Skip to content

fix(smithy): release agent pool slots on session end#124

Open
furquanuddin94 wants to merge 10 commits into
stoneforge-ai:masterfrom
furquanuddin94:codex/fix-agent-pool-session-release
Open

fix(smithy): release agent pool slots on session end#124
furquanuddin94 wants to merge 10 commits into
stoneforge-ai:masterfrom
furquanuddin94:codex/fix-agent-pool-session-release

Conversation

@furquanuddin94
Copy link
Copy Markdown

@furquanuddin94 furquanuddin94 commented May 16, 2026

Summary

Fixes #121.

Agent pool slots are now released when worker or steward sessions terminate, including sessions cleaned up after dead-process detection. This prevents pools from staying full when no governed session is actually running.

Stacking note

This PR is stacked on upstream PRs #116 and #118. The agent-pool fix itself is in the top five commits on this branch:

  • ff02229 fix(smithy): release agent pool slots on session end
  • 1f888ec fix(smithy): keep pool slots tied to active agents
  • e2945db fix(smithy): reserve pool slots before session start
  • 218eafc fix(smithy): wait for session end cleanup before restart
  • 1705e4d docs: clarify agent pool changeset

Changes

  • Add session-ended callbacks to SessionManager so pool cleanup can run when sessions leave active execution.
  • Register agent-pool cleanup with the Smithy server services.
  • Reserve pool slots before provider spawn work can exit, so short-lived failed sessions are still released through the normal session-ended path.
  • Ensure dispatch waits for session-end cleanup before immediately starting another session for the same agent.
  • Add coverage for session cleanup, pool slot release, and dispatch reuse behavior.

Test plan

  • bun test packages/smithy/src/runtime/session-manager.bun.test.ts
  • bun test packages/smithy/src/services/agent-pool-service.bun.test.ts
  • bun test packages/smithy/src/services/dispatch-daemon.bun.test.ts
  • corepack pnpm --filter @stoneforge/smithy typecheck
  • git diff --check
  • Manual sanity check in local Smithy: pool slot releases after worker/steward sessions terminate.

Checklist

  • Tests pass
  • Typecheck passes
  • Changeset added (if applicable)

Extract the Codex interactive argument construction into buildCodexInteractiveArgs so the unit test exercises the same production arg-building logic used by spawn instead of duplicating that logic in the test. The helper preserves the existing working-directory, resume, and model behavior.

Codex now documents --sandbox workspace-write as the replacement for the deprecated --full-auto shortcut, so use the documented sandbox flag for fresh and resumed interactive sessions.

Refs stoneforge-ai#114.
…-flag

fix(smithy): update codex interactive sandbox flag
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.

bug: agent pool slots remain occupied after sessions terminate

1 participant