fix(tool-pair-validator): skip placeholder repair for subagent sessions#4032
Merged
code-yeongyu merged 1 commit intoMay 15, 2026
Conversation
Guard the tool-pair validator when transformed assistant messages belong to a tracked subagent session, while keeping normal main-session orphaned tool_use repair intact. Constraint: code-yeongyu#3996 reports background Oracle sessions hanging after synthetic placeholder tool_result insertion. Rejected: disable tool-pair-validator globally | would regress main-session compaction/orphaned tool_use repair. Confidence: high Scope-risk: narrow Directive: Keep subagent skip coverage and normal repair coverage together when changing tool-pair validation. Tested: bun test src/hooks/tool-pair-validator/hook.test.ts src/plugin/messages-transform.test.ts Tested: bun run typecheck Not-tested: live Oracle background task e2e; no remote push or PR comment performed.
There was a problem hiding this comment.
No issues found across 2 files
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: The change is narrowly scoped to skip placeholder repair only when the session is a tracked subagent, the new helper and condition are correct, existing tests pass, and a regression test covers both the skip and the unchanged main-session path, so there is no risk of regressions.
This was referenced May 15, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tool-pair-validatorhook inserts a synthetic placeholder tool_result when an assistant message contains an orphan tool_use. This is the right behavior for the main session (compaction can strip tool_results), but it corrupts background sub-agent sessions where the orphan is expected and the synthetic placeholder breaks downstream consumers.Changes
src/hooks/tool-pair-validator/hook.ts: read the session id from the transformed message via a smallgetMessageSessionIDhelper; bail out ofrepairMissingToolResultsif the session is tracked insubagentSessions. Import the registry fromsrc/features/claude-code-session-state.src/hooks/tool-pair-validator/hook.test.ts: new regression test asserting that a transformed assistant message owned by a tracked subagent session is left untouched, plus the existing main-session repair coverage stays green.Rationale (from commit body)
Testing
Not tested end-to-end against a live Oracle background task — that would need a real session reproduction, which I don't have a deterministic setup for. The unit coverage exercises both the subagent-skip path and the main-session repair path.
Related Issues
Closes #3996