Add a Web snapshot that restores a cold ordinary Session in another directory through the Session controller, keeps the second delivery live, and rejects an archived target. Keep subagent exports unchanged by building the agent-message attribution in the tool. Rewrite the tool, user, and group documentation for the Web-only row, move the disposed-input upgrade guide to v0.2.2-rc.2, drop the removed service pages and guide, and regenerate the catalogs.
description, kind
| description | kind |
|---|---|
| Enable session_send_message in a Web profile so an Agent can message another ordinary Session and receive an acceptance receipt without waiting for a reply. | package-reference |
@deepseek-ai/dsh-tool-session-control
English | 中文
Summary
Let an Agent in a Web profile send a message to another ordinary Session, including one in a different Workspace or directory, and continue working once the recipient accepts it. A running recipient reads the message at its next input boundary; an idle recipient starts a turn, and an inactive recipient resumes first. The recipient sees the calling Session as the sender. The tool is off by default, exists only in Web compositions, and never waits for a reply; subagent targets use send_message.
Table of Contents
- Use this package
- Understand the implementation
- Further Exploration
- Model Experience
- Known Limitations and Deferred Work
- Dev Note
Use this package
Enable the disabled tool-session-control row of the @deepseek-ai/dsh-web-app bundle with a profile patch; the user guide shows the patch and how to inspect the composed row.
When to choose it
Enable it when Agents in a Web profile must hand instructions or findings to independent Sessions. The tool applies no Workspace or directory restriction: any Agent that sees it can address any ordinary Session that the Session controller resolves. Leave the row disabled when Agents must not start work in other Sessions. Members of one subagent tree message each other with send_message from subagent control instead.
Minimal configuration
- id: tool-session-control
disabled: false
The package declares no Config fields. It injects ctx.tools, ctx.sessionController from @deepseek-ai/dsh-api-session-controller, and ctx.workspaceRegistry from @deepseek-ai/dsh-workspace; the dsh-web-app bundle mounts both Host services, and a composition without them registers no tool.
Delivery and failures
Call session_send_message({ session_id: "target-id", message: "Please review the result." }) to obtain { "message_id": "accepted-message-id" }. The receipt confirms that the target inbox accepted the message as steering input; it does not mean that the recipient ran or replied. The tool resolves the target with ctx.sessionController.resolveAgent(): a live Agent is reused, concurrent callers share one cold restoration, and the Session controller keeps a restored Agent resident like a Session opened in the GUI.
| Condition | Result |
|---|---|
| No calling Agent | ToolContextUnavailableError (TOOL_CONTEXT_UNAVAILABLE) |
| Whitespace-only message | ToolArgsError (INVALID_ARGS), before activation |
| Target is the caller's own Session | SESSION_MESSAGE_SELF |
| Target is archived before or after activation | SESSION_MESSAGE_ARCHIVED; the target stays archived |
| Subagent routing owns the target | SESSION_MESSAGE_SUBAGENT_OWNED, directing the caller to send_message |
| Target disposal began before acceptance | SESSION_MESSAGE_INPUT_CLOSED; nothing was accepted |
| Other Session controller failure, including an unknown Session or one without a working directory | The controller's RemoteError code, such as session/not-found or session/writer-held |
SESSION_MESSAGE_* failures are SessionMessageError instances raised before the target inbox accepted the message. Cancellation before acceptance fails the call and stops waiting immediately; a restoration already in progress continues under the Session controller, and the tool delivers nothing after cancellation. Cancellation after acceptance keeps the successful receipt. The tool never retries automatically.
Understand the implementation
Implementation internals — click to expand
The tool takes the sender from the runtime's calling Agent, so the model cannot choose a sender identity. It checks the Workspace registry's archive list, waits for the Session controller's activation while racing the caller's signal, then rechecks cancellation and the archive list. It builds the message with the agent-message source that @deepseek-ai/dsh-subagent declares, records the caller's senderSessionId, uses the same Agent <sender> sent a message: prefix as send_message with the caller's Session id, and calls steer() on the target. AgentInputClosedError from a disposing target becomes SESSION_MESSAGE_INPUT_CLOSED; other inbox failures propagate unchanged. The definition sets preserveSuccessOnCancellation, so the tool pipeline keeps an accepted receipt when cancellation arrives later. The Host presenter shows the target id and message text; the Web tool card derives the accepted state and message ID from the recorded result.
Source map
| File | Role |
|---|---|
src/index.ts |
Plugin entry: the tool definition, failure codes, archive checks, and activation wait |
Further Exploration
- Send a message to another Session — enable the tool in a Web profile.
- API Session Controller — Session activation, restoration, and ownership.
- Subagent control —
send_messagewithin a subagent tree. - Tools — invocation, cancellation, and result recording.
Model Experience
Tool schema and result
What the model sees
The tool catalog defines the exact schema. The schema exposes neither sender identity nor permission overrides. A successful call returns one JSON text block, {"message_id":"..."}, that confirms acceptance, not completion or a reply. A rejected call returns Error: <message>; a subagent target reads session "<id>" is a subagent; message it with send_message and its agent name.
Token effect
The schema contributes prompt tokens whenever the tool is visible. Each call adds its arguments and a compact receipt to the caller's history.
KV Cache effect
Enabling or disabling the row changes the tool schema list and may invalidate reuse from the first changed schema token. Calls and receipts append to ordinary history without rewriting earlier messages.
Delivered message
What the model sees
The recipient receives one steering user message: a text block Agent <caller session id> sent a message: followed by the message text unchanged.
Token effect
The recipient's history gains the prefix and the message text.
KV Cache effect
Append-only in the recipient; the message joins at its next input boundary without rewriting earlier messages.
Known Limitations and Deferred Work
- Web compositions only — only the dsh-web-app bundle declares the row; the
headless,sdk,sdk-minimal, andacpprofiles mount no Session controller and offer nosession_send_message. - Subagent targets use
send_message— the tool rejects a target that subagent routing owns and does not bypass tree-local names, permissions, or restoration rules. - Text only, no reply wait — messages carry text only; the tool attaches no files and does not wait for the recipient's turn or answer.
- Restored Agents stay resident — a cold target restored for a message stays loaded under the Session controller, like a Session opened in the GUI.
- No safe retry after an unknown outcome — acceptance is not idempotent; callers must retain known successful receipts and must not repeat a send automatically.
Dev Note
Working context for maintainers — click to expand
None.