Skip to content

refactor(acp): move the deepseek session code off AcpClient into DeepseekAcpClient - #37641

Merged
chenmingwei23 merged 1 commit into
mainfrom
refactor/deepseek-out-of-acpclient
Nov 15, 2026
Merged

chenmingwei23 merged 1 commit into
mainfrom
refactor/deepseek-out-of-acpclient

Conversation

@chenmingwei23

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: AcpClient holds no DeepSeek Harness-only code; a deepseek session runs exactly as before from a class of its own.

AcpClient is the per-session client every non-KAS backend shares, and it carried the DeepSeek Harness session contract: the gate nonce and the READ_ONLY proof the deepseek launch records on the session, the session's MCP array, the remedy text of the completed-unasked tripwire (behind an _is_deepseek branch), and a deepseek check in the tool-event path for the provider tool-call id dsh forwards verbatim. The process adapter also asked a deepseek-only MCP seam on the session.

Why it matters

deepseek dashboard chats are next to share one ACP process, the way KAS, codex, claude and goose chats can. That needs deepseek's per-session state to be a unit the shared runtime can hold 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

  • No behaviour change for any backend, deepseek included.
  • No deepseek chat sharing yet; that lands in the two follow-up PRs.
  • The completed-unasked tripwire itself stays in client_permissions: pi and MiMo Code share it, and only its deepseek remedy moves.
  • No change to the ACP_BACKENDS_* capability sets (ACP_BACKENDS_RESUME_WITHOUT_LOAD keeps deepseek).

What changed (motivation -> approach -> change)

deepseek code was spread across the shared client -> it now lives in DeepseekAcpClient(AcpClient) (acp/client_deepseek.py), bound from one owner module (acp/client_deepseek_session.py) -> AcpClient keeps one hook per step with what every other backend already did, and the subclass fills it.

  • The class. AcpClient(acp_backend="deepseek", ...) builds a DeepseekAcpClient through the __init_subclass__(serves=...) registry, so no caller changes. Its __init__ sets _deepseek_gate_nonce and _deepseek_read_only_issue, which the shared __init__ no longer sets; every reader already reads them with getattr and a fail-closed default.
  • Hooks on AcpClient. _gate_tripwire_remedy (pi's text, which every non-deepseek tripwire already used) and _tool_call_ids_repeat_in_turn (False). The tripwire reads the first, the tool-event path the second, so kiro-cli and every other backend take the same branch as before.
  • MCP array. _deepseek_session_mcp_servers moves verbatim from client_mcp_array and fills the existing _harness_session_mcp_servers hook in place of the seam on DeepseekLaunch, so the array sent on session/new and session/resume is unchanged.
  • _is_deepseek is removed. ProcessSession no longer lists the two deepseek fields or the deepseek MCP seam; the launch types its session as DeepseekProcessSession (the ClaudeProcessSession pattern).

Backwards compatibility

Compatible: AcpClient(acp_backend="deepseek") still builds a deepseek client, and the launch, tripwire, read-only proof and MCP array run the same code in the same order.

Reader: src/kiro_crew/acp/harness/deepseek.py:DeepseekLaunch.session_mcp_servers -- removed; the array now comes from DeepseekAcpClient._harness_session_mcp_servers on the same two call sites -- test_only_the_claude_goose_and_deepseek_clients_fill_the_harness_mcp_seam
Reader: src/kiro_crew/acp/client_class.py:AcpClient._is_deepseek -- removed; its one reader was the tripwire remedy, now _gate_tripwire_remedy -- test_a_completed_call_the_gate_never_asked_about_stops_the_session

Tests

  • test_client_bindings.py: a DeepseekAcpClient inventory, each member bound from client_deepseek_session; the two new hooks join the AcpClient inventory; AcpClient(acp_backend="deepseek") builds DeepseekAcpClient.
  • test_acp_deepseek_backend_enforcement.py: the tripwire tests build the class the backend builds, and the stop test now pins the deepseek remedy (red when the subclass keeps pi's text: checked by swapping the override back).
  • test_harness_parity.py: DeepseekAcpClient fills _harness_session_mcp_servers with its own array; DeepseekLaunch asks no MCP seam.
  • test_member_mount_deepseek.py: builds the class the backend builds.
  • Run locally, serial: the files above plus test_acp_mcp_startable.py, test_acp_launch_goldens.py, test_side_readonly_deepseek.py, test_crew_oauth_bridge_harnesses.py, test_acp_deepseek_backend.py, test_acp_deepseek_backend_vault.py, test_acp_harness_contract.py: 1123 passed. black, isort, flake8 and mypy on the changed files are clean.

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 is sufficient. deepseek chat sharing, which these hooks prepare for, gets a real dsh run in the PR that routes it.

Related Issues

Part of #5033

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title
  • 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

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

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 481cdd9694febf33aedd1cccbd162e1abe7be0bb touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 481cdd9694febf33aedd1cccbd162e1abe7be0bb — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. The DeepSeek array still goes out in the same place in the session/new and session/resume arrays, and the deleted adapter seam had only one caller, client_start.py:229. Every reader of the two moved fields uses getattr with a fail-closed default.

Notes

  • The removed DeepseekLaunch.session_mcp_servers now falls back to the base adapter's []. If a future backend fills both hooks, it would send its servers twice, and nothing in this diff catches that.

[DESIGN-REVIEWED] 481cdd9

Description read

[DESCRIPTION-READ] 4d49be91c4709f28b59ffaa3f9f1a67115fc1b7701946c603d3b56ea080a3681

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 481cdd9694febf33aedd1cccbd162e1abe7be0bb — 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 does not.

First-Principles-Verdict: PASS

Nothing blocks: a refactor that moves deepseek-only code off the shared client into its own class. Every default stays where it was, and each new hook replaces one backend check.

What this change ships

Inventory (7 items) — 7 justified

Intent: let a deepseek session keep its state in its own client class, so the shared runtime can later hold that state per session. This is a FIX-free refactor (an ADDITION of structure with no behaviour change).

  1. AcpClient(acp_backend="deepseek") now builds a DeepseekAcpClient, through the existing serves= registry — justified
  2. The gate nonce and the READ_ONLY proof are now set only on deepseek clients; every reader uses getattr with a fail-closed default — justified
  3. The tripwire's deepseek remedy text comes from a class attribute instead of an _is_deepseek branch — justified
  4. The tool-event "repeated tool-call id" check reads a class flag instead of comparing the backend to deepseek — justified
  5. The deepseek MCP array now fills the harness MCP hook instead of the DeepseekLaunch.session_mcp_servers adapter hook — justified
  6. _is_deepseek is removed, and ProcessSession loses the deepseek fields and its MCP method — justified
  7. New DeepseekProcessSession protocol types the launch's session — justified

[FIRST-PRINCIPLES-REVIEWED] 481cdd9

Description read

[DESCRIPTION-READ] 3f23b5014fea8eb7b509519c6bd33aa06c43fab77537652ad7a9b57746e08414

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 481cdd9

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 481cdd9694febf33aedd1cccbd162e1abe7be0bb false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 481cdd9694febf33aedd1cccbd162e1abe7be0bb and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 481cdd9

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 481cdd9694febf33aedd1cccbd162e1abe7be0bb false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 15, 2026
…seekAcpClient

AcpClient carried the DeepSeek Harness session contract: the gate nonce and
the READ_ONLY proof its launch records, its MCP array, the tripwire remedy
behind an `_is_deepseek` branch, and a deepseek check in the tool-event path
for the provider tool-call id dsh forwards verbatim.

DeepseekAcpClient (acp/client_deepseek.py) now holds all of it, bound from
the new owner module client_deepseek_session. AcpClient keeps one hook per
step (`_harness_session_mcp_servers`, `_gate_tripwire_remedy`,
`_tool_call_ids_repeat_in_turn`) with the behaviour every other backend
already had, and the subclass fills it. The process adapter no longer asks a
deepseek seam, and the launch types its session as DeepseekProcessSession.
AcpClient(acp_backend="deepseek") builds DeepseekAcpClient, so no caller
changes.

Behaviour is unchanged. The tests follow the members to the new class; the
tripwire test now also pins the deepseek remedy.
@chenmingwei23
chenmingwei23 force-pushed the refactor/deepseek-out-of-acpclient branch from 9bd08a8 to 481cdd9 Compare November 15, 2026 15:58
@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 15, 2026
@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: the decider estimates an 8% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes.

A refactor that moves the DeepSeek Harness code into DeepseekAcpClient, following the existing goose, claude and opencode subclass pattern, with no behaviour change found. The registry in AcpClient.new picks the subclass for acp_backend="deepseek", and the facade imports the module, so it is registered. The MCP array is unchanged: the harness and adapter hooks are spliced next to each other in client_start on both session/new and resume. The gate nonce and READ_ONLY proof are set only on the subclass, and every reader uses getattr with a fail-closed default. The tripwire remedy and the tool-call-id flag are class attributes, and only the deepseek class overrides them. Existing deepseek tool-call-id tests build the client through AcpClient(acp_backend=deepseek), so they go through the subclass. The tripwire test now checks the deepseek remedy text, and the parity tests would catch DeepseekLaunch overriding the MCP method again.

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 481cdd9694 · 278 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@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 Nov 15, 2026
@chenmingwei23
chenmingwei23 enabled auto-merge (squash) November 15, 2026 17:06

@bolichen97 bolichen97 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. I read the whole diff on this head: the new client_deepseek.py and client_deepseek_session.py, the removals in client_class.py, client_mcp_array.py, client_permissions.py, client_tool_events.py, harness/base.py and harness/deepseek.py, and every changed test. I did not run tests locally. All 97 checks are green.

This is a pure move with the same shape as the goose split. Behavior is unchanged, and I checked these points on main:

  • MCP array order. On main a deepseek session got its servers from DeepseekLaunch.session_mcp_servers through _adapter_session_mcp_servers, which sits after _harness_session_mcp_servers and before the pooled servers in client_start.py. Now the same list comes from DeepseekAcpClient._harness_session_mcp_servers and the adapter hook is empty for deepseek, so the array is the same, in the same order, for session/new and session/load.
  • Fields that moved off the base class. _deepseek_gate_nonce and _deepseek_read_only_issue are no longer set on AcpClient. Every read on main in client_permissions.py (lines 1043, 1402 and 1488) uses getattr with the old default, and _dispatch_parts/permission_requests.py only uses a local variable of that name, so a non deepseek client still reads the empty defaults.
  • Class selection. AcpClient.__new__ picks the class from acp_backend through _client_class_by_backend, so every deepseek client built the normal way is a DeepseekAcpClient. The tests that build a bare client now pass acp_backend, and test_the_backend_picks_the_client_class pins the choice.
  • Tripwire remedy. The base class default is the pi text and the deepseek class overrides it, which gives the same two texts as the old if self._is_deepseek branch. The new assertion checks the deepseek text and that the pi text is absent.
  • Repeated tool call ids. The old backend == deepseek test is now a class flag that is true only on DeepseekAcpClient, false elsewhere.
  • Removed _is_deepseek. I searched main for other users. The matches in hooks.py, gate_tiers.py and tool_identity.py are a different helper (_is_deepseek_read_only_builtin), and the two strings in test_acp_launch_goldens.py are source snippets, not calls.

There is no new refusal, no security change and no regex in product code.

Not checked: I did not read the surrounding code of harness/deepseek.py beyond the changed hunks, and mergeable was still UNKNOWN when I ran the gate. The author already holds auto merge, so I left it as it is.

@chenmingwei23
chenmingwei23 merged commit eedecfd into main Nov 15, 2026
99 checks passed
@chenmingwei23
chenmingwei23 deleted the refactor/deepseek-out-of-acpclient branch November 15, 2026 17:14
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 15, 2026
@LuisBrel LuisBrel mentioned this pull request Nov 16, 2026
5 tasks done
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.

4 participants