Skip to content

Keep agent processes alive for one-hour idle window - #165

Merged
MiniMax-AI-Dev merged 1 commit into
mainfrom
fix/agent-process-idle-timeout
Jul 13, 2026
Merged

Keep agent processes alive for one-hour idle window#165
MiniMax-AI-Dev merged 1 commit into
mainfrom
fix/agent-process-idle-timeout

Conversation

@RyanLee-Dev

Copy link
Copy Markdown
Collaborator

Summary

  • stop terminating Claude Code and Codex subprocesses as soon as a prompt emits its terminal result
  • close each run's protocol stream immediately while retaining the underlying CLI process
  • retain completed sessions by AgentStateKey and cancel them only after one hour with no new prompt for the same state key
  • reset the idle window whenever a new prompt arrives for that state key
  • keep explicit prompt cancellation, device shutdown, daemon shutdown, and transport failure as immediate teardown paths

Root cause

PR #103 added terminal cleanup that called Process.Cancel / closed the Codex RPC client immediately after each response. That correctly removed leaked foreground CLI processes, but it also killed background work started by the agent as soon as the response finished.

Validation

  • real fake-Claude subprocess test verifies the result stream closes while the CLI remains alive until Cancel
  • Codex test verifies terminal completion leaves the RPC child and session context alive
  • dispatch tests verify idle cancellation and renewal by a subsequent prompt
  • focused race tests pass for Claude, Codex, and dispatch lifecycle paths
  • affected package tests pass; the unrelated known Claude plugin concurrency test remains flaky in the full package run
  • make check passed all Go packages, then stopped because the local Docker daemon exhausted its predefined network address pools
  • git diff --check

@MiniMax-AI-Dev
MiniMax-AI-Dev merged commit 6962a93 into main Jul 13, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants