Skip to content

fix(replay): preserve agent on fallback prompt replay#8

Merged
blazejpawlak merged 2 commits intomainfrom
fix/preserve-agent-on-fallback
Mar 18, 2026
Merged

fix(replay): preserve agent on fallback prompt replay#8
blazejpawlak merged 2 commits intomainfrom
fix/preserve-agent-on-fallback

Conversation

@blazejpawlak
Copy link
Copy Markdown
Contributor

Summary

  • Pass agent in the session.prompt body during fallback replay so the fallback model runs under the same agent as the original request
  • Without this, OpenCode defaults to its built-in plan agent (read-only mode), causing the fallback model to refuse tool execution

Root Cause

orchestrator.ts already resolves and stores agentName (e.g. "OpenCoder") before the abort→revert→prompt sequence, but the session.prompt body only included model and parts. The missing agent field caused OpenCode to fall back to its default plan agent.

Test plan

  • Hit a rate limit with a non-default agent (e.g. OpenCoder) — confirm fallback model responds as that agent, not in plan mode
  • Verify bun test passes (101 tests, no failures)
  • Verify bunx tsc --noEmit is clean

🤖 Generated with Claude Code

blazejpawlak and others added 2 commits March 18, 2026 15:15
Pass `agent` in the session.prompt body so the fallback model runs
with the same agent as the original request. Without this, OpenCode
defaults to its built-in plan agent (read-only mode), causing the
fallback model to refuse tool execution.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add two cases to the orchestrator test suite:
- agent name from the failing message is passed to session.prompt
- agent is omitted (undefined) when it could not be resolved

Also extend MockClientCalls.prompt to capture the agent field.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@blazejpawlak blazejpawlak merged commit 774ad97 into main Mar 18, 2026
@blazejpawlak blazejpawlak deleted the fix/preserve-agent-on-fallback branch March 18, 2026 19:36
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 1.0.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant