feat: native background subagents (next_agent/agents_status) + auto-continue for transient provider errors - #40923
feat: native background subagents (next_agent/agents_status) + auto-continue for transient provider errors#40923mdsohail99 wants to merge 4 commits into
Conversation
…asoning_content, JSON parse)
DeepSeek thinking-mode quirk (400 invalid_request_error 'reasoning_content must be passed back')
and model output JSON-parse errors (AI_JSONParseError / JSON parsing failed) are transient:
a minimal 'continue' user prompt resumes the session and it completes normally.
- retry.ts: isAutoContinueError classifier (reasoning_content AND must-be-passed-back, or
AI_JSONParseError / JSON parsing failed), classified before the isRetryable/5xx early-return
so 400-class isRetryable:false errors still retry; AUTO_CONTINUE_MAX=2 cap
- processor.ts: on auto-continue retry, append {role:user, content:continue} to the retried
request so it is not byte-identical to the rejected one (a plain retry fails identically)
- tests: classifier positives/negatives, retryable() both shapes, policy cap termination
…ckground primitives)
…request queue is full' - isAutoContinueError adds /request queue is full/i (distinctive token only, not 'streaming response failed' or bare 503, to avoid over-matching genuine Service Unavailable errors) - retryable() classifies it before the isRetryable/5xx early-return; policy cap and processor continue-append reach it via the shared matcher (processor.ts unchanged — already consumes isAutoContinueError) - tests: classifier positives/negatives incl. generic 503 negatives, retryable() as APIError statusCode 503 isRetryable:false, 5xx sanity guard
Note on
|
Type of change
What does this PR do?
Adds native background sub-agent orchestration to the core and makes transient provider errors self-recovering:
Background subagents —
Task(background=true)primitives plusnext_agent(drain semantics) andagents_status(non-blocking snapshot) tools, enabling true parallel async fan-out of sub-agents from a single session.Auto-continue on transient provider errors — three error families that are not real failures get resumed automatically with a minimal "continue" prompt instead of failing the step:
reasoning_content must be passed back(400)AI_JSONParseError/JSON parsing failed[503] The request queue is fullThe retry policy classifies these as retryable and the processor appends a
{role:user, content:"continue"}message to the retried request so it is not byte-identical to the rejected one (a plain same-request retry fails identically). Retries are capped (2) so genuinely stuck sessions still surface their error.Agent-Teams orchestrator definition (
.opencode/agent/orchestrator-agent-teams.md) — the async team-orchestration agent wired to the new native primitives.How did you verify your code works?
bun test test/session/retry.test.ts— 69 pass / 0 fail (classifier positives/negatives, retryable() both APIError and UnknownError shapes, policy cap termination)bun test test/session/processor-effect.test.ts— 16 pass / 0 fail (no regression, incl. upstream midstream server-error retry test)bun run typecheckin packages/opencode — passesChecklist