Skip to content

Fix backend runner lifecycle handling#75

Merged
DorianZheng merged 1 commit into
mainfrom
codex/fix-codex-agentlite-lifecycle
Apr 30, 2026
Merged

Fix backend runner lifecycle handling#75
DorianZheng merged 1 commit into
mainfrom
codex/fix-codex-agentlite-lifecycle

Conversation

@DorianZheng

Copy link
Copy Markdown
Member

Summary

  • Delay JSONL CLI host result emission until backend completion instead of treating intermediate assistant messages as final
  • Track live BoxLite boxes with atomic heartbeat records so startup cleanup preserves active runs
  • Force-remove boxes during explicit agent deletion and clear heartbeat records on teardown and error paths
  • Add regression coverage for message completion handling and box ownership cleanup races

Why

The runner could finalize too early on the first assistant message, and startup cleanup could remove an active VM when AgentLite instances overlapped. The new heartbeat flow distinguishes live owners from stale boxes, including PID reuse, failed removals, and partial-write cases.

Impact

Active runs are less likely to be interrupted, explicit deletes still clean up boxes, and host clients receive a single final result after backend completion.

Validation

  • PATH=/opt/homebrew/bin:$PATH ./node_modules/.bin/tsc --noEmit
  • git diff --check
  • PATH=/opt/homebrew/bin:$PATH ./node_modules/.bin/vitest run --maxWorkers=4 (one timing assertion in src/acp/client.e2e.test.ts failed during the full parallel run)
  • PATH=/opt/homebrew/bin:$PATH ./node_modules/.bin/vitest run src/acp/client.e2e.test.ts --maxWorkers=1
  • PATH=/opt/homebrew/bin:$PATH ./node_modules/.bin/vitest run src/box-runtime.test.ts src/container-agent-backend.test.ts src/container-runner.test.ts --maxWorkers=4

@DorianZheng DorianZheng marked this pull request as ready for review April 30, 2026 12:58
@DorianZheng DorianZheng merged commit 9f3091f into main Apr 30, 2026
2 checks passed
@DorianZheng DorianZheng deleted the codex/fix-codex-agentlite-lifecycle branch April 30, 2026 12:58
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.

1 participant