SDK wire: session/cancel and session/close #2888
Replies: 2 comments 1 reply
|
Verified against rc.7 ( 1. The gap is real and self-documented. Both READMEs name it verbatim: 2. The implementation fits the existing shapes.
3. Design points that look right:
4. One thing worth double-checking (not blocking): the 5. On the zh.md gap — that's exactly the right thing to leave to the maintainers: the translation-pairing gate is their tooling, and a community PR shouldn't risk a wrong translation. The 107/107 + lint + typecheck is the right bar. This is the second SDK-family contribution I've seen this week (the other being the SDK wire observability thread) — the wire is clearly where external hosts are pushing. When PRs re-open, this is ready to land as-is or near-as-is. If the maintainers want a review of the diff against the exact |
|
Adding a Voice Agent runtime consumer perspective: this proposal addresses a concrete integration boundary that I am currently researching. I am designing a Python-based Voice Agent runtime in which a framework such as LiveKit Agents or Pipecat owns the real-time voice data plane:
DeepSeek Harness would run as a separate cognitive/tool sidecar, accessed through the Python SDK and the stdio JSON-RPC runtime. It would own the semantic conversation, model execution, tool policy, tool event log, and potentially longer-running agent workflows. A likely deployment model is one long-lived DSH runtime per Python worker, with multiple concurrent calls mapped to different DSH A typical barge-in sequence would look like this:
Without For this reason, the proposed session-scoped shape looks appropriate to me:
I would, however, like the protocol contract to distinguish cancellation acceptance from cancellation settlement. For example, For an interactive host, the important lifecycle is closer to: The existing There is also a late-event fencing requirement. After cancellation, text deltas or tool events from the old activity may still be in transit. A host needs either:
This is particularly important for voice playback, because an old text delta must never be synthesized after the caller has started a new turn. For
That would let a voice worker release per-call resources when a call ends while preserving the option to inspect or resume the semantic session separately. My current source baseline is rc.7 ( A few questions for the maintainers:
Overall, I support the proposed |
Uh oh!
There was an error while loading. Please reload this page.
The gap
An external orchestrator driving the SDK runtime over JSON-RPC has no way to stop a turn or release one session. The READMEs name this themselves:
packages/sdk/protocol/README.md— "No cancel or session-close methods — a client abandons a turn by closing the runtime process"packages/sdk/server/README.md— "The wire has no per-session close or prompt-cancel method — SDK-created agents remain live until process shutdown"Closing the process is a blunt fallback: with many sessions on one runtime, abandoning one turn kills the others too. Any host embedding the runtime as one agent backend among several needs per-session control.
What I implemented
Two request methods, following the existing
session/promptshape:session/cancel{ sessionId }{ cancelled: boolean }— whether a live session existed and received the cancellationsession/close{ sessionId }{ closed: boolean }— whether a live session was disposedDesign notes, mostly about being conservative:
session/cancelappliesagent.cancel({ kind: 'user' })— the same cancellation the ACP bridge already uses, so behavior is consistent between the two front ends. It assigns no prompt-level outcome; the cancelled activity settles through its ownsession.eventstream, matching howsession/promptalready refuses to attribute results.false), not an error.session/closeawaits an in-flight session creation before closing, so a pending creation cannot leak past the close. It drops the record before disposing, so a concurrent prompt cannot find a closing record.session-persistence-jsonl, so callers mint a fresh id. Documented as a residual limitation rather than papered over.prompt.Scope is 353 insertions across 11 files — protocol types, server methods,
HarnessClient.cancelSession()/closeSession(),HarnessSession.cancel()/close(), tests, and README updates. The SDK suite passes at 107/107 with lint and typecheck clean.Why I'm posting rather than opening a PR
CONTRIBUTING.md says external PRs aren't accepted right now, and PRs are disabled on the repo, so this is an offer rather than a request. Branch, if it's useful: master...AlexisDevos:deepseek-harness:feat/sdk-session-cancel-close
Take it, rewrite it, or ignore it. I'm posting mainly because the limitation is one your own docs flag, and I needed it for a host integration — if the shape is wrong for where you're taking the protocol, I'd rather know that than have you carry a design you didn't choose.
Known gap on my side: the
README.zh.mdtwins are not updated, soverify-translation-pairingreports all three sdk READMEs out of sync. I didn't attempt the translation.All reactions