Skip to content

🔦 fix: Log Why a Selected Subagent Could Not Start - #583

Open
danny-avila wants to merge 1 commit into
mainfrom
danny-avila/subagent-resolution-diagnostics
Open

danny-avila wants to merge 1 commit into
mainfrom
danny-avila/subagent-resolution-diagnostics

Conversation

@danny-avila

Copy link
Copy Markdown
Collaborator

Summary

When a selected subagent fails to start, SubagentExecutor returns a fixed sentence ("Unable to initialize the selected subagent.") and logs nothing. That's deliberate for the model, since resolver errors can carry host secrets. But it leaves operators with no record of which step failed.

We hit this in production. A background PR-review subagent calls a nested verifier subagent. The nested calls failed in 4 of 5 runs, and in every failure the parent's foreground turn had already ended. Nothing in the logs said whether identity preparation failed, the host resolver rejected, or the child had been aborted.

This change logs one structured warning at each of the two start-up failure points. It follows the no-quoting rule in src/tools/diagnostics.ts: every field is a value the SDK owns, or the host-registered subagent type. The error's text is never included.

[SubagentExecutor] Subagent resolution failed { phase: 'config', subagentType: 'agent_…', aborted: false, type: 'Error' }
Field Meaning
phase identity (execution identity/lease) or config (host resolveAgentInputs, then the usability check)
subagentType The registered config's type, not the model's argument
aborted Whether the composed child signal was aborted
type The SDK's own binding/invalidation error classes, else the built-in class label from describeCodeApiError

The host still owns its own error text: a host that wants the message should log it where its resolver throws.

Changes

  • src/tools/subagent/diagnostics.ts: logSubagentResolutionFailure and a non-quoting error classifier.
  • SubagentExecutor.ts: calls it from both SUBAGENT_RESOLUTION_ERROR_MESSAGE catch sites. The pre-commit Prettier/import-sort hook also reformatted a few existing lines in this file; those are formatting only.
  • Tests: the existing redaction test now asserts the warning's exact shape and that the resolver's secret never reaches it. A new test covers the aborted: true path.

Testing

  • npx jest src/tools/subagent: 4 suites, 127 tests passed.
  • npx jest src/tools/__tests__/subagentHooks.test.ts src/graphs src/run: 13 suites, 212 tests passed.
  • npx tsc --noEmit: clean. ESLint: clean on the changed files.

Both start-up failure paths returned a fixed sentence and logged nothing, so an operator could not tell an execution-identity failure from a host resolver rejection or an aborted child. Log the phase, the registered subagent type, whether the child signal was aborted, and the error's class, under the same no-quoting rule as the Code API diagnostics.
@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-30T03:17:00.918095Z c639b65 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: c639b65f4a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: c639b65f4a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danny-avila

Copy link
Copy Markdown
Collaborator Author

@codex review — final review pass for head c639b65. Please do a complete final review of this exact head.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: c639b65f4a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant