🌐 US-Proxy
class="logged-out env-production page-responsive" style="word-wrap: break-word;" >
Skip to content

fix(coderd/x/chatd): surface child error detail in wait_agent last_error - #27477

Merged
ibetitsmike merged 1 commit into
mainfrom
mike/subagent-error-detail
Jul 24, 2026
Merged

fix(coderd/x/chatd): surface child error detail in wait_agent last_error#27477
ibetitsmike merged 1 commit into
mainfrom
mike/subagent-error-detail

Conversation

@ibetitsmike

@ibetitsmike ibetitsmike commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

When a child subagent chat fails, its persisted last_error carries both a normalized message and an actionable provider detail. The wait_agent tool result returned only the message, which for unclassified failures is the generic fallback "The chat request failed unexpectedly." The detail (for example reasoning model `max` not supported) never reached the parent model, so it retried blind instead of self-correcting (observed in dogfood chat 37c516d2: the parent respawned a kimi-k3 child with max effort twice and needed human intervention to switch to xhigh).

Changes

  • subagentLastErrorMessage now builds the last_error string with the detail: detail alone when the message is empty or the generic fallback, message (detail) when both are meaningful, and message alone when there is no detail. This mirrors exactly what the chat UI already renders from the same persisted payload; no content is added or removed relative to what the user sees in the chat window.
  • Unrecognized payloads (raw bytes that do not decode as a ChatError) no longer surface at all; the handler falls back to its status reason instead of exposing raw stored JSON.
  • Unit table test for the helper plus regression tests asserting the detail-aware last_error on both the normal wait_agent poll path and the timeout TOCTOU recheck path.

Both paths share the same response block, so no other tool payloads change.

An earlier revision added read-path credential redaction (auth-detail suppression plus scrubbing regexes) on top of this. It was removed: the same detail is already served verbatim to the same user through the chats API and rendered in the chat window, so a wait_agent-only scrub added inconsistency without a security boundary, and its opaque-token heuristic destroyed useful diagnostics such as request IDs. If provider error bodies echoing credentials ever becomes a demonstrated problem, the fix belongs at classification/write time in chaterror so every surface stays consistent.

Validation

  • go test ./coderd/x/chatd/..., make lint/go green.
  • Dogfood UAT on a dev instance: injected the production fixture into a child chat and confirmed the parent's wait_agent result now carries reasoning model `max` not supported instead of the generic message.

This PR was authored by Mux, an AI coding agent, operating on Mike's behalf.

@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4e8294b774

ℹ️ 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".

Comment thread coderd/x/chatd/subagent.go
@ibetitsmike
ibetitsmike force-pushed the mike/subagent-error-detail branch from 4e8294b to de969b6 Compare July 23, 2026 23:53
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: de969b63c3

ℹ️ 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".

Comment thread coderd/x/chatd/subagent.go Outdated
@ibetitsmike
ibetitsmike force-pushed the mike/subagent-error-detail branch from de969b6 to 5a743ff Compare July 24, 2026 00:03
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5a743ff821

ℹ️ 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".

Comment thread coderd/x/chatd/subagent.go Outdated
@ibetitsmike
ibetitsmike force-pushed the mike/subagent-error-detail branch from 5a743ff to f50e4ab Compare July 24, 2026 00:18
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f50e4ab27b

ℹ️ 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".

Comment thread coderd/x/chatd/subagent.go Outdated
@ibetitsmike
ibetitsmike force-pushed the mike/subagent-error-detail branch from f50e4ab to f221d4d Compare July 24, 2026 00:30
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

Reviewed commit: f221d4d762

ℹ️ 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".

@ibetitsmike
ibetitsmike marked this pull request as ready for review July 24, 2026 15:51
Comment thread coderd/x/chatd/subagent.go Outdated
@ibetitsmike
ibetitsmike force-pushed the mike/subagent-error-detail branch from f221d4d to 87f065b Compare July 24, 2026 18:01
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 87f065bef1

ℹ️ 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".

Comment thread coderd/x/chatd/subagent.go
@ibetitsmike

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 87f065bef1

ℹ️ 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".

Comment thread coderd/x/chatd/subagent.go
@ibetitsmike
ibetitsmike merged commit ff10beb into main Jul 24, 2026
32 checks passed
@ibetitsmike
ibetitsmike deleted the mike/subagent-error-detail branch July 24, 2026 19:01
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants