fix(agent): fallback to fresh start when resume args fail#180
Merged
Conversation
When a resumed agent exits with a non-zero code and the output indicates a resume-args failure (e.g. Claude's \"No conversation found to continue\"), automatically restart the agent without resume args instead of leaving it in an exited state. Co-Authored-By: Claude Opus 4.7 <[email protected]>
Owner
ReviewNice, focused fix — I traced the full flow and the core logic is correct and, importantly, loop-safe: A few things worth addressing: Important
Minor
Verdict: Ready to merge once the |
Owner
|
Thank you very much! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When using Claude Code (which supports session resumption via
--continue) to create a task, if the user closes and restarts the app before any conversation has taken place, the system relaunches the agent using theresume_argsdefined inAgentDef. Because no session exists to continue, the process exits immediately withNo conversation found to continue, forcing the user to manually click the restart button to recover the task.1. Root Cause
resumedstate are launched withAgentDef.resume_args(for Claude Code this is typically--continue).2. Solution
This PR adds resume-failure detection in the
onExitcallback ofTaskAITerminal:resumedstate, exits with a non-zero code, and its final output matches a known resume-failure signature (e.g. Claude'sNo conversation found to continue), it automatically callsrestartAgent(id, false).falseskipsresume_argsand falls back toAgentDef.args, starting a fresh session without requiring manual intervention.It also introduces
isResumeArgsFailureinsrc/lib/agent-args.tsto centralize the resume-failure signatures for each CLI, making future extensions easier.