Skip to content

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

Merged
iamwhatever merged 1 commit into
mainfrom
feat/acp-codex-session-sharing-reland
Sep 20, 2026
Merged

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

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. KIROCREW_LIVE_CODEX_PROMPT_TESTS=1 is the ONE gate that decides whether it runs, and it is the only skipif on it. Past that gate every precondition fails rather than skips: codex-acp absent, node off PATH, CODEX_PATH unset, no codex config.toml, a refused session/new, a planting prompt that does not reach end_turn. test_real_adapter_gate.py::test_no_guarded_test_carries_a_skip_the_lane_cannot_see is what forbids the skipif(_ENTRY is None) form in this file, on the ground that a skipif cannot fail. The opt-in is a declaration that this host holds a working credentialled codex, so a run that reports success having measured nothing is the shape the no-silent-skip rule refuses; a host that cannot meet it unsets the variable. 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.

The full scoped backend selection is not re-run here: this host is memory constrained and the instruction for this branch is the affected files at -n 2. When that wide selection was last driven on this feature it reported three failures in test_app_manager.py::TestMalformedMcpUrlIsSkippedNotFatal, which reproduced identically on a clean origin/main checkout of the same commit, so they are this host's rather than this diff's. CI runs the selection.

Re-land of #11960 (reverted in #12088)

#11960 was merged on a base that predated three commits, and a rebase-merge replayed
its older copies of two test files over them. #12088 reverts it. This branch is the
same feature rebuilt on the current base: the reverts are what it was developed
against, and nothing here re-applies a file state.

what main gained after the old base what the merge did to it what this branch does
bc0d2b0cfc #11780 — one-SQLite-store subagent_persistence test/test_subagent_continuable.py was replaced by a pre-refactor copy calling the removed _run_agent_identity_path; 25 tests failed on every shard the file is main's, and only TestSharedBindIdentityLabel is added to it
bf3fccf7d5 #11946 — Real Adapter Contract Tests lane test/test_codex_session_mcp.py lost the three @pytest.mark.real_adapter markers and the require_real_adapter guard, so the lane selected 1 test against a floor of 4 the file is main's, guard and all three markers intact, and only the load-after-close blocks are added
d92b8c4162 #11944 — codex session compaction test_acp_capability_sets_leaf.py collapsed the ACP_BACKENDS_COMPACT pin from three members back to two the pin is main's, and #11942 has since taken it to four (kiro, claude, codex, opencode) — this branch carries main's value byte for byte and changes only the ACP_BACKENDS_SESSION_SHARING pin

The third row is not in #12088's text. It surfaced here because every file the old
commit touched was diffed against the revert base and each line confirmed as this
feature's own, rather than only the two failures being repaired.

The new live test deliberately carries no real_adapter marker. The contract lane
installs adapters from a pinned manifest and then asserts on its own junit report that
no SELECTED case was skipped. It holds no model credential and does not set this test's
spend opt-in, so a marked case here would be selected, skip, and turn the lane red —
the exact shape that assertion exists to refuse. Selection stays at 4, the floor's
value, verified by collection. What covers this file on every shard is
test_provider_config_only_excludes_process_configuration, which carries no marker and
no skip.

Verified on this branch, rebased onto origin/main with #12088 already in it: 576
passed, 1 skipped across the eight affected files, which include the compaction and
capability pins and the real-adapter corpus gate; -m real_adapter collects 4; mypy clean on 1647 files; black, flake8, isort,
agent-sdk-boundary, docs-lint, comment-history, harness-parity and feature-map all
green. The re-landed TestSharedBindIdentityLabel is still mutation-verified on the
current API: restoring the hardcoded label fails the codex case and leaves the kiro one
green.

Related Issues

Re-lands #11960, which was reverted in #12088. #11274 was closed by that merge and stays closed, so this PR claims no closing keyword for it.

no linked issue: every issue this touches is already in its final state. #11274 is closed and stays closed, #11960 and #12088 are pull requests, and #11959 is a deliberate follow-up this change does not close.

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 bolichen97 September 19, 2026 21:38
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Intent: Re-land #11960 on a current base — an ordinary codex subagent runs on its parent's runtime and stays continuable 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, changing codex's teardown verb, admitting KAS to the sharing set, making spawn_release dispose a harness-owned record, or touching anything #11780, #11946 or #11944 landed — this branch takes main's copy of every contested file and adds only its own content.

@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

Design Review (Fable 5) — ✅ PASS

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

Design-Verdict: PASS

Verify the claimed credentialled test_real_codex_acp_load_after_close_restores run — CI can never re-check the restore property this membership rests on.

Suggestions

  • The load-after-close invariant is guarded only by a doc comment in test/real_adapter_gate.py; a follow-up that makes the codex-acp bump checklist (or a scheduled credentialled job) actually run the opt-in test would close the "release reaches the field before any lane goes red" window the PR itself names.

[DESIGN-REVIEWED] fae998c

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of fae998cbd9b819023f9162053c6f9bb87cccefd2 — 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: PASS

One measurement carries the whole membership and no CI lane ever re-runs it: confirm the credentialled KIROCREW_LIVE_CODEX_PROMPT_TESTS=1 run happened on this head.

The reversal of the base pins is the honest kind: the deleted comment itself recorded the exclusion as conditional ("out of this set until the missing pieces land — a keep-aware teardown, and a provider label the continuation path can read"), the PR shows the first piece was mismeasured and ships the second, and a runnable gated test plus the rewritten pins carry the new facts. The partial RFC rfc-resumable-subagent-sessions already records "Session sharing | On by default" with shared-sid loadability as its Phase 0 question, so the shape has a base-side record. The label fix reuses the existing _provider_label_of already called at run.py:1077 and run.py:1170 (grepped: no PROVIDER_LABEL_DEFAULT write remains in run.py), and the sharing set has a real consumer chain (providers/acp.py:629 → session_allocation.py:788 → run.py:2738).

What this change ships

Inventory (8 items) — 8 justified

Intent: stop paying a dedicated adapter tree for every codex subagent and make a finished one continuable, on the measured fact that codex's persisted thread survives session/close — an ADDITION.

  1. A codex subagent now runs on its parent's runtime instead of spawning its own adapter tree — justified
  2. A finished codex subagent can now be continued; spawn_continue reloads the persisted thread — justified
  3. A run cancelled before session capture now records the backend that served it, so cleanup fails closed instead of falsely succeeding — justified
  4. New test-only opt-in KIROCREW_LIVE_CODEX_PROMPT_TESTS=1 gates the one token-spending live test — justified
  5. That live test copies only provider keys from the operator's codex config, so operator-configured processes cannot start during it — justified
  6. Tests that pinned codex out of sharing now pin it in, with the disposing teardown still asserted beside it — justified
  7. Harness docstrings, three spec rows and four RFC passages updated to the new membership in the same commit — justified
  8. The adapter-gate doc now names the one contract a codex-acp bump must re-measure by hand — justified

[FIRST-PRINCIPLES-REVIEWED] fae998c

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of fae998cbd9b819023f9162053c6f9bb87cccefd2 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] fae998c

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

@github-actions

github-actions Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] fae998c

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable fae998cbd9b819023f9162053c6f9bb87cccefd2: <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

iamwhatever commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the opt-in live test's preconditions are pytest.fail calls, and the three capability skipif decorators are gone with them; the diff adds no pytest.skip anywhere

  • opted-in live test silently skips failed preconditions (span=cf849040cdfe) — fixed in 8e33ff8

Fixed, and the fix reaches further than the three lines cited.

The three pytest.skip calls at 2951, 2977 and 2980 are pytest.fail calls, each
carrying the driver's captured context so a red names what the adapter actually
answered. The reasoning the finding is right about: KIROCREW_LIVE_CODEX_PROMPT_TESTS=1
is a DECLARATION that this host holds a working credentialled codex, the same shape
KIROCREW_E2E_REQUIRE=1 already has in test/real_adapter_gate.py. Under a declaration
an absent precondition is a red, not silence — a host that cannot meet it unsets the
variable.

The same defect had a decorator form the finding did not reach, so it went too:
skipif(_ENTRY is None), skipif(shutil.which("node") is None) and
skipif(not os.environ.get("CODEX_PATH")) are now the same pytest.fail checks in the
body. That form is independently forbidden by main's own corpus gate,
test_real_adapter_gate.py::test_no_guarded_test_carries_a_skip_the_lane_cannot_see, on
the ground that a skipif cannot fail and so restores the silence the lane removes — and
that gate was red on shard 6 of the reviewed head, linux and Windows both, which is the
same defect arriving as a failing check. It is green now. The one remaining skipif is
the spend opt-in itself, which is what decides whether the test runs at all.

What still skips in this file is two of main's own lane tests, at 1930 and 2171, both
already behind require_real_adapter — which fails rather than skips under
KIROCREW_E2E_REQUIRE=1. Neither is this diff's line.

Measured on 8e33ff8: 576 passed, 1 skipped over the eight affected files (the single
skip is this opt-in test, unopted); -m real_adapter still collects 4, the lane's floor;
test_real_adapter_gate.py 20 passed; mypy clean on 1647 files; black, isort, flake8,
comment-history and harness-parity green.

@iamwhatever

iamwhatever commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor Author

self-added: yes
mechanism: the sharing-set comment in backends.py states which half the contract lane measures and which half it cannot, and test/real_adapter_gate.py names the credentialled run a codex-acp bump has to cover by hand

  • the regression tripwire for continuation is overstated in the code record (span=1d9658900687) — fixed in 8e33ff8

Fixed on the first of the two clearing options, because the second was attempted first
and measured impossible.

The attempt: make the restore assertable by the contract lane, which holds no model
credential, by asserting session/load on a session created and closed without a prompt.
codex refuses that load — "no rollout found for thread id" — because a thread that never
ran a real turn has no rollout to reload. No wording of a lane test reaches the property;
it is not a matter of how the assertion is phrased. The assertion was not relaxed to
match that refusal.

So the record is corrected instead, and it now separates the halves the way the
measurement does. The EVICT half is lane-covered: test_real_codex_acp_session_close_evicts
carries the real_adapter marker, so an adapter release that stops session/close
evicting goes red in the lane. The RESTORE half — the one codex's membership in
ACP_BACKENDS_SESSION_SHARING actually rests on — is asserted only by
test_real_codex_acp_load_after_close_restores, which prompts and therefore runs only
where a host sets KIROCREW_LIVE_CODEX_PROMPT_TESTS=1 and holds a codex credential,
never in CI. The comment says that, and says the consequence plainly: an adapter bump
does not re-measure the restore, so a release that made close destroy the record would
reach the field before any lane went red.

The process half of the finding is where the bump requirement lands.
test/real_adapter_gate.py's docstring is what a bump PR's author reads, and it now
names this one contract the lane cannot measure, why it cannot, and that a codex-acp bump
needs one credentialled run of that opt-in test beside the lane's green — the lane going
green alone does not establish it.

The property itself is measured, on a real codex-acp 1.11.0 against a real codex
0.154.0.488, and the numbers are in this PR's body: the load restores on the same adapter
process and on a restarted one over the same CODEX_HOME, with the recall turn spending
330 input tokens against 9786 cached-read. What the finding is right about is that the
code record claimed a standing tripwire for it, and there is none.

@iamwhatever
iamwhatever force-pushed the feat/acp-codex-session-sharing-reland branch from 1a966aa to 8e33ff8 Compare September 19, 2026 22:25
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Sep 19, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

mechanism: no code change; the capability ratchet named here already runs unskipped on every shard, and the line the finding points at is the live adapter measurement rather than the ratchet

  • the new capability ratchet is skipped by default (span=cf849040cdfe) — rebutted

Rebutted on the facts, and the skip class the earlier round of this span raised is
separately fixed.

The capability ratchet is not skipped. It is asserted in two files that carry zero
pytest.skip, zero skipif and zero real_adapter markers, so it runs on every shard
of every run: test/test_acp_capability_sets_leaf.py:174 pins the set to exactly
{kiro, codex}, and lines 266, 268 and 272 pin the subset relation and KAS's exclusion;
test/test_acp_codex_harness.py:990 and 1008-1011 pin codex in the set, KAS out of it,
and the proper-subset relation to ACP_BACKENDS_ACP_RUNTIME. Remove codex from the set
and both files go red in CI with no host cooperation at all.

What sits at test/test_codex_session_mcp.py:2898 is a different assertion: the LIVE
measurement of the adapter behaviour the set membership rests on. It sends
session/prompt, so it needs a codex credential, and CI holds none. That is not a
ratchet left off by oversight — it is the one contract in this area no CI job can run.
The repository's own contract lane cannot stand in for it either: its credential is
fabricated, and codex refuses session/load on a thread that never ran a real turn
("no rollout found for thread id", measured), so the restore is unassertable there
however the test is written.

That gap is now recorded rather than papered over. backends.py states which half the
lane measures and which half it does not, and test/real_adapter_gate.py names one
credentialled run of this test as part of a codex-acp bump, so the bump PR's author is
told rather than left to infer it.

The first round of this span was about silent skips, and that part was a real defect and
is fixed: the diff now adds no pytest.skip at all, the three capability skipif
decorators are pytest.fail checks in the body, and the single remaining skipif is the
spend opt-in that decides whether the test runs. -m real_adapter still collects 4, the
lane's floor.

@iamwhatever

Copy link
Copy Markdown
Contributor Author

mechanism: no code change; the rides-along is documentation only, and the body already declares it

  • the rewritten RFC passages about codex's MCP array correct staleness that predates this change (span=a9cc5572ce21) — agreed as declared, kept

Agreed on every fact, and kept deliberately.

The item is right that this is a rides-along: _codex_session_mcp_servers and the
_is_codex arm are already absent from src/ on the base, which I re-checked on
origin/main — git grep returns no hits for either. So the RFC passages described code
that had already gone, and correcting them fixes no behaviour in this change.

It stays in because of what the alternative costs. A spec that still describes symbols
nothing implements is an instruction to the next author to re-add them. Leaving it would
move this change's cost into a wrong instruction instead of removing it, and the correction
is three documentation files with no source edit behind it — src/ in this diff is
acp/harness/codex.py, agent_sdk/backends.py and subagent_manager/run.py, none of
which touch that removed array.

Harm-free is the right reading, and the declaration the item credits is in the PR body
under the re-land section, where the rides-along is named rather than folded silently into
the feature's own changes.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Sep 19, 2026
@iamwhatever
iamwhatever force-pushed the feat/acp-codex-session-sharing-reland branch from 8e33ff8 to 4e43824 Compare September 19, 2026 22:59
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in docs/system-specs/modules/, src/kiro_crew/context.py, src/kiro_crew/memory_recall.py, src/kiro_crew/mcp_core.py, src/kiro_crew/config/sections.py and the workflow allocator since this head went green (179c318748cd -> 02c4370af059, four commits: #11461, #12094, #11996, #11880); CI re-running.

No literal file overlap: none of the four commits touches any of this PR's 13 files, so green_age.py's overlap list is its same-dir and import proximity heuristic firing, not a contested file. The change itself is byte-identical across both rebases — the sorted -U0 added and removed line sets of <old>^..<old> and HEAD^..HEAD match exactly, twice.

Re-run on the new base before pushing: my own eight affected files at 576 passed / 1 skipped (the skip is the live codex test, unopted), and the nine overlapping test files main changed at 535 passed / 1 skipped. black, isort, flake8, comment-history and harness-parity green; push_guard.py --require-single-on-base SAFE. The last commit picked up, #11880, is CI-only (job migration to CodeBuild) and touches no source this diff reads.

@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: passed Eligible automated validation passed for the current revision readiness: checking Automated validation is still running labels Sep 19, 2026
@iamwhatever
iamwhatever force-pushed the feat/acp-codex-session-sharing-reland branch from 4e43824 to 968efec Compare September 19, 2026 23:35
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/decisions* and src/kiro_crew/platform_log_append.py since this head went green (02c4370af059 -> abedd2ed15d2, #11993); CI re-running.

Readiness had passed on the previous head 4e438245a7 with 91 checks, 0 failing, and all four reviewer lanes fresh and clean. This push carries the same change onto the newer base, nothing else: the sorted -U0 added and removed line sets of the old commit and the new one match exactly.

No literal file overlap again — #11993 touches none of this PR's 13 files, so green_age.py's list is its same-dir and import proximity heuristic. Re-run on the new base before pushing: my eight affected files at 576 passed / 1 skipped, and the five overlapping test files #11993 changed at 275 passed / 7 skipped. push_guard.py --require-single-on-base SAFE.

@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 added readiness: checking Automated validation is still running readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Sep 19, 2026
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.

Re-land on the current base: the test additions sit on top of the
one-SQLite-store subagent_persistence API and keep the real-adapter
contract markers, rather than carrying the file states they were
written against.
@iamwhatever
iamwhatever force-pushed the feat/acp-codex-session-sharing-reland branch from 968efec to fae998c Compare September 20, 2026 02:22
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision labels Sep 20, 2026
@iamwhatever

Copy link
Copy Markdown
Contributor Author

Rebased to resolve a real conflict: GitHub had this head at CONFLICTING. abedd2ed15d2 -> e8b94aaef7f3, 19 commits; CI re-running.

One of them is a genuine collision rather than proximity. #11942 ("compact opencode, and stop telling four backends they self-manage") edits the same three files this PR does: docs/system-specs/modules/providers.md, src/kiro_crew/agent_sdk/backends.py and test/test_acp_capability_sets_leaf.py. Two auto-merged; the third conflicted on the sharing-set pin, where main asserts frozenset({ACP_BACKEND_KIRO}) and this branch asserts frozenset({ACP_BACKEND_KIRO, ACP_BACKEND_CODEX}).

Resolved by keeping both sides' contributions, not by taking a side. This branch's comment and assert are the feature. main's trailing three-line preamble for the harness pins that follow is main's, and it is kept — dropping a comment main added is exactly the clobber that reverted #11960.

ACP_BACKENDS_COMPACT now pins FOUR members (kiro, claude, codex, opencode) because #11942 added opencode. That is main's value, byte-identical to origin/main's copy of the assert, and it supersedes the three-member figure in this PR's description — the description is corrected.

Equivalence of the kept hunks: the sorted -U0 added and removed line sets of the pre-rebase commit and the post-rebase commit are IDENTICAL, 898 lines each, comm empty in both directions. The conflict resolution changed no line this commit contributes.

#11942's own content is intact rather than merely conflict-free: ACP_BACKENDS_HARNESS_MANAGED_COMPACTION 4 occurrences, ACP_BACKENDS_CONTEXT_RECYCLE 4, opencode 1.18.30 2, compact-live.jsonl 1 — every count equal to origin/main's. The only lines this commit removes from main's backends.py and providers.md are the old prose arguing codex OUT of sharing, which is what the change replaces.

Four re-land invariants re-checked on fae998cbd9: 3 real_adapter markers and 3 require_real_adapter calls in test_codex_session_mcp.py; _run_agent_identity_path 0 occurrences in test_subagent_continuable.py; the ACP_BACKENDS_COMPACT pin equal to main's four members; -m real_adapter collects 4 and, run for real with KIROCREW_E2E_REQUIRE=1, 4 passed with no selected case skipped. The one skip in that run is test_stt_stream_cov80.py's module-level collection skip for a missing optional SDK, which no -m selection reaches.

Tests on the new base: my eight affected files 576 passed / 1 skipped, and #11942's five test files 217 passed. black, isort, flake8, comment-history and harness-parity green; push_guard.py --require-single-on-base SAFE.

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

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving at fae998c. No blocking findings. All three bots reviewed this head with no blocking findings and no override was needed.

Harness parity is clean, and clean in the way the rule actually asks for. backends.py:781 is ACP_BACKENDS_SESSION_SHARING = frozenset({ACP_BACKEND_KIRO, ACP_BACKEND_CODEX}) — positive membership by named backend. I grepped the diff for the forbidden shape (not is_claude_backend and friends) and found none in source; the only hits are docs prose and an assert KAS not in SESSION_SHARING exclusion test, which is a legitimate use. Selection stays at agent.acp_backend with agent.provider still ["acp"], so no seam moved. Model literals: none as a default or fallback; the one claude-agent-acp hit is a backend name in a comment.

The most valuable change in this PR is a fail-open bug that the title does not mention. run.py:2921 replaces a hardcoded PROVIDER_LABEL_DEFAULT with self._manager._provider_label_of(provider). Before this, a codex session cancelled inside the pre-recapture window recorded the kiro label, so _cleanup_session_files_sync took the kiro branch, found nothing to clean, and reported cleanup as succeeded. A cleanup that fails while claiming success is the worst shape for this kind of code, and the fix turns it fail-closed. The comment at the call site is also the right instinct — it routes through a table so "a harness added later is one table row rather than one more branch here", citing H13.

The resume path refuses rather than guessing, which is the question I most wanted answered. run.py:1103: if info.conversation_key and not _resumed: raise RuntimeError("resume_failed: session/load did not restore…"). So a missing, truncated or archived thread produces a clean refusal, never a silent resume into wrong context. On cross-run isolation: the session key is conversation_key or f"subagent:{info.id}" (run.py:412), unique per run, and although codex's session/load resolves from the sessionId alone, a thread that is not there refuses and drives _resumed=False. One subagent cannot land in another's thread without forging its conversation key.

The keep/continuation split at run.py:994 is coherent: those runs take the get_or_create arm that returns a real _resumed, while the sharing arm hardcodes _resumed=False — so the refusal above can never fire spuriously on a sharing run.

One finding, minor. providers.md, harness-parity.md and agent-host-contract.md were updated, but docs/system-specs/modules/subagent.md and acp-client.md were not, even though session sharing now covers codex and continuation survives teardown. Both specs describe surfaces this changes, so the next reader of either will have a stale picture. Worth a follow-up rather than a block.

Tests fail on revert where it counts: the capability-set leaf test reds if membership changes, and test_keep_marks_continuable_and_skips_sharing reds if the not info.keep gate goes. The live codex restore test is opt-in behind KIROCREW_LIVE_CODEX_PROMPT_TESTS and never runs in CI — which the repo discloses honestly in real_adapter_gate.py rather than letting it read as coverage.

I did not run the suite, and the measured restore/evict behaviour comes from that opt-in test rather than from anything I executed.

Not merging; that is Ray's call.

@iamwhatever
iamwhatever merged commit 5547284 into main Sep 20, 2026
177 of 185 checks passed
@iamwhatever
iamwhatever deleted the feat/acp-codex-session-sharing-reland branch September 20, 2026 04:51
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Sep 20, 2026
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