parallel-code icon indicating copy to clipboard operation
parallel-code copied to clipboard

fix(agent): fallback to fresh start when resume args fail

Open FourWindff opened this issue 5 months ago • 0 comments

Summary

When using an Agent CLI that supports session resumption (like Claude Code) to create a Task, if the user closes and restarts the app without having any conversation first, the system relaunches the Agent using the resume_args defined in AgentDef. Since there is no existing session to continue, the process exits immediately with No conversation found to continue, forcing the user to manually click the restart button to recover the Task.

1. Root Cause

  • After the app restarts, Agents in the resumed state are launched with AgentDef.resume_args (for Claude Code this is typically --continue or equivalent).
  • If no actual conversation happened before the restart, the CLI cannot find a session to resume and exits with an error.
  • The previous implementation had no automatic fallback when an Agent exited due to failed resume arguments, leaving the user to manually restart.

2. Solution

This PR adds resume-failure detection in the onExit callback of TaskAITerminal:

  • If the Agent is in resumed state, exits with a non-zero code, and its final output matches a known resume-failure signature (e.g. Claude's No conversation found to continue), it automatically calls restartAgent(id, false).
  • Passing false skips resume_args and falls back to AgentDef.args, starting a fresh session without requiring manual intervention.

It also introduces isResumeArgsFailure in src/lib/agent-args.ts to centralize the resume-failure signatures for each CLI, making future extensions easier.

FourWindff avatar Jun 16 '26 15:06 FourWindff