fix(session): return proper exit codes for cmd_continue and fork_agent #259

Merged
shoko merged 1 commits from fix/issue-248 into main 2026-04-08 08:42:32 +02:00
Owner

Summary

Modify cmd_continue and fork_agent to return proper exit codes for better daemon integration.

Exit Codes

Exit Code Meaning
0 Success - agent forked successfully
1 General error - worktree/session/validation failed
2 Max concurrent agents reached (MAX_CONCURRENT_AGENTS limit)

Changes

  • fork_agent(): Returns exit code instead of echoing status string
  • cmd_continue(): Returns exit code 2 when max agents reached, exit code 1 for general errors
  • ensure_worktree(): Returns exit code 2 when max agents condition is detected
  • EXITCODES.md: New documentation file describing all exit codes

Daemon Integration

These exit codes help the queue daemon distinguish between recoverable errors (exit 2 = max agents, can retry later) and non-recoverable errors (exit 1 = task should be marked as failed).

Closes #248

## Summary Modify `cmd_continue` and `fork_agent` to return proper exit codes for better daemon integration. ### Exit Codes | Exit Code | Meaning | |-----------|---------| | 0 | Success - agent forked successfully | | 1 | General error - worktree/session/validation failed | | 2 | Max concurrent agents reached (MAX_CONCURRENT_AGENTS limit) | ### Changes - **fork_agent()**: Returns exit code instead of echoing status string - **cmd_continue()**: Returns exit code 2 when max agents reached, exit code 1 for general errors - **ensure_worktree()**: Returns exit code 2 when max agents condition is detected - **EXITCODES.md**: New documentation file describing all exit codes ### Daemon Integration These exit codes help the queue daemon distinguish between recoverable errors (exit 2 = max agents, can retry later) and non-recoverable errors (exit 1 = task should be marked as failed). Closes #248
shoko added 1 commit 2026-04-08 08:29:16 +02:00
- fork_agent() now returns exit code instead of echoing status
- cmd_continue() returns exit code 2 when max agents reached
- cmd_continue() returns exit code 1 for general errors (instead of exit 1)
- ensure_worktree() returns exit code 2 for max agents condition
- Add EXITCODES.md documenting all exit codes

Closes #248
han approved these changes 2026-04-08 08:41:38 +02:00
han left a comment
First-time contributor

lgtm

lgtm
shoko merged commit 920d714c8f into main 2026-04-08 08:42:32 +02:00
Sign in to join this conversation.