Files
deepseek-harness/examples/echo-agent/README.md
T
imccyu 6f77da4c8c refactor: relocate demo app bundles to packages/examples/*-demo
Move the agent-spine bundle and the stdio/ACP/JSON-RPC app packages out of
core/ and ui/ into a new packages/examples/ group, renamed with a -demo
suffix so the npm name marks them as non-product surface:

  core/agent-core   -> examples/agent-spine-demo  (dsh-agent-spine-demo)
  ui/stdio-agent    -> examples/stdio-demo        (dsh-stdio-demo)
  ui/acp-agent      -> examples/acp-demo          (dsh-acp-demo)
  ui/jsonrpc-agent  -> examples/jsonrpc-demo      (dsh-jsonrpc-demo)

Update every code/config/test reference and reference-only doc mentions, and
regenerate module-graph, config-catalog, and doc-graphs. The jsonrpc bin
(dsh-jsonrpc-agent) and single-file exe (dsh-jsonrpc-agent-pkg) keep their
names; the SDK runtime-startup surface is reconciled separately.
2026-07-15 16:46:05 +08:00

2.3 KiB

echo-agent

Runnable demo: stdin chat with a scripted mock model and an echo tool. The all-mock skeleton — "swap the backend, keep the app".

What it shows

This example is just a leaf cordis.yml: it loads the @deepseek-ai/dsh-stdio-demo app (which bundles the whole @deepseek-ai/dsh-agent-spine-demo spine, the console logger, JSONL persistence, the readline UI, and a pre-created main agent), and swaps in two example-local backends plus hmr:

  • mock-llm.ts — a mock LlmAdapter that streams scripted responses and calls the echo tool when the user types "echo ". Registered with ctx.llm.registerAdapter(['mock-echo'], …).
  • echo-tool.ts — a tool registered via ctx.tools.register(defineTool(…)) with typed execute args; echoes text back uppercased.

Swapping mock-llm for the real llm-deepseek adapter is all that separates this from coding-agent — the same app, a different backend.

Plugin files

File Role Key patterns demonstrated
src/mock-llm.ts LlmAdapter registration ctx.llm.registerAdapter(['mock-echo'], …), streaming chunks with the proper block-start/block-end protocol
src/echo-tool.ts Tool registration ctx.tools.register(defineTool(…)) with typed execute args, returning ContentBlock[]
cordis.yml Leaf wiring the two backends + hmr + one @deepseek-ai/dsh-stdio-demo entry carrying the app config

The spine, UI, persistence, and boot glue all live in @deepseek-ai/dsh-stdio-demo and the bundle it loads — this folder holds only the demo-specific mocks and the leaf wiring.

Run

pnpm run demo:echo
# or:
node --expose-internals --import tsx packages/examples/stdio-demo/src/bin.ts examples/echo-agent/cordis.yml

Type a message and press Enter. "echo " triggers a tool call round-trip (the mock model requests the echo tool, which echoes the text uppercased, and the next model step acknowledges it).

The session is persisted under .sessions/ relative to the directory you launch the demo from. pnpm run demo:echo runs from the repo root, so the logs land in <repo-root>/.sessions/cwd-<hash>/ (one .jsonl log per session). Clean up with: rm -rf .sessions