deepseek-harness/examples/acp-agent
Yichen Jiang 7e95a00c8a fix(llm): align replay state with assembled content and degrade unusable state
A max-tokens response that included a tool call persisted assembler-transformed
content next to replay metadata projected from the untransformed native message,
so the next request died in history reconstruction with INVALID_REPLAY_STATE and
the session stayed permanently stuck.

Write side: the finish chunk's replayState becomes a typed ReplayEnvelope —
opaque response-level metadata plus optional per-block entries aligned with the
emitted block sequence. BlockAssembler computes one keep/drop decision for
blocks and entries together, so stored metadata always describes stored content
and retained blocks keep their signatures. pi-ai splits its state into a
version-2 response half and per-block signature entries.

Read side: durable content is authoritative. toPiAssistant degrades any
unusable state — foreign kind, other versions (including the flat v1 form
already on disk), malformed metadata, or content/block mismatches — to the
existing provider-neutral conversion with an onReplayDegrade diagnostic instead
of failing the request, which un-bricks sessions poisoned before this change.

Covered by assembler and replay unit tests, an agent-loop continuation
regression, keyless real-composition continuation tests (native pruned-envelope
replay and legacy flat-state degrade), and the authored keyless snapshot
scenario max-tokens-continue through the assembled ACP app.
2026-08-15 16:07:30 +08:00
..
tests fix(llm): align replay state with assembled content and degrade unusable state 2026-08-15 16:07:30 +08:00
advanced.cordis.snapshot.yml • feat(self-modification): add dynamic Cordis plugin runtime and UI 2026-08-13 01:29:36 +08:00
advanced.cordis.yml • feat(self-modification): add dynamic Cordis plugin runtime and UI 2026-08-13 01:29:36 +08:00
agent-instructions.cordis.snapshot.yml refactor: apply repository naming contract 2026-08-13 00:54:38 +08:00
agent-instructions.cordis.yml refactor: apply repository naming contract 2026-08-13 00:54:38 +08:00
background-job-admission.cordis.snapshot.yml refactor: apply repository naming contract 2026-08-13 00:54:38 +08:00
background-job-admission.cordis.yml refactor: apply repository naming contract 2026-08-13 00:54:38 +08:00
both-mode.cordis.snapshot.yml refactor: apply repository naming contract 2026-08-13 00:54:38 +08:00
both-mode.cordis.yml refactor: apply repository naming contract 2026-08-13 00:54:38 +08:00
child-question.cordis.snapshot.yml refactor: apply repository naming contract 2026-08-13 00:54:38 +08:00
child-question.cordis.yml refactor: apply repository naming contract 2026-08-13 00:54:38 +08:00
code-mode-workspace-context.cordis.snapshot.yml refactor: apply repository naming contract 2026-08-13 00:54:38 +08:00
code-mode-workspace-context.cordis.yml refactor: apply repository naming contract 2026-08-13 00:54:38 +08:00
code-mode.cordis.snapshot.yml refactor: apply repository naming contract 2026-08-13 00:54:38 +08:00
code-mode.cordis.yml refactor: apply repository naming contract 2026-08-13 00:54:38 +08:00
composition.md refactor: apply repository naming contract 2026-08-13 00:54:38 +08:00
cordis-tools.cordis.yml • feat(self-modification): add dynamic Cordis plugin runtime and UI 2026-08-13 01:29:36 +08:00
cordis.snapshot.yml build(vendor): rescope the vendored Cordis packages into @deepseek-ai 2026-08-10 22:04:13 +08:00
cordis.yml Merge commit '5ae8c6487ad9556b8793b890a4fe5ece24c55805' into codex/product-subagent-one-shot-background 2026-08-13 15:50:23 +08:00
depth-two.cordis.snapshot.yml build(vendor): rescope the vendored Cordis packages into @deepseek-ai 2026-08-10 22:04:13 +08:00
depth-two.cordis.yml build(vendor): rescope the vendored Cordis packages into @deepseek-ai 2026-08-10 22:04:13 +08:00
fs.cordis.snapshot.yml build(vendor): rescope the vendored Cordis packages into @deepseek-ai 2026-08-10 22:04:13 +08:00
fs.cordis.yml build(vendor): rescope the vendored Cordis packages into @deepseek-ai 2026-08-10 22:04:13 +08:00
image-text-route.cordis.snapshot.yml fix(examples): follow Cordis package rescope 2026-08-11 10:30:04 +08:00
image-text-route.cordis.yml fix(examples): follow Cordis package rescope 2026-08-11 10:30:04 +08:00
image.cordis.snapshot.yml fix(examples): follow Cordis package rescope 2026-08-11 10:30:04 +08:00
image.cordis.yml fix(examples): follow Cordis package rescope 2026-08-11 10:30:04 +08:00
package.json refactor(acp): reduce bridge to automation protocol 2026-07-24 01:40:25 +08:00
partial-landlock.cordis.snapshot.yml build(vendor): rescope the vendored Cordis packages into @deepseek-ai 2026-08-10 22:04:13 +08:00
partial-landlock.cordis.yml build(vendor): rescope the vendored Cordis packages into @deepseek-ai 2026-08-10 22:04:13 +08:00
product-subagent-both.cordis.snapshot.yml feat(agent-presets): enable background Codex and Claude Code subagent tasks 2026-08-12 17:07:34 +08:00
product-subagent-both.cordis.yml feat(agent-presets): enable background Codex and Claude Code subagent tasks 2026-08-12 17:07:34 +08:00
product-subagent-codex.cordis.snapshot.yml feat(agent-presets): enable background Codex and Claude Code subagent tasks 2026-08-12 17:07:34 +08:00
product-subagent-codex.cordis.yml feat(agent-presets): enable background Codex and Claude Code subagent tasks 2026-08-12 17:07:34 +08:00
pty-snapshot-backend.mjs refactor: apply repository naming contract 2026-08-13 00:54:38 +08:00
pty.cordis.snapshot.yml refactor: apply repository naming contract 2026-08-13 00:54:38 +08:00
pty.cordis.yml refactor: apply repository naming contract 2026-08-13 00:54:38 +08:00
README.i18n.yaml docs(i18n): standardize contract terminology 2026-08-09 11:33:14 +08:00
README.md docs: apply hierarchy across the corpus 2026-08-05 16:13:28 +08:00
README.zh.md docs(i18n): standardize contract terminology 2026-08-09 11:33:14 +08:00
retry.cordis.snapshot.yml build(vendor): rescope the vendored Cordis packages into @deepseek-ai 2026-08-10 22:04:13 +08:00
retry.cordis.yml build(vendor): rescope the vendored Cordis packages into @deepseek-ai 2026-08-10 22:04:13 +08:00
session-query.cordis.snapshot.yml refactor: apply repository naming contract 2026-08-13 00:54:38 +08:00
session-query.cordis.yml refactor: apply repository naming contract 2026-08-13 00:54:38 +08:00
session-sandbox-root.cordis.snapshot.yml build(vendor): rescope the vendored Cordis packages into @deepseek-ai 2026-08-10 22:04:13 +08:00
session-sandbox-root.cordis.yml build(vendor): rescope the vendored Cordis packages into @deepseek-ai 2026-08-10 22:04:13 +08:00
session-title.cordis.snapshot.yml refactor: apply repository naming contract 2026-08-13 00:54:38 +08:00
session-title.cordis.yml refactor: apply repository naming contract 2026-08-13 00:54:38 +08:00
subagent-continuable-inheritance.cordis.snapshot.yml Merge remote-tracking branch 'origin/master' into fix/continuable-subagent-policy-inheritance 2026-08-10 22:24:56 +08:00
subagent-continuable-inheritance.cordis.yml Merge remote-tracking branch 'origin/master' into fix/continuable-subagent-policy-inheritance 2026-08-10 22:24:56 +08:00
subagent-durability-failure.cordis.snapshot.yml build(vendor): rescope the vendored Cordis packages into @deepseek-ai 2026-08-10 22:04:13 +08:00
subagent-durability-failure.cordis.yml build(vendor): rescope the vendored Cordis packages into @deepseek-ai 2026-08-10 22:04:13 +08:00
subagent-report-quiet.cordis.snapshot.yml feat(subagent): deliver continuable child settlement to parents 2026-08-11 12:31:49 +08:00
subagent-report-quiet.cordis.yml feat(subagent): deliver continuable child settlement to parents 2026-08-11 12:31:49 +08:00
web-fetch-fixture-server.mjs refactor: apply repository naming contract 2026-08-13 00:54:38 +08:00
web.cordis.snapshot.yml refactor: apply repository naming contract 2026-08-13 00:54:38 +08:00
web.cordis.yml refactor: apply repository naming contract 2026-08-13 00:54:38 +08:00

acp-agent example

English | 中文

Automation-oriented Agent Client Protocol server over JSON-RPC stdio. It is intended for parent agents, subagent providers, and other programmatic clients, not as the product UI.

pnpm run demo:acp             # needs DEEPSEEK_API_KEY (repo-root .env or env)
pnpm run demo:code-mode       # same protocol with the Code Mode tool transport

The leaf loads the ACP app, DeepSeek adapter, sandboxed bash and filesystem stacks, one-shot approval policy, compaction, subagents, workflows, hooks, a derived session-query index, and repeat guard. The app creates one fresh agent per session/new, persists sessions to JSONL, and keeps stdout protocol-pure. Optional overlays add session queries, filesystem spill storage, Code Mode, or web fetching.

Protocol channel

Stdout carries only newline-delimited ACP JSON-RPC. @deepseek-ai/dsh-acp-demo installs no stdout logger; leaf additions must use stderr for diagnostics.

The automation contract — supported methods, baseline prompt content, committed-text output, and the intentionally absent UI surfaces — lives in @deepseek-ai/dsh-acp.

Session workspaces and permissions

Each session/new supplies an absolute cwd. Sandboxed bash and filesystem mutations resolve workspace-write against that session cwd, so concurrent sessions can use separate project roots; platform temporary roots remain shared writable scratch space (sandbox contract). DSH_PERMISSION_MODE selects workspace-write or danger-full-access for the deployment.

Under workspace-write, a model retry requesting wider sandbox access triggers session/request_permission with allow_once and reject_once. The client decides programmatically; dismissal or an unavailable answer fails closed. The selected outcome applies only to that retry and is recorded through the normal tool-result/audit path. The server never exposes a permission picker or persists client policy.