Skip to content

Fix/handle error subtypes in result message - #479

Merged
feifei325 merged 4 commits into
mainfrom
fix/handle-error-subtypes-in-result-message
Feb 6, 2026
Merged

feifei325 merged 4 commits into
mainfrom
fix/handle-error-subtypes-in-result-message

Conversation

@FicoHu

@FicoHu FicoHu commented Feb 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Refactor
    • Enhanced agent result tracking with improved logging of stop reason information for Claude responses.

yunpeng7 and others added 2 commits February 6, 2026 16:22
… stuck

When Claude SDK returns ResultMessage with subtype like "error_during_execution"
but is_error=False, the task would remain in RUNNING state indefinitely.

This fix handles all error_ prefixed subtypes per official documentation:
- error_during_execution: Error occurred during execution
- error_max_turns: Reached turn limit
- error_max_budget_usd: Exceeded budget limit
- error_max_structured_output_retries: Reached structured output retry limit

Ref: https://platform.claude.com/docs/agent-sdk/stop-reasons

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add stop_reason field to result details and log output for better
debugging and monitoring of Claude SDK responses.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Feb 6, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@FicoHu has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 24 minutes and 26 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📝 Walkthrough

Walkthrough

The pull request adds a stop_reason field to the result_details dictionary during ResultMessage processing and updates the corresponding log message to include this new field alongside existing metadata.

Changes

Cohort / File(s) Summary
ResultMessage Processing
executor/agents/claude_code/response_processor.py
Added stop_reason field to result_details dictionary and updated log output to include stop_reason alongside subtype and is_error.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Suggested reviewers

  • qdaxb

Poem

🐰 A stop_reason hops into our logs so bright,
Where messages are processed day and night,
Logging truth with clarity and care,
One small field, but oh, what's hiding there! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The PR title mentions 'handle error subtypes in result message', but the actual changes add a stop_reason field to result_details and update logging. The title is misleading about the primary change. Update the title to accurately reflect the main change, such as 'Add stop_reason field to result message processing' or 'Include stop_reason in result message details and logging'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/handle-error-subtypes-in-result-message

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

yunpeng7 and others added 2 commits February 6, 2026 17:11
Move detailed callback body to DEBUG level, keep INFO log concise
with only task_id and status.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@feifei325
feifei325 merged commit 19cec38 into main Feb 6, 2026
12 checks passed
@feifei325
feifei325 deleted the fix/handle-error-subtypes-in-result-message branch February 6, 2026 09:17
maquan0927 pushed a commit to maquan0927/Wegent that referenced this pull request Feb 11, 2026
* fix(executor): handle error subtypes in ResultMessage to prevent task stuck

When Claude SDK returns ResultMessage with subtype like "error_during_execution"
but is_error=False, the task would remain in RUNNING state indefinitely.

This fix handles all error_ prefixed subtypes per official documentation:
- error_during_execution: Error occurred during execution
- error_max_turns: Reached turn limit
- error_max_budget_usd: Exceeded budget limit
- error_max_structured_output_retries: Reached structured output retry limit

Ref: https://platform.claude.com/docs/agent-sdk/stop-reasons

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* feat(executor): add stop_reason to ResultMessage logging

Add stop_reason field to result details and log output for better
debugging and monitoring of Claude SDK responses.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* refactor(executor): simplify callback log output

Move detailed callback body to DEBUG level, keep INFO log concise
with only task_id and status.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: yunpeng7 <yunpeng7@staff.weibo.com>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
fengkuizhi pushed a commit that referenced this pull request Mar 3, 2026
Fix/handle error subtypes in result message (#479)

See merge request weibo_rd/common/wecode/wegent!1404
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.

2 participants