[PR #10134] fix: propagate subagent retry status to primary agent #13353

Closed
opened 2026-02-16 18:18:13 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/10134

State: closed
Merged: No


Problem

Issue #5204 reported that when a subagent hits a rate limit error, the primary agent continues to "spin" indefinitely without showing any error message to the user.

Root Cause

  • When a subagent encounters a retryable error (like rate limit), it enters a retry loop
  • The retry state is stored only in the subagent's session
  • TaskTool returns successfully even when the subagent is retrying
  • Primary agent has no visibility into the subagent's retry state

Solution

This PR propagates the subagent's retry status to the primary agent:

  1. TaskTool (task.ts): Now includes the subagent's SessionStatus in the return metadata
  2. SessionPrompt (prompt.ts): Checks if the subagent is retrying and propagates the status to the primary agent

Changes

  • packages/opencode/src/tool/task.ts: Add SessionStatus to return metadata
  • packages/opencode/src/session/prompt.ts: Check and propagate subagent retry status

Testing

Validated through:

  • Static code analysis and type checking
  • Verified OpenCode builds and runs successfully
  • Code path analysis confirms correct logic flow
  • Backward compatible (new field is optional)

Real-world rate limit testing can be performed in staging environment.

Impact

  • Backward compatible (new field is optional)
  • Minimal performance impact (single Map lookup)
  • Significantly improves user experience by showing retry status instead of appearing to hang

Fixes #5204

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/10134 **State:** closed **Merged:** No --- ## Problem Issue #5204 reported that when a subagent hits a rate limit error, the primary agent continues to "spin" indefinitely without showing any error message to the user. ## Root Cause - When a subagent encounters a retryable error (like rate limit), it enters a retry loop - The retry state is stored only in the subagent's session - TaskTool returns successfully even when the subagent is retrying - Primary agent has no visibility into the subagent's retry state ## Solution This PR propagates the subagent's retry status to the primary agent: 1. **TaskTool** (`task.ts`): Now includes the subagent's `SessionStatus` in the return metadata 2. **SessionPrompt** (`prompt.ts`): Checks if the subagent is retrying and propagates the status to the primary agent ## Changes - `packages/opencode/src/tool/task.ts`: Add SessionStatus to return metadata - `packages/opencode/src/session/prompt.ts`: Check and propagate subagent retry status ## Testing Validated through: - ✅ Static code analysis and type checking - ✅ Verified OpenCode builds and runs successfully - ✅ Code path analysis confirms correct logic flow - ✅ Backward compatible (new field is optional) Real-world rate limit testing can be performed in staging environment. ## Impact - ✅ Backward compatible (new field is optional) - ✅ Minimal performance impact (single Map lookup) - ✅ Significantly improves user experience by showing retry status instead of appearing to hang Fixes #5204
yindo added the pull-request label 2026-02-16 18:18:13 -05:00
yindo closed this issue 2026-02-16 18:18:13 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13353