Skip to content

feat(acp): continue a codex subagent from its persisted thread - #11960

Merged
bolichen97 merged 1 commit into
mainfrom
feat/acp-codex-session-sharing
Sep 19, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
feat/acp-codex-session-sharing

Conversation

@iamwhatever

@iamwhatever iamwhatever commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

A codex subagent pays for a whole second agent: its own Node adapter and its own codex app-server. Kiro subagents do not. They get a session on the parent's process.

Codex was kept out of that because of one belief: its teardown verb session/close evicts the session, so a shared subagent "would not survive" the conversation that spawned it, and spawn_continue would answer conversation_gone.

The belief measured the wrong thing. close disposes the live session. It leaves the thread codex wrote under CODEX_HOME alone. That thread is what a continuation needs.

Why it matters

Every ordinary codex subagent spawns a second adapter tree today. That is slower to start and costs memory nothing reclaims until the process is recycled.

It also left the repo asserting something untrue in six places, including two tests built to hold codex out.

What changed (motivation → approach → change)

Codex subagents now run on the parent's runtime, and a finished one can still be continued.

piece what it does where
ACP_BACKENDS_SESSION_SHARING codex joins kiro src/kiro_crew/agent_sdk/backends.py
teardown unchanged — still session/close, still evicts src/kiro_crew/acp/harness/codex.py
continuation session/load on the thread under CODEX_HOME src/kiro_crew/subagent_manager/run.py
_bind_shared_handle_impl reads the served backend's label instead of fixing it at kiro's src/kiro_crew/subagent_manager/run.py
the record set comment, harness docstrings, three spec rows, four RFC passages docs/system-specs/modules/harness-parity.md, docs/system-specs/modules/providers.md, docs/system-specs/modules/agent-host-contract.md, docs/request-for-change/rfc-crew-agent-sdk-boundary.md
KIROCREW_LIVE_CODEX_PROMPT_TESTS new test-only env gate: the one live test that sends session/prompt runs only when this equals 1 test/test_codex_session_mcp.py

Sharing here does not mean a session that stays alive. A resident subagent session would hold the MCP fleet codex starts from its own config — about 44 processes and 2751 MB for one session — on a runtime nobody is using. So teardown keeps closing, and the conversation is reached again by loading the record the host kept. That is what kiro already does with its transcript under <kiro home>/sessions/cli.

So membership asks one question: after this backend's teardown verb, can a session/load still restore the thread? Codex answers yes. KAS answers no, because _kiro/session/delete removes the record, and that is the whole of its exclusion.

The label read is a smaller thing than it looks, and the body of this PR is where to say so. _bind_shared_handle_impl wrote kiro's label for every backend. It is not what a continuation reads: _run_inner_impl re-captures the label from the same provider right after session acquisition, and that write is what reaches state.json. A run that completes was always labelled correctly, and the live run below confirms it — the continuation succeeds with the old constant in place. What the constant owns is the window before that re-capture. A run cancelled there leaves the identity record claiming kiro for a session another host holds, and the tombstone prune then takes _cleanup_session_files_sync's kiro branch, unlinks a path that was never going to exist, and reports cleanup succeeded — where the real label returns "no cleanup route for this provider" and the prune keeps its retry metadata.

No keep-alive teardown variant exists in this diff. The idea was considered and dropped: the measurement says codex never needed one.

Backwards compatibility

Compatible: codex subagents move from a dedicated session to a shared one, which is the behaviour kiro subagents already have. Nothing is rejected, renamed or removed, no teardown verb changes, and a subagent whose spawn carries a model pin, an allowed_tools list or bare still takes the dedicated arm.

Tests

  • test_acp_codex_harness.py — codex is in the sharing set, the provider answers eligible, and the same test asserts the teardown verb is still the disposing session/close and that codex is in ACP_BACKENDS_HARNESS_OWNED_SESSIONS, so "sharing" cannot be read as "resident".
  • test_acp_codex_harness.py — the runtime set still does not imply sharing, now shown with KAS.
  • test_acp_capability_sets_leaf.py, test_harness_parity.py — the set's value, its proper-subset relation to ACP_BACKENDS_ACP_RUNTIME, and the opt-in ratchet, all re-pointed at KAS as the separating member.
  • test_subagent_continuable.py::TestSharedBindIdentityLabel — a real AcpSessionProvider over a codex runtime is bound, and the published live cleanup identity, the persisted identity and info._session_provider all read codex; the kiro case is pinned beside it because ACP_BACKEND_KIRO is the empty string and a truthiness test would have sent kiro down the wrong branch. Mutation-verified: restoring the old constant kills the codex test and leaves the kiro one green.
  • test_codex_session_mcp.py::test_provider_config_only_excludes_process_configuration — the ambient config.toml copied into the throwaway CODEX_HOME is narrowed to an allowlist of provider keys, so mcp_servers in any spelling (header table, inline, dotted) plus hooks and notify cannot ride in and start the operator's own processes. Carries no skip marker, so it runs in CI where the live test does not.
  • test_codex_session_mcp.py::test_real_codex_acp_load_after_close_restores — a gated live test against a real adapter: close evicts, session/load on the closed id restores and recalls the first turn, the same load works from a restarted adapter process, and session/delete archives the thread so a later load refuses. Skips unless KIROCREW_LIVE_CODEX_PROMPT_TESTS equals exactly 1 and CODEX_PATH is set and a codex config.toml exists. The opt-in is separate on purpose: CODEX_PATH is configuration that anyone using the internal codex wrapper exports, so it is not consent to spend model tokens. This is the only test in the file that sends session/prompt; the other two live tests handshake without a model call and carry no such gate.

Manual verification

The capability was driven end to end against a real codex-acp 1.11.0 and a real codex 0.154.0.488, on the final commit:

run_shared_arm: true          run_pid: 4140343 == runtime_pid: 4140343
state_provider: codex         run_result: "OK"
runtime_alive_after_parent_teardown: false
continue_resumed_same_sid: true
continue_result: "nutmeg"     continue_error: ""

A parent session on the codex backend, an ordinary spawn (no keep, no pin) that landed on the parent's runtime, the parent torn down with its process confirmed dead, then continue_conversation — which resumed the same sessionId and answered with the word the first turn planted.

The same run was driven twice, once with the label read in place and once with the bind-site constant restored, because that is what decides whether the label read is the fix or a separate correctness point:

tree state shared arm state.json provider continuation
membership + label read yes, run_pid == runtime_pid codex same sid, answered nutmeg
membership only, constant restored yes, run_pid == runtime_pid codex same sid, answered marzipan

Both rows resume. So the shared-subagent path was never what made a codex spawn_continue answer conversation_gone, and the label is not what this PR fixes — ACP_BACKENDS_SESSION_SHARING membership is. The claim that a persisted PROVIDER_LABEL_DEFAULT breaks the ordinary continuation does not hold: _run_inner_impl re-captures the label from the provider before anything persists state.json, and that write is authoritative. The label read earns its place on the cancellation window described above, not on this path.

The adapter-level half was measured separately with token accounting. On the restarted adapter the recall turn spent 330 input tokens against 9786 cached-read, above the planting turn's 7738, so the restored thread is in the cached prefix rather than re-sent.

Two host limits are disclosed rather than worked around. This box cannot create user namespaces (unshare(CLONE_NEWUSER) → EPERM), so no Crew sandbox backend exists and codex's OS credential mask can never be applied; the driver patched sandbox.credential_mask_applies to True in its own process only, which is the one product gate it bypassed. The user bus is also unreachable, so clearing XDG_RUNTIME_DIR put the cgroup scope on the product's own documented no-systemd-user-session path. Everything downstream of those two ran real code.

One observation the run produced that this PR does not change: spawn_release on a codex conversation reports released, and a later continue still resumes it. release_conversation_impl calls _cleanup_session_files_sync, which has no route for a non-kiro provider and returns False having deleted nothing, while state.json keeps the sid — so the continuation re-seeds. It is disk state rather than resident memory, holds for every backend that owns its session store, and predates this change. Tracked in #11959 with the session/delete archive proof.

Backend gates green: mypy (1631 files), flake8, isort, black, harness-parity, agent-sdk-boundary, feature-map, docs-lint, comment-history, and the scoped backend selection at 28756 passed. Three failures in test_app_manager.py::TestMalformedMcpUrlIsSkippedNotFatal reproduce identically on a clean origin/main checkout of the same commit, so they are this host's, not this diff's.

Related Issues

Closes #11274

Related: #11959 — spawn_release disposes nothing on a backend that owns its session store. Disk state, not resident memory, so it is outside this line of work's leak rule; deferred deliberately rather than wired to session/delete here.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@iamwhatever
iamwhatever requested review from a team and smeyffret September 19, 2026 06:27
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Intent: Let an ordinary codex subagent run on its parent's runtime instead of paying its own adapter tree, and stay continuable afterwards by loading the thread codex persisted — so spawn_continue works on codex the way it already works on kiro.
Not a goal: Keeping a subagent session resident after its parent ends (any keep-alive teardown variant), changing codex's teardown verb, admitting KAS to the sharing set, or making spawn_release dispose a harness-owned session record.

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 19, 2026
@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — 🔴 changes requested (blocking)

GPT 5.6 found at least one blocking issue that must be resolved before merging db59c29ce82f209d4205ce51b7e80930dba4ee09. Adjudication upheld 1 of 1 blocking finding(s); those must be resolved before merging.

This comment is updated in place on each push.

BLOCKING -- test/test_codex_session_mcp.py:1835 -- Real-adapter contract tests became skip-only (origin: validation)
@pytest.mark.skipif(_ENTRY is None, reason="codex-acp not installed")
Required adapter lane -> tests no longer selected by real_adapter or fail closed via require_real_adapter -> CI reports green without checking Codex adapter behavior.
Anchor: a-ratchet-may-only-tighten
Fix: Restore the real_adapter markers and require_real_adapter guards on the three existing adapter tests.
[GPT-REVIEWED] db59c29
[BLOCK-MERGE] db59c29

Adjudication (Opus 4.8) — is blocking on each finding proportionate?

F1 is anchored to a-ratchet-may-only-tighten (AUTOSDE.yaml:717, blocking: true). The diff confirms the anchor's criteria exactly: test/test_codex_session_mcp.py lost its @pytest.mark.real_adapter markers on three live-adapter tests (diff hunks at src lines 1832, 2096, 2172) and deleted the require_real_adapter fail-closed guard (_require_codex_acp removed at 1784), replacing both with skip-only @pytest.mark.skipif (1835-1836). The CI "Real Adapter Contract Tests" lane selects tests via pytest -m real_adapter (ci.yml:1715), so the marker removal drops these tests from the lane entirely, and KIROCREW_E2E_REQUIRE=1 no longer forces them closed — precisely the "newly added skip / deleted assertion in a file the diff otherwise only extends" the rule flags. The rule's blocking: true flag is authoritative and outranks weighing.

Harm rung: this is a blocking AUTOSDE rule; not weighed.
Conditions confirmed: markers removed (test_codex_session_mcp.py:1835), guard deleted (test_codex_session_mcp.py:1784 hunk), lane selects on marker (ci.yml:1715).
Real fix cost: restore three markers + guard calls — trivial, does not abandon the PR's feature.

[ADJUDICATION] db59c29ce82f209d4205ce51b7e80930dba4ee09 total=1 uphold=1 downgrade=0
UPHOLD F1 test/test_codex_session_mcp.py:1835 reason=autosde-blocking-rule
[GPT-ADJUDICATED] db59c29ce82f209d4205ce51b7e80930dba4ee09

False positive or not applicable? A repository writer can comment:
/ai-review override gpt db59c29ce82f209d4205ce51b7e80930dba4ee09: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — 🔴 BLOCK (blocking)

Design-level review of db59c29ce82f209d4205ce51b7e80930dba4ee09 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

Design-Verdict: BLOCK

Stale-base test rewrites revert two sibling pins that landed at base — one assertion is provably red at this PR's own HEAD.

Blockers

Rewritten pins clobber #11944 and #11946, unmentioned in the description.
The new test_membership_is_unchanged_by_the_move asserts ACP_BACKENDS_COMPACT == frozenset({ACP_BACKEND_KIRO, ACP_BACKEND_CLAUDE}), but src/kiro_crew/agent_sdk/backends.py:886 at HEAD still reads frozenset({ACP_BACKEND_KIRO, ACP_BACKEND_CLAUDE, ACP_BACKEND_CODEX}) (codex compaction, #11944, whose comment says "Membership is what stops a codex session growing unbounded") — so the test fails on every run, and "fixing" it by editing the source would reopen unbounded codex session growth. In the same file the PR strips require_real_adapter/@pytest.mark.real_adapter (#11946's fail-closed lane gate) back to plain skipif, deleting the docstring that named the forbidden behaviour ("a lane whose only guard skipped reports success having measured nothing") — the E2E lane that installs the pinned adapter now silently skips when the install breaks. Both are decisions at base, treated as text to rewrite; the claimed 28756-test run must predate this rebase. Fix: rebase the test edits onto the true base — keep codex in the COMPACT assertion, keep the real_adapter gate on the two handshake tests (the new token-spend gate stacks on top).
Clears when: the COMPACT assertion matches backends.py:886 and the two live handshake tests re-carry require_real_adapter/real_adapter (or a human states the #11946 gate removal is intended), with the scoped gate re-run on the rebased head.

Watch

The invariant membership rests on — session/load restores after session/close — runs only under KIROCREW_LIVE_CODEX_PROMPT_TESTS=1, so an adapter release that makes close destructive breaks shared-subagent continuation with no lane going red; the backends.py comment ("repeats the measurement on every install that has the adapter") overstates the guard.
Clears when: the comment states the opt-in honestly, or a token-free lane check (or explicit acceptance in the spec) covers the restore semantics.

[DESIGN-REVIEWED] db59c29

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — 🔴 BLOCK

Premise-level review of db59c29ce82f209d4205ce51b7e80930dba4ee09 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: BLOCK

The sharing change is measured and clean; riding beside it, the diff silently deletes six pinned tests and flips ratchets no source in this PR implements.

Not justified as shipped

  • Item 5 — undeclared: the two pre-existing live codex tests lose require_real_adapter, whose deleted docstring says "a lane whose only guard skipped reports success having measured nothing"; the description never mentions it.
    Subtraction: delete the replacement skipifs and keep the real_adapter mark on test_real_codex_acp_accepts_the_crew_stdio_element and test_real_codex_acp_session_close_evicts.
    Clears when: the gate is back, or a rebase removes this hunk from the diff.
  • Item 6 — undeclared: ACP_BACKENDS_COMPACT re-pinned to {kiro, claude} while agent_sdk/backends.py:886 ships codex as a member, with a measured rationale.
    Clears when: the hunk is gone after a rebase, or a source change plus description sentence carries the removal.
  • Item 7 — undeclared: test_subagent_continuable.py is mass-rewritten far beyond the declared TestSharedBindIdentityLabel, deleting and reversing pins with no implementing source.
    Clears when: see Blockers.

What this change ships

Inventory (9 items) — 6 justified

Intent: stop paying a dedicated adapter tree for every codex subagent by running it on the parent's runtime, with continuation served from codex's persisted thread — ADDITION.

  1. Ordinary codex subagents run on the parent's runtime instead of spawning a second adapter tree — justified
  2. A finished shared codex subagent stays continuable via session/load on the CODEX_HOME thread — justified
  3. Shared-bind cleanup identity records the serving backend's label instead of kiro's constant — justified
  4. New test-only opt-in KIROCREW_LIVE_CODEX_PROMPT_TESTS=1 gates the one token-spending live test — justified
  5. Existing live codex tests now skip instead of failing the adapter-required lane — undeclared, deletes a pin whose message states its purpose
  6. ACP_BACKENDS_COMPACT test pin drops codex — undeclared, contradicts the shipped source
  7. Continuation/restricted-memory test suite rewritten: six tests deleted, expectations reversed — undeclared, no implementing source in this diff
  8. The live test copies only provider keys from the operator's config.toml, excluding mcp_servers/hooks/notify — justified
  9. Specs, RFC passages and harness docstrings updated to the new membership in the same commit — justified

Blockers

  • Undeclared pin deletions with no implementing source. The Tests section names only TestSharedBindIdentityLabel, yet the diff deletes test_run_execution_publication_is_off_loop and all five TestRestrictedRunStateLifetime tests, and reverses test_override_cannot_establish_missing_lineage — a test whose name says the override cannot succeed now asserts it does. The rewrites call sp._run_agent_identity_path/_run_memory_identity_path and match "protected agent template unavailable": grepped src/, 0 hits for all three, so these tests cannot pass on this tree. With items 5–6 this reads as one root cause — the branch has diverged from its base — and the diff reverses recorded decisions the description never mentions.
    Subtraction: drop every hunk in test_subagent_continuable.py except TestSharedBindIdentityLabel, the ACP_BACKENDS_COMPACT re-pin, and the _require_codex_acp removal.
    Clears when: a push or rebase onto current main leaves the diff carrying only the declared sharing, label, doc and test additions — or the source implementing the rewritten pins ships in this PR with each deleted pin named in the description.

[FIRST-PRINCIPLES-REVIEWED] db59c29

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — 🔴 changes requested (blocking)

Reviewed db59c29ce82f209d4205ce51b7e80930dba4ee09 — this comment is updated in place on each push.

The candidate is confirmed against source. agent_sdk/backends.py:886 defines ACP_BACKENDS_COMPACT with three members including ACP_BACKEND_CODEX, and this PR does not touch that line. The test edit at test/test_acp_capability_sets_leaf.py:175 asserts a two-member set, so the assertion fails deterministically. The sibling test_codex_compaction.py:148 (ACP_BACKEND_CODEX in ACP_BACKENDS_COMPACT, unchanged) corroborates that codex is still a member. Fix is in-diff.

BLOCKING — the diff's own test edit asserts a ACP_BACKENDS_COMPACT value that no longer matches the unchanged source set, so CI goes red.

[BLOCK-MERGE] db59c29

BLOCKING — test/test_acp_capability_sets_leaf.py:175
assert ACP_BACKENDS_COMPACT == frozenset({ACP_BACKEND_KIRO, ACP_BACKEND_CLAUDE})
Running test_membership_is_unchanged_by_the_move → reads the unchanged ACP_BACKENDS_COMPACT = frozenset({ACP_BACKEND_KIRO, ACP_BACKEND_CLAUDE, ACP_BACKEND_CODEX}) (agent_sdk/backends.py:886, not touched by this PR) → the three-member set never equals the asserted two-member set → AssertionError, this test fails in CI.
Fix: restore codex — assert ACP_BACKENDS_COMPACT == frozenset({ACP_BACKEND_KIRO, ACP_BACKEND_CLAUDE, ACP_BACKEND_CODEX}).

[OPUS-REVIEWED] db59c29

Verdict parsed from the review's SHA-scoped output markers for commit db59c29ce82f209d4205ce51b7e80930dba4ee09.

False positive or not applicable? A repository writer can comment:
/ai-review override fable db59c29ce82f209d4205ce51b7e80930dba4ee09: <one-sentence reason>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Sep 19, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: no
mechanism: none added; this records why the measured adapter floor stays unversioned.

  • Record the verified codex-acp floor the way the hot-reload set does (span=e930ecc200be) — rebutted as disproportional here.

Accurate about the shape and I am not fixing it, for a reason the suggestion itself
supplies: drift degrades to conversation_gone through the fail-closed resume guard
that is still in place, so the failure mode is a refused continue, not a wrong answer.
That is the whole difference from ACP_BACKENDS_MCP_CONFIG_HOT_RELOAD, whose floor
exists because drift there leaves a user's freshly installed servers unmounted with
nothing red to say why.

A version floor would also be the weaker guard of the two available. The live test
test_real_codex_acp_load_after_close_restores re-measures the behaviour itself on
every install that has the adapter, so an adapter release that makes close
destructive goes red on the property rather than on a number someone has to remember
to bump. A floor read from initialize would pass on a 1.12.0 that broke the
behaviour and fail on a 1.10.x that never had it, which is the wrong test in both
directions.

What the suggestion is right about is that the version is currently recorded only in
prose. It is named in the set comment, the harness docstring and the spec row, all
beside the measurement it came from, which is where a reader looking for "what was
this verified against" will be standing. Promoting it to a read gate is worth doing
the day a codex release actually breaks this, because then there is a real floor
rather than a guessed one.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: no
mechanism: none added; the RFC/spec corrections delete stale prose rather than adding a structure.

  • The RFC MCP-array passages ride along on a sharing change (span=de04951ab46b) — rebutted: the correction is in scope by instruction, and the alternative is worse.

Correct that these passages are not about session sharing, and they are here on
purpose rather than by accident. The symbols they described -- _codex_session_mcp_servers()
and the _is_codex spawn arm -- were deleted when codex moved onto the shared runtime,
which is the change this PR completes; correcting the prose that still named them was a
named deliverable of this round, not a discovery mid-review.

The reviewer's own verification is the argument for doing it here: 0 hits in src/.
A spec that describes a deleted private method is what walks the next author into
re-adding it, and the cost of that is paid by whoever collapses the next per-backend
arm. Splitting it into its own PR would mean a docs-only change whose whole
justification lives in this diff's history, reviewed by someone with none of this
context.

Scope was bounded deliberately rather than left open. The sweep was the full deleted
SET across docs/, root *.md and .github/, not only the paths named to me -- which
is how agent-host-contract.md was found carrying the same two stale symbols, and it
is corrected in the same commit for the same reason. Nothing else matched.

The two remaining mentions in the RFC are deliberate and stay: an RFC records what was
true when it was written, so those passages are past-tense narrative that now say
outright that the method no longer exists. Rewriting them to present tense would make
the document lie about its own history.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the ambient-config copy in the gated live test, added in this PR and now narrowed to an allowlist.

  • Inline MCP configuration bypasses isolation (span=cf849040cdfe) — fixed in 392eba23ab.

Upheld and fixed. The chain holds exactly as written: the helper classified only
table HEADERS, so mcp_servers = { ... } inline and mcp_servers.name = { ... }
dotted both reached the else branch, left skipping False, and were copied into the
throwaway CODEX_HOME -- after which codex starts the operator's own MCP processes.
The adjudication's containment points are accurate and did not change the verdict:
an opt-in prompting run and a group SIGKILL reap bound the blast radius, they do not
remove it.

The fix is not the one requested, and deliberately. Adding the two missing spellings
keeps a denylist on an open axis: TOML has more ways to write that key than a filter
will enumerate, and the next reader inherits the trap. Inverted to an ALLOWLIST of the
six provider scalars plus whole model_providers tables, so every other key is
excluded by construction -- the three mcp_servers forms, and hooks, notify and
otel with them, none of which the test needs and any of which can start a process.

Verified where it counts. The live test is gated on CODEX_PATH and SKIPS in CI, so a
fix proven only through it would ship unverified; the new pure-function test carries no
skip marker and asserts the literal strings are absent from the output. Mutation-verified
both ways: restoring the header-only body fails it on assert "mcp_servers" not in filtered, and the allowlist passes. 174 passed, 1 skipped on the two affected files.

Degradation direction checked: if the allowlist omits a key some host needs, the live
test skips on its existing incomplete-prompt guard rather than failing falsely.

@iamwhatever
iamwhatever force-pushed the feat/acp-codex-session-sharing branch from 7ae7ca8 to 4bdd2e1 Compare September 19, 2026 07:05
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Rebased: main moved from cff7de54165b to 0e7ba9a6f0be while this round was in repair; the two commits it gained touch none of this PR's 12 files (empty path intersection), and the rebased diff is line-identical to the pre-rebase one — 802 added/removed lines, sorted sets equal. CI re-running on 4bdd2e1540.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 19, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the CODEX_PATH gate on the prompting live test, added by this PR and now joined by an explicit opt-in.

  • Live model calls lack an explicit test opt-in (span=cf849040cdfe) — fixed in 24ce11a498.

Upheld. CODEX_PATH is configuration, not consent: anyone using the internal codex
wrapper exports it in their shell, so an ordinary pytest test/ on such a machine
reached session/prompt and charged real usage to whoever ran it. That is the
no-test-side-effects anchor, and it is a different defect from the one this span
carried on the previous head -- that was process-start, this is spend.

Fixed as asked: KIROCREW_LIVE_CODEX_PROMPT_TESTS must equal exactly "1". An exact
comparison rather than a truthiness test, so 0, true and yes all skip -- verified
three ways with CODEX_PATH set, and each skips naming the variable in its reason. The
authorising value was never used while verifying a gate whose purpose is to not spend.
The existing CODEX_PATH, node and adapter gates stay: they are necessary conditions,
the new variable is the authorising one.

The sibling sweep is why this should not recur. session/prompt occurs EXACTLY ONCE in
this file, in _LOAD_DRIVER, written by this one test; the other two live tests use
_DRIVER and _CLOSE_DRIVER and never prompt, the close test using
session/set_config_option as its oracle. So they make no model call and correctly
carry no such gate -- an opt-in there would only stop a measurement that costs nothing.
Verified by grep, not by reading.

Keeping rather than removing the gated test was deliberate: it is the anti-drift guard
the sharing membership rests on, named in the set comment, so deleting it to satisfy the
finding would trade a spend risk for an unpinned capability claim.

@iamwhatever
iamwhatever force-pushed the feat/acp-codex-session-sharing branch from 4bdd2e1 to 24ce11a Compare September 19, 2026 07:21
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Rebased: main moved from 0e7ba9a6f0be to 8e27f52fc696 during this round; the commits it gained touch none of this PR's files (empty path intersection), and the rebased diff is line-identical to the pre-rebase one (811 added/removed lines, sorted sets equal). CI re-running on 24ce11a498.

@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Sep 19, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: KIROCREW_LIVE_CODEX_PROMPT_TESTS, a test-only env gate added while answering a security finding.

  • The new test-only env gate is undeclared in the description (span=d88a782edf12) — fixed by describing it.

Upheld, and the gap was mine rather than the reviewer's reading. The variable was added
to answer a spend finding and the description still named only CODEX_PATH, so the one
document a reader consults to learn what this change introduces did not mention it. An
undeclared knob is how a knob nobody remembers survives.

The description now names it in the change table and in the test section, states the
exact required value, and records why it is separate from CODEX_PATH -- configuration
that the internal wrapper's users all export is not consent to spend model tokens.

On the observation that its semantics differ from the KIROCREW_E2E* family: correct,
and that is why it is not one of them. Those select whether a suite runs; this one
authorises money. Folding a spend gate into a run-selection family would make the next
author reason about cost from a variable name that has never meant cost. One consumer is
the honest scope: exactly one test in the tree sends session/prompt, verified by grep,
so a broader gate would guard nothing today and would invite being read as covering
calls it does not.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

self-added: no
mechanism: none added; the RFC and spec corrections delete stale prose rather than introduce a structure.

  • The RFC MCP-array rewrites record earlier PRs' work, not this change (span=17de4fc97a26) — rebutted: in scope by instruction, and the alternative costs more.

Accurate that these passages describe the MCP-mirror work rather than session sharing,
and they are here deliberately. The symbols they named -- _codex_session_mcp_servers()
and the _is_codex spawn arm -- were deleted when codex moved onto the shared runtime,
which is the line of work this change completes, so correcting the prose that still
named them was a named deliverable of this round rather than something noticed in
passing.

The reviewer's own framing supplies the argument for doing it here: harm-free doc
freshness, and declared in the table rather than smuggled. A spec that still describes a
deleted private method is what walks the next author into re-adding it, and that cost
lands on whoever collapses the next per-backend arm. Splitting it out would produce a
docs-only PR whose entire justification lives in this diff, reviewed by someone holding
none of this context.

Scope was bounded rather than left open: the sweep covered the full deleted symbol set
across docs/, root *.md and .github/, which is how agent-host-contract.md was
found carrying the same two stale names and corrected alongside. Nothing else matched.
The two remaining mentions in the RFC stay on purpose -- an RFC records what was true
when written, and those are past-tense passages that now say the method no longer exists.

@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 19, 2026
@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Sep 19, 2026
bolichen97 pushed a commit that referenced this pull request Sep 19, 2026
amadsalmon pushed a commit to amadsalmon/KiroCrew that referenced this pull request Sep 22, 2026
…otdev#11960)

Put codex in ACP_BACKENDS_SESSION_SHARING, so an ordinary codex subagent
runs on its parent's runtime instead of paying its own Node process and
app-server.

Teardown is unchanged: a subagent session is still closed, because one
left resident holds the MCP fleet codex starts from its own config on a
runtime nobody is using. What spawn_continue addresses is the thread
codex persists under CODEX_HOME, restored with session/load -- measured
on codex-acp 1.11.0 against codex 0.154.0, including from a restarted
adapter process.

Also reads the served backend's label at the shared bind instead of
fixing it at kiro's, and corrects the record: the set comment, the
harness docstrings, three spec rows and the RFC passages naming symbols
that no longer exist.

Co-authored-by: zejiangg <zejiangg@amazon.com>
amadsalmon pushed a commit to amadsalmon/KiroCrew that referenced this pull request Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

codex: evict a dropped session instead of only cancelling its turn

3 participants