Skip to content

fix(agents): harden structured error-code classification edge cases#1663

Merged
wpfleger96 merged 1 commit into
mainfrom
worktree-wpfleger+agent-error-code-hardening
Jul 8, 2026
Merged

fix(agents): harden structured error-code classification edge cases#1663
wpfleger96 merged 1 commit into
mainfrom
worktree-wpfleger+agent-error-code-hardening

Conversation

@wpfleger96

Copy link
Copy Markdown
Collaborator

Post-merge review of #1653 surfaced several edge cases in the structured error-code seam where classification silently degrades or misfires. This PR closes them.

  • Unknown structured codes are now authoritative: a finite lastErrorCode the UI doesn't recognize returns generic copy immediately instead of falling through to string-prefix matching, so a future code (e.g. a rate-limit classification) whose message happens to start with llm auth: can no longer render the relay-membership copy.
  • Number.isFinite guards replace the != null checks, so NaN (from a non-numeric payload.code) is treated as no-code rather than entering the switch.
  • When the code field is lost (downgrade, i64 parse failure), friendlyAgentLastError now recovers the code embedded in the message via the "Agent reported error (code N): " Display format before falling back to legacy prefixes.
  • buzz-acp no longer truncates non-standard JSON-RPC errors to "unknown error": when the message field is missing or non-string, the full JSON object is preserved (e.g. {"code":-32000,"data":"quota exceeded"}). The duplicated extraction at the prompt and steer read loops is folded into one agent_error_from_json helper.
  • Bare llm auth: / llm model not found: log-line promotion is restored in meaningful_agent_error_from_log with synthetic codes (-32001 / -32002), so older agent binaries that log unwrapped prefixes surface a classified error instead of the generic "harness exited with status N".
  • The dead AgentError match arm in the transport-error branch of handle_prompt_result is removed by hoisting a single error_code extraction above both branches.
  • Cleanups from the same review: accurate module docstring in friendlyAgentLastError.ts (the old one described the pre-fix(agents): surface provider errors structurally instead of raw dumps #1653 architecture), doc comments on AgentLogError, the promotes_unwrapped_llm_auth test asserts promotion again (matching its name), new coverage for the legacy log format, and the E2E fixture uses the new-format error string.

Related: #1653

Post-merge review of #1653 found gaps in the error-code seam: unknown
codes could cross-classify via string prefixes, NaN slipped past the
null guard, new-format log strings were unclassifiable when the code
field was lost, non-standard JSON-RPC errors were truncated to
"unknown error", and bare llm-auth log lines from older agent binaries
regressed to the generic exit message. Unknown structured codes are now
authoritative (generic, no string matching), codes embedded in the
message are recovered, the full JSON error object is preserved when
message is absent, and bare-prefix promotion is restored with
synthetic codes.
@wpfleger96 wpfleger96 merged commit fc8a174 into main Jul 8, 2026
28 checks passed
@wpfleger96 wpfleger96 deleted the worktree-wpfleger+agent-error-code-hardening branch July 8, 2026 22:18
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