Skip to content

Port stale multi-agent slot cleanup from Codex CLI #214

@shiny-code-bot

Description

@shiny-code-bot

Current Status

State: Completed; PR #220 merged.
Next action: None for this issue.
Blocked by: None.
Waiting for: Nothing.
Last verified: 2026-05-29. PR #220 merged into main at 66fa099361510f8d3ca60bbc4603102db56dc318; remote task branch was deleted.

Implementation:

  • Ported the stale-slot behavior concept from OpenAI e2551a5e36 into Every Code's editable AgentManager model.
  • Every Code's equivalent explicit close operation is agent.cancel; it now treats an active agent record with no task handle as stale, marks it Cancelled, stamps completion time, finalizes terminal state, and returns success.
  • Added regression cancel_agent_reaps_stale_active_record_without_handle.

Validation:

  • cargo test -p code-core cancel_agent_reaps_stale_active_record_without_handle
  • ./build-fast.sh
  • JetBrains changed-files inspection clean: 0 problems.

Finish Line

Every Code releases stale multi-agent capacity when a spawned agent/thread disappears before explicit close, with a regression test covering the stuck-slot scenario.

Acceptance Criteria

  • Map OpenAI e2551a5e36 behavior to Every Code's code-rs multi-agent implementation rather than cherry-picking read-only codex-rs paths.
  • Add a focused failing regression for an agent that remains registered after its backing task/thread is gone.
  • Implement cleanup so explicit close or equivalent recovery marks the stale agent closed and frees capacity.
  • Preserve normal close behavior for healthy running agents.
  • Validate with ./build-fast.sh.

Notes

This is a product hardening port, not a mechanical upstream import. The source fix touches codex-rs/core/src/agent/control.rs and codex-rs/core/src/tools/handlers/multi_agents*, while Every Code's editable implementation has diverged.

Metadata

Metadata

Assignees

No one assigned

    Labels

    planDurable planning issueplan:donePlan completed or superseded

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions