Repository navigation
refactor(acp): move the opencode session code off AcpClient into OpencodeAcpClient - #37602
Conversation
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: this follows the goose split pattern, the order of the MCP array on [DESIGN-REVIEWED] 7b80a45 Description read[DESCRIPTION-READ] f31296025c7a2f90ec5eeb2d26c7ad1056b67e9fb4ce55e8465bf87a0e925318 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks: every member moves verbatim behind hooks that already have peers, and the one new refusal guards a permission check that has a named cause. Notes
What this change shipsInventory (6 items) — 5 justifiedIntent: let opencode's per-session checks run as their own unit, so a later PR can put several opencode chats on one shared ACP process. This is an ADDITION (a refactor with no behaviour change).
[FIRST-PRINCIPLES-REVIEWED] 7b80a45 Description read[DESCRIPTION-READ] e1bcbf8df4439bf5e0182bfe42efdcb05acd68db9cf4f4da22676e77578354df That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
Code change approver recommendation: A person should decideWhy: the decider estimates a 10% chance that this change introduces a defect, within the 12% limit for approving on its own, but it changes 493 lines, more than the 400 it may approve on its own. This is a behaviour-preserving refactor and can merge. Opencode's shell-permission hold, hosted fall-back refusal and MCP server list now live on An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
647bc5a to
5140472
Compare
Sensitive Change ReviewSensitive files changed:
|
Sensitive change review
|
…codeAcpClient AcpClient carried opencode's session contract: holding a shell permission back until the update carrying its command reaches the security cache, refusing a session left on opencode's hosted fall-back model, and building opencode's MCP array, behind `_is_opencode` and backend checks in the shared turn, model-selection and start code and a seam on the process adapter. OpencodeAcpClient (acp/client_opencode.py) now holds all of it, bound from the new owner module client_opencode_session. AcpClient keeps one hook per step (`_defers_shell_permission` + `_defer_shell_permission`, `_refuse_harness_default_model`, and the existing `_harness_session_mcp_servers`) with the behaviour every other backend already had, and the subclass fills it. AcpClient(acp_backend="opencode") builds OpencodeAcpClient, so no caller changes; a class that defers no shell permission refuses the opencode backend. Behaviour is unchanged. The tests follow the members to the new class.
5140472 to
7b80a45
Compare
Sensitive change review
|
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved. On this head the review checked that the three moved functions match their originals on main body for body, apart from docstrings. _refuse_opencode_hosted_fallback still applies both redactions. The prompt loop now gates the shell-permission deferral on a class flag that only OpencodeAcpClient sets, which is the same condition as the old backend name test. The opencode MCP entries moved from the adapter slot to the harness slot of the same array, so the wire array and its order do not change. The existing opencode tests build their client through AcpClient(acp_backend="opencode"), so they now run through the new class. The new __new__ refusal has a test that fails without it.
Done well: this follows the merged goose split (#37535) closely. A subclass that does not defer shell permissions now gets an error before any process starts, where before it would have lost the reorder without any sign.
Optional:
docs/system-specs/modules/agent-host-contract.mdline 462 still says opencode's MCP array is "spliced by its own_is_opencodearm". You could reword it to match the goose cell: "spliced by its client class (OpencodeAcpClient._harness_session_mcp_servers,acp/client_opencode.py)".- In
test/test_acp_opencode_backend.pyaround line 829, the assertion message still mentions the MCP-array splice exemption, which no longer exists. Something like "an opencode identity test sits on the shared init path (harness-parity H13)" would match the stricter check. - #37629 conflicts with this PR in
client_model_selection.py. Whichever PR merges second should build its MiMo refusal on the new_refuse_harness_default_modelhook and not on_is_opencode.
…odel unsigned MiMo Code 0.1.17 is built on opencode and has the gap #37480 closed there. With no sign-in, no key and no model in its config, session/new puts the session on xiaomi/mimo-v2.6-pro-ultraspeed and the first prompt goes to Xiaomi's API with no Authorization header. Crew did not stop it: the start-time refusal ran for opencode only. Following #37602's split, a new MimocodeAcpClient (acp/client_mimocode.py, bound from client_mimocode_session) fills the _refuse_harness_default_model hook; AcpClient(acp_backend="mimocode") now builds it. It refuses when the session's model and every advertised model are xiaomi/ ones, the harness config names no model, and no Xiaomi credential is present. A signed-in host advertises the very same models, so MiMo Code's read-back records that last fact: the sign-in file the auth declaration names (under XDG_DATA_HOME or HOME), XIAOMI_API_KEY or MIMOCODE_AUTH_CONTENT in the child's environment, or a provider.xiaomi.options.apiKey in the resolved config. The file is checked for existence only and never opened; the key is checked for presence and never logged. A signed-in host, a model named in mimocode.json, a Crew pin, or a provider of the operator's own is left alone.
…odel unsigned MiMo Code 0.1.17 is built on opencode and has the gap #37480 closed there. With no sign-in, no key and no model in its config, session/new puts the session on xiaomi/mimo-v2.6-pro-ultraspeed and the first prompt goes to Xiaomi's API with no Authorization header. Crew did not stop it: the start-time refusal ran for opencode only. Following #37602's split, a new MimocodeAcpClient (acp/client_mimocode.py, bound from client_mimocode_session) fills the _refuse_harness_default_model hook; AcpClient(acp_backend="mimocode") now builds it. It refuses when the session's model and every advertised model are xiaomi/ ones, the harness config names no model, and no Xiaomi credential is present. A signed-in host advertises the very same models, so MiMo Code's read-back records that last fact: the sign-in file the auth declaration names (under XDG_DATA_HOME or HOME), XIAOMI_API_KEY or MIMOCODE_AUTH_CONTENT in the child's environment, or a provider.xiaomi.options.apiKey in the resolved config. The file is checked for existence only and never opened; the key is checked for presence and never logged. A signed-in host, a model named in mimocode.json, a Crew pin, or a provider of the operator's own is left alone.
…odel unsigned (#37629) MiMo Code 0.1.17 is built on opencode and has the gap #37480 closed there. With no sign-in, no key and no model in its config, session/new puts the session on xiaomi/mimo-v2.6-pro-ultraspeed and the first prompt goes to Xiaomi's API with no Authorization header. Crew did not stop it: the start-time refusal ran for opencode only. Following #37602's split, a new MimocodeAcpClient (acp/client_mimocode.py, bound from client_mimocode_session) fills the _refuse_harness_default_model hook; AcpClient(acp_backend="mimocode") now builds it. It refuses when the session's model and every advertised model are xiaomi/ ones, the harness config names no model, and no Xiaomi credential is present. A signed-in host advertises the very same models, so MiMo Code's read-back records that last fact: the sign-in file the auth declaration names (under XDG_DATA_HOME or HOME), XIAOMI_API_KEY or MIMOCODE_AUTH_CONTENT in the child's environment, or a provider.xiaomi.options.apiKey in the resolved config. The file is checked for existence only and never opened; the key is checked for presence and never logged. A signed-in host, a model named in mimocode.json, a Crew pin, or a provider of the operator's own is left alone. Co-authored-by: Joe Guo <zejiangg@amazon.com>
…odel unsigned (#37629) MiMo Code 0.1.17 is built on opencode and has the gap #37480 closed there. With no sign-in, no key and no model in its config, session/new puts the session on xiaomi/mimo-v2.6-pro-ultraspeed and the first prompt goes to Xiaomi's API with no Authorization header. Crew did not stop it: the start-time refusal ran for opencode only. Following #37602's split, a new MimocodeAcpClient (acp/client_mimocode.py, bound from client_mimocode_session) fills the _refuse_harness_default_model hook; AcpClient(acp_backend="mimocode") now builds it. It refuses when the session's model and every advertised model are xiaomi/ ones, the harness config names no model, and no Xiaomi credential is present. A signed-in host advertises the very same models, so MiMo Code's read-back records that last fact: the sign-in file the auth declaration names (under XDG_DATA_HOME or HOME), XIAOMI_API_KEY or MIMOCODE_AUTH_CONTENT in the child's environment, or a provider.xiaomi.options.apiKey in the resolved config. The file is checked for existence only and never opened; the key is checked for presence and never logged. A signed-in host, a model named in mimocode.json, a Crew pin, or a provider of the operator's own is left alone. Co-authored-by: Joe Guo <zejiangg@amazon.com> (cherry picked from commit c7c9357)
…odel unsigned (#37629) MiMo Code 0.1.17 is built on opencode and has the gap #37480 closed there. With no sign-in, no key and no model in its config, session/new puts the session on xiaomi/mimo-v2.6-pro-ultraspeed and the first prompt goes to Xiaomi's API with no Authorization header. Crew did not stop it: the start-time refusal ran for opencode only. Following #37602's split, a new MimocodeAcpClient (acp/client_mimocode.py, bound from client_mimocode_session) fills the _refuse_harness_default_model hook; AcpClient(acp_backend="mimocode") now builds it. It refuses when the session's model and every advertised model are xiaomi/ ones, the harness config names no model, and no Xiaomi credential is present. A signed-in host advertises the very same models, so MiMo Code's read-back records that last fact: the sign-in file the auth declaration names (under XDG_DATA_HOME or HOME), XIAOMI_API_KEY or MIMOCODE_AUTH_CONTENT in the child's environment, or a provider.xiaomi.options.apiKey in the resolved config. The file is checked for existence only and never opened; the key is checked for presence and never logged. A signed-in host, a model named in mimocode.json, a Crew pin, or a provider of the operator's own is left alone. Co-authored-by: Joe Guo <zejiangg@amazon.com> (cherry picked from commit c7c9357)
…odel unsigned (#37629) MiMo Code 0.1.17 is built on opencode and has the gap #37480 closed there. With no sign-in, no key and no model in its config, session/new puts the session on xiaomi/mimo-v2.6-pro-ultraspeed and the first prompt goes to Xiaomi's API with no Authorization header. Crew did not stop it: the start-time refusal ran for opencode only. Following #37602's split, a new MimocodeAcpClient (acp/client_mimocode.py, bound from client_mimocode_session) fills the _refuse_harness_default_model hook; AcpClient(acp_backend="mimocode") now builds it. It refuses when the session's model and every advertised model are xiaomi/ ones, the harness config names no model, and no Xiaomi credential is present. A signed-in host advertises the very same models, so MiMo Code's read-back records that last fact: the sign-in file the auth declaration names (under XDG_DATA_HOME or HOME), XIAOMI_API_KEY or MIMOCODE_AUTH_CONTENT in the child's environment, or a provider.xiaomi.options.apiKey in the resolved config. The file is checked for existence only and never opened; the key is checked for presence and never logged. A signed-in host, a model named in mimocode.json, a Crew pin, or a provider of the operator's own is left alone. Co-authored-by: Joe Guo <zejiangg@amazon.com> (cherry picked from commit c7c9357)
…odel unsigned (#37629) MiMo Code 0.1.17 is built on opencode and has the gap #37480 closed there. With no sign-in, no key and no model in its config, session/new puts the session on xiaomi/mimo-v2.6-pro-ultraspeed and the first prompt goes to Xiaomi's API with no Authorization header. Crew did not stop it: the start-time refusal ran for opencode only. Following #37602's split, a new MimocodeAcpClient (acp/client_mimocode.py, bound from client_mimocode_session) fills the _refuse_harness_default_model hook; AcpClient(acp_backend="mimocode") now builds it. It refuses when the session's model and every advertised model are xiaomi/ ones, the harness config names no model, and no Xiaomi credential is present. A signed-in host advertises the very same models, so MiMo Code's read-back records that last fact: the sign-in file the auth declaration names (under XDG_DATA_HOME or HOME), XIAOMI_API_KEY or MIMOCODE_AUTH_CONTENT in the child's environment, or a provider.xiaomi.options.apiKey in the resolved config. The file is checked for existence only and never opened; the key is checked for presence and never logged. A signed-in host, a model named in mimocode.json, a Crew pin, or a provider of the operator's own is left alone. Co-authored-by: Joe Guo <zejiangg@amazon.com> (cherry picked from commit c7c9357)
Problem / Motivation
Goal:
AcpClientholds no opencode-only code; an opencode session runs exactly as before from a class of its own.AcpClientis the per-session client every non-KAS backend shares, and it carried opencode's session contract: holding a shell permission back until thetool_call_updatethat carries its command has filled the security cache, refusing a session left on opencode's hosted fall-back model before its first prompt, and building opencode's MCP array. Those sat behind_is_opencodeandself.backend == ACP_BACKEND_OPENCODEbranches in the shared turn, model-selection and start code, and behind a seam onOpencodeLaunch.Why it matters
opencode dashboard chats are next to share one ACP process under the runtime sharing preview, the way KAS, codex, claude and goose chats can. That needs opencode's per-session checks to be a unit the shared runtime can run per session. This is the first of three PRs, split the way goose was (#37535, #37562, #37567). Users see no change from this PR.
Not a goal
OpencodeLaunch(acp/harness/opencode.py): they run once per process, not per session.AcpClient.What changed (motivation -> approach -> change)
opencode code was spread across the shared client -> it now lives in
OpencodeAcpClient(AcpClient)(acp/client_opencode.py), bound from one owner module (acp/client_opencode_session.py) ->AcpClientkeeps one hook per step with what every other backend already did, and the subclass fills it.AcpClient(acp_backend="opencode", ...)builds anOpencodeAcpClientthrough the__init_subclass__(serves=...)registry, so no caller changes. A class that defers no shell permission is refused the opencode backend before any process exists (_SHELL_PERMISSION_DEFERRAL_BACKENDS), so an edition subclass cannot start opencode with a permission judged before its command is cached.AcpClient._defers_shell_permission(False) with_defer_shell_permission(returns False): the turn loop reads the flag before the await, so every other backend makes no call._refuse_harness_default_model(no-op) on the non-kiro branch of_ensure_served_defaultand after a refused model pin; kiro-cli takes the other branch and never reaches it. The MCP array uses the existing_harness_session_mcp_servershook in place of the seam onOpencodeLaunch, so the array sent onsession/newandsession/loadis unchanged._defer_opencode_shell_permission(fromclient_turn; it is now the_defer_shell_permissionhook itself, so the frame it reads is read under the prompt loop's claim on stdout),_refuse_opencode_hosted_fallback(fromclient_model_selection),_opencode_session_mcp_servers(fromclient_mcp_array)._is_opencodeis removed.ProcessSessionno longer lists_opencode_session_mcp_servers. Doc lines inacp-client.md,agent-host-contract.mdand two code comments name the new home.Backwards compatibility
Compatible:
AcpClient(acp_backend="opencode")still builds an opencode client, and the turn, model refusal and session start run the same code in the same order.Reader: src/kiro_crew/acp/harness/opencode.py:OpencodeLaunch.session_mcp_servers -- removed; the array now comes from
OpencodeAcpClient._harness_session_mcp_serverson the same two call sites -- test_only_the_claude_goose_and_opencode_clients_fill_the_harness_mcp_seamReader: src/kiro_crew/acp/client_class.py:AcpClient._is_opencode -- removed; its readers were two model-selection branches and the MCP binding, now hooks -- test_a_resumed_session_is_not_gated_on_a_kiro_transcript
Reader: src/kiro_crew/acp/client_turn.py:_defer_opencode_shell_permission -- moved to client_opencode_session as
OpencodeAcpClient._defer_shell_permission, called only from_prompt_loop-- test_every_read_message_caller_claims_stdout, test_mimocode_permission_waits_for_matching_command_refinementTests
test_client_bindings.py: anOpencodeAcpClientinventory, each member bound fromclient_opencode_session; the new hooks join theAcpClientinventory;test_the_backend_picks_the_client_classnow checks opencode buildsOpencodeAcpClientand that a subclass without the deferral is refused opencode (red if the refusal is removed).test_harness_parity.py:OpencodeAcpClientfills_harness_session_mcp_serverswith its own array;OpencodeLaunchasks no MCP seam.test_acp_opencode_backend.py,test_acp_mimocode_turn.py: follow the members.test_acp_opencode_hosted_fallback.py,test_acp_opencode_effort.py,test_opencode_session_mcp.py,test_acp_mcp_startable.py,test_acp_refactor_facade.py,test_acp_bindings.py,test_acp_client_prompt_turn.py,test_acp_session_mcp.py,test_member_dispatch_mount.py,test_acp_goose_backend.py,test_acp_harness_contract.py,test_campaign_facades_base_public_names.py,test_acp_client_tool_hooks.py, all pass. mypy oversrc/kiro_crew/is clean; flake8, black and isort are clean on the changed files.Proof: not provable -- other: refactor with no behaviour change; tests follow the moved members
Manual verification
N/A -- no behaviour change; unit coverage of the moved members and the new refusal is sufficient. opencode chat sharing, which these hooks prepare for, gets a real opencode run in the PR that routes it.
Screenshots / video
N/A -- no UI change.
Related Issues
Part of #5033
Checklist