fix: handle Claude Agent SDK 0.3.x system messages to stop runtime-warning flood#2872
fix: handle Claude Agent SDK 0.3.x system messages to stop runtime-warning flood#2872imabdulazeez wants to merge 2 commits into
Conversation
- no-op thinking_tokens to stop flooding work log - map permission_denied to runtime warning with tool + reason - map mirror_error to runtime.error
- new ToolDeniedPayload schema and ProviderRuntimeToolDeniedEvent in contracts - permission_denied system subtype emits tool.denied instead of runtime warning - ingestion maps tool.denied to a distinct error-tone work-log entry
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Needs human review Unable to check for correctness in 423af15. You can customize Macroscope's approvability policy. Learn more. |
What Changed
Teach the Claude adapter about the
systemmessage subtypes added in the@anthropic-ai/claude-agent-sdk0.3.xbump, so they stop falling through to thegeneric "Unhandled subtype" runtime warning:
thinking_tokens→ no-op. This is the one the SDK streams continuously while amodel is in its extended-thinking phase, and is responsible for the nonstop
warnings on every prompt.
permission_denied→ emits a new dedicatedtool.deniedprovider-runtime event.mirror_error→ mapped toruntime.error.Adds the
tool.deniedruntime event (contract + ingestion) so a denied tool showsup as a distinct, error-toned work-log entry (tool name + reason) instead of a
generic "Runtime warning".
Why
The
0.3.xSDK introduced newsystemmessage subtypes.ClaudeAdapter'shandleSystemMessageswitch only knows the older set, so anything new hits thedefaultbranch and emits aruntime.warning.thinking_tokensis emittedrepeatedly throughout a model's thinking, so every prompt floods the work log with
"Runtime warning" entries — exactly what's reported in #2870.
Handling the three new subtypes explicitly removes the noise while keeping the
defaultbranch as a catch-all so genuinely-unknown future messages are stillsurfaced.
permission_deniedandmirror_errorare real signals, so they're routedto meaningful events rather than silently dropped.
Fixes #2870
UI Changes
No visual/component changes. Behavioral only: the work log no longer fills with
repeated "Runtime warning" entries on every prompt (the "before" is the screenshot
in #2870), and a denied tool now renders as a distinct error-tone entry.
Checklist
Note
Handle Claude Agent SDK 0.3.x system messages to stop runtime-warning flood
thinking_tokens,permission_denied, andmirror_errorsubtypes to the system message handler in ClaudeAdapter.ts:thinking_tokensis silently ignored,permission_deniedemits a newtool.deniedruntime event, andmirror_erroremits a runtime error instead of an unhandled warning.tool.deniedevent type in providerRuntime.ts with a payload carryingtoolName,toolUseId,reason, andagentId.tool.deniedevents to an error activity in ProviderRuntimeIngestion.ts, surfacing the tool name and denial reason in the activity summary.Macroscope summarized 423af15.