Agent Prompt Submission
On this page
Agent prompt submission and final responses#
wakterm agent send TARGET MESSAGE writes the prompt to the native harness pane, submits it, waits for acknowledgement, and prints structured JSON. Enter is pressed in its own write once the pane has redrawn the typed prompt, because a harness can drop an Enter that arrives while it is still taking a paste: Claude discards it when a pasted line ends like an image path, such as a link to a .png file.
For a Claude, Codex, agy, Devin or Muse agent, acknowledgement is exact: the command waits for the input_accepted Agent API event whose input_sha256 matches the sent text, and returns as soon as the agent records it, whether the input starts a turn or joins a running one. Its JSON then reports acknowledgement.kind: "input_accepted". A Claude slash command is acknowledged when Claude records a command, since Claude records an alias such as /new under the command's own name, /clear. If the agent does not record the input within --ack-timeout-ms (10 seconds by default), the kind is timed_out and acknowledged is false. Claude can leave typed input in its prompt without submitting it, for example while it is still starting, so while Claude has not recorded the input and reports itself idle with nothing else holding the keyboard, the command presses Enter again every 2 seconds, up to 3 times. When the event stream cannot be read, such an agent's other progress does not stand in for its record of the input, so the kind is unavailable and acknowledged is false. agy holds a message sent during a turn and sends it on its own as its next turn once the running one ends, joined with any other message it held until then, and records it only then; while it shows the message in a ▸ row above its input box, the kind is input_queued and acknowledged is true. For other harnesses, the command watches the agent's observed progress instead.
When the text would not reach the agent's prompt, because a dialog, question or startup prompt has the keyboard, or would be sent together with something else, because Claude's input box holds text the user is typing, the command writes nothing and still exits successfully. A dimmed prompt suggestion in an empty box is not typed text and does not block a send. Text in Claude's box blocks a send only while someone is typing it, which is for 60 seconds after the last input to the pane. After that, Wakterm presses Claude's stash key, Ctrl+S by default, which moves the draft out of the box, and sends the message; Claude puts the draft back once the message is submitted and shows "Draft restored". Wakterm reads ~/.claude/keybindings.json each time and presses whichever key the stash action chat:stash is bound to there. The draft blocks the send, with a detail that says which, only when the action has no key, as when Ctrl+S was given to another action, or when its key is one Wakterm cannot send as input. Sendable keys are Ctrl with a letter and Alt or Meta with a letter or digit, alone or in a chord. For a Codex agent, the command writes only while the pane shows Codex's input box enabled and empty, with its placeholder or nothing in it, and while Codex reports no pending approval or question. A draft, an approval, a question form, a selection menu or the transcript view in place of the box blocks the send, because Codex would discard the text and take the Enter that follows as an answer. A message sent into a running managed Codex turn can be left unused when the turn ends first, and Codex puts it back in its input box. When the turn completes, Wakterm presses Enter once for it, submitting it as the next turn, if Codex recorded no input since the message was sent, nobody has typed into the pane since, Codex is idle, and its input box holds text. For an agy agent, the command writes only while agy's footer shows its idle hint, "? for shortcuts", under an empty input box. agy shows that hint only while no turn runs; during a turn its footer reads "esc to cancel", or a hint that takes priority over it, such as for a message already queued into the turn. A message sent during a turn would be queued and sent together with the user's next input, so anything else in the footer, or text in the box, blocks the send. When agy shows its feedback survey ("How's the CLI experience so far?") in place of the box, which it does only once a turn has ended, Wakterm presses its Skip choice, 0, and sends the message once the empty box is back; if the survey stays, the send is refused with that reason. Starting agy with IS_DEMO=1 turns the survey off. If agy starts a turn after the text is written but before Enter, for example when one of its background tasks finishes, Wakterm presses no Enter and removes its text from the box. Nothing was delivered, so the command reports it like the other cases above, with submitted: false and an input_blocked refusal. If the text cannot be removed, it may still be sent later, and the command fails with an error that says so. For a Devin agent, the command writes while Devin's input box is empty, whether or not a turn runs: Devin shows "Guide Devin while it works" in the box during a turn and takes a message sent then as guidance for that turn, recording it as input of that turn. A permission prompt in place of the box, or text in it, blocks the send. A Muse agent is sent to the same way: while Muse's input box, the ❯ line between the two lowest rules, is empty, whether or not a turn runs. A tip Muse shows in an empty box, in the rules' gray, is not text in it. Muse queues a message sent during a turn and hands it to that turn, recording it as input of that turn. A draft in the box, or a prompt in its place, blocks the send. Its JSON then has submitted: false and refusal: {"reason": "input_blocked", "detail": "..."}; refusal is null otherwise. reason is a stable code that callers can match to retry once the agent is idle, and detail is human-readable text that may change.
For an idle Codex agent with an exact observer-backed PTY session or managed app-server session, or an idle Claude agent with an exact observer-backed PTY session, --return-final creates a durable asynchronous return request:
wakterm agent send zola --return-final "Complete phases 2 and 3"
The command registers the exact correlation boundary, submits the prompt, and exits. Its JSON receipt contains reply_pending: true, the request ID, target incarnation, correlation source, baseline provider turn when available, and armed cursor. Observer-backed PTYs use the provider-file cursor. Managed app-server sessions use the durable Agent API event sequence. The command does not keep a CLI process or RPC socket open for the delegated turn.
Use a caller-generated UUID when another durable system owns the request:
wakterm agent send zola \
--return-final \
--request-id fe57dc90-994e-4e73-b09c-fac483d9f05b \
--final-timeout-ms 3600000 \
"Complete phases 2 and 3"
Repeating the same request ID and input returns its existing receipt without submitting the prompt again. Reusing the ID with different input is rejected. The timeout is an asynchronous request deadline. Zero, the default, disables the deadline.
Authoritative admission for orchestrators#
agent send remains the convenient interactive command. An orchestrator that
must not steer an active turn uses the versioned admission API instead:
wakterm agent capabilities
wakterm agent catalog
wakterm agent admit zola \
--incarnation PROCESS_INCARNATION \
--request-id REQUEST_ID \
--return-final \
--final-timeout-ms 3600000 \
"Complete phases 2 and 3"
An orchestrator retrying a persisted identity that may no longer appear in the
current catalog uses --exact-agent-id. This bypasses display-name and catalog
resolution so the server can return a structured unavailable or
stale_incarnation receipt:
wakterm agent admit PERSISTED_AGENT_ID \
--exact-agent-id \
--incarnation PERSISTED_INCARNATION \
--request-id REQUEST_ID \
"Complete phases 2 and 3"
The catalog supplies the stable agent ID and opaque process incarnation. The admission call requires both, refreshes the provider observer away from the mux reactor, and rechecks the same incarnation and authoritative idle state immediately before input. Prompt text and Enter are serialized as one pane write. Observer scanning, SQLite work, and the removed 200 ms submission delay do not block the mux reactor.
The structured receipt classifies accepted, busy, unsupported,
unavailable, stale_incarnation, invalid, observer_failure,
internal_failure, and indeterminate. A definitive rejection always has
prompt_written: false. Any write error is indeterminate because a PTY write
may have been partial. Callers must not retry an indeterminate request under a
new ID.
An idle observer-backed target whose observer has not produced a cursor for its completed baseline turn is a definitive observer_failure with prompt_written: false. A managed target receives the same classification when the durable Agent API event stream is unavailable. It is not busy, because no active target turn was observed, and it is not a delivery failure, because Wakterm did not attempt the pane write. A caller may choose an explicit one-way admission while return-final correlation is unavailable.
The caller owns the request ID. Repeating the same ID, process incarnation, prompt bytes, paste mode, return mode, and timeout cannot write the prompt a second time. Reusing an ID with different input is rejected. One-way admissions and return-final admissions both persist their idempotency state. Return-final admissions continue to complete on the existing durable terminal request stream described below.
Results and subscriptions#
Inspect or cancel one request:
wakterm agent request get REQUEST_ID
wakterm agent request cancel REQUEST_ID
Terminal results are appended to a durable ordered event stream. A consumer
keeps the last processed terminal_event_sequence and resumes after it:
wakterm agent request watch --after 42
The command emits one JSON object per terminal request and remains attached as
a single subscription. --once drains currently available events and exits.
Terminal states are completed, aborted, timed_out, cancelled,
delivery_failed, and indeterminate. Only completed contains
final_message.
The request database lives in Wakterm's data directory, uses SQLite WAL with full synchronous commits, and survives mux and consumer restarts. Terminal event sequence numbers are stable, so consumers can make their own delivery idempotent without reading provider session files.
Correlation safety#
Every return request requires the same exact target incarnation, authoritative idle state immediately before the atomic prompt write, and one stable provider turn through completion.
Observer-backed Codex PTYs additionally require:
- the same adopted process ID and process start time remain attached
- the same exact observer session remains attached
- the target was idle at submission with a completed baseline turn
- the provider starts a new turn after the armed observer cursor
- the first user message hash matches the submitted prompt
- the bound provider turn ID remains stable through completion
Managed Codex app-server sessions instead require:
- the same exact app-server thread ID and session ID remain attached
- the durable Agent API event stream is live at admission
- the first new provider turn starts after the armed durable event sequence
- the same provider turn ID supplies the durable final
A mismatch becomes indeterminate. Wakterm never substitutes a later final message. During live admission, a request remains registered until prompt submission is durably confirmed; terminal watchers leave that registration unchanged. At authoritative mux startup, registrations left unfinished by the previous runtime become indeterminate, preventing a post-restart prompt from satisfying them accidentally.
Steering messages within the same bound provider turn preserve correlation. They do not replace the matched initial prompt or authorize a final from a different provider turn.
Codex session discovery first checks rollout files actually held open by the adopted process tree and verifies the adopted process start time and declared working directory. A reused pane can no longer remain attached to an older rollout merely because that file was the previous preferred observer session.
An observer-backed return request correlates from the agent's durable Agent API events. Admission records the current event sequence, and the request binds the first new turn_started from the exact agent incarnation whose input_sha256 matches the prompt, then completes or aborts with that turn's turn_final. A new turn started by different input, or by input the provider does not record, ends the request indeterminate rather than binding it. Input queued into the bound turn while it runs does not start a new turn. Codex, Claude, and agy projections record the input hash, so they support return mode; another harness gains it once its projection records the hash and its sessions bind to the exact process. agy records the sent text between <USER_REQUEST> tags ahead of metadata it appends, and the hash covers only that text. OpenCode's projection records the hash too, but Wakterm chooses an OpenCode session by its working directory and recency rather than by the process that owns it, so OpenCode does not support return mode.
One PTY limitation remains: byte delivery and the durable submitted marker cannot be a single transaction. Wakterm resolves a crash in that narrow window as indeterminate instead of risking duplicate or unrelated completion. The actual pane write still runs through the existing mux input path, but it is one bounded write rather than observer work, database work, or a timed wait.