Headless
chord headless is Chord’s lightweight control-plane entry point, suitable for bot, gateway, or automation-script integration.
What it is
Section titled “What it is”- No TUI
- Interacts over stdio
- Input is JSON commands (one per line)
- Output is JSON envelopes (one per line)
It is suitable for outer-layer integration, but it does not provide a browser frontend, multi-tenant isolation, or complete permission hosting.
chord headless# orgo run ./cmd/chord/ headlessCLI flags: -d/--session-dir, -c/--continue, -r/--resume, -w/--worktree. See CLI: chord headless.
Wire format
Section titled “Wire format”- stdin: one JSON command per line
- stdout: one JSON envelope per line. Other diagnostic output goes to stderr; never parse stderr as protocol.
An encoded JSONL envelope is limited to 16 MiB. Input command lines are limited
to 1 MiB; an oversized input line produces a recoverable error envelope with
code: "stdin_line_too_long". Keep individual command and result payloads
below these limits so the process and gateway can keep the stream framed.
If an output envelope exceeds the limit, cannot be encoded, or cannot be
written, Chord cancels ongoing work and exits with a nonzero status. Check the Chord log for the
transport error; the failed output is not delivered as an error envelope.
Every outbound envelope has the shape:
{ "type": "<event-type>", "payload": { ... } }State-carrying envelopes (event-loop pushes, command-path announcements such as role_change and handoff_cancelled, and status_response snapshots) also carry a monotonic seq ({ "type": "<event-type>", "seq": 12, "payload": { ... } }). Pushes leave the process in seq order, but a status_response snapshot is copied and emitted on the command path, so a snapshot taken before a newer push can arrive after it. Any cached-state mutation bumps seq, even when the gateway did not subscribe to the corresponding push or the mutation has no push at all: auto-dismissing a pending confirm or question on send, or an explicit confirm / question / handoff reply; so a later status_response is strictly newer than one copied before the mutation. Integrations that merge status_response into cached state must drop a snapshot whose seq is smaller than an already-seen seq. Every status_response, including one sent before the first push, has a nonzero seq. Reset the highest observed version when a new process sends ready; versions are local to that process.
The first line you receive is always {"type": "ready", ...}; wait for it before sending other commands.
Try one interaction first
Section titled “Try one interaction first”After configuring a model, start chord headless in a terminal:
- Wait for
readyon stdout before sending commands. - Enter
{"type":"status"}on stdin and press Enter. Expect astatus_response. - Enter
{"type":"send","content":"Explain this project without changing files."}and press Enter to send a read-only task. - Read the returned events. If an approval, question, or handoff needs a response, use its corresponding command below; waiting for your answer is not a stuck task.
In an integration, keep the process’s stdin open, read stdout line by line, and collect stderr separately. You can defer event filtering: before subscribe is sent, all subscribable events are forwarded.
Gateway-managed session transfers
Section titled “Gateway-managed session transfers”On macOS and Linux, a gateway that owns the session lifecycle starts a managed process with:
chord headless --gateway-managed --gateway-instance <binding-instance-id> -d <workspace>For an incoming transfer, also pass --resume <session-id> --gateway-transfer-id <transfer-id>. Chord claims the session lock, validates the complete paused checkpoint and target binding, and restores to ready_paused. Ordinary headless and ACP processes do not expose takeover endpoints.
Managed ready and status_response payloads include runtime_id, session_epoch, and the canonical workspace. session_switched also supplies these identities for the active session. The workspace identifies the repository independently of the process’s execution directory, including linked worktrees. A paused target’s ready also includes state: "ready_paused", transfer_id, and binding_instance_id. Verify the transfer, session, workspace, and binding identities before opening the target route.
The paused_inputs field in ready and status_response contains paused, pending_input_count, and inputs. Each input has input_id, owner_task_id, a single-line preview, and attachment_count. At most 8 inputs are returned, with previews limited to 160 Unicode characters. Attachment paths and contents are excluded. A null projection means no valid summary is available; do not treat it as an empty queue. A paused target executes only after an explicit continuation or new request.
Source transfer events bypass subscribe filtering:
| Event | Integration action |
|---|---|
session_transfer_preparing |
Persistently block new input and automatic restarts for the binding, settle receipts for earlier send commands, then send the technical ACK |
session_transfer_status |
Display the state and blockers while draining, saving, or reporting a save failure |
session_transfer_saved |
Saving completed; continue waiting for lock release |
session_transfer_released |
The source released its session lock and will exit with code 20; do not restart it as a crashed process |
Correlate these events by transfer identity rather than the ordinary snapshot seq. Send the technical ACK in stdin order, copying the identity fields from session_transfer_preparing.payload:
{"type":"session_transfer_prepared","transfer_id":"transfer-1","session_id":"session-1","source_runtime_id":"runtime-1","source_session_epoch":1,"binding_instance_id":"binding-1","accepted":true}To reject preparation, use accepted: false with error_code and message. The technical ACK has a 5-second budget. Query the original transfer ID to confirm prepare_failed under the same source and binding identities before reopening the route. A preflight rejection confirms that start was not admitted. If a receipt is lost or the result is unknown, keep the binding blocked. Observation timeouts do not stop source work or release its lock. Coordinate transfers through chord takeover preflight/start/status/retry-save --json; see Usage for user commands and recovery actions.
Commands
Section titled “Commands”You send these on stdin. Unknown command types are answered with an error envelope.
subscribe
Section titled “subscribe”Select which event types you want pushed. If you never send subscribe, Chord forwards all optional event types by default. Sending subscribe replaces that default with an explicit allowlist.
{"type": "subscribe", "events": ["activity", "assistant_message", "idle", "done_completion"]}Response:
{"type": "subscribe_response", "payload": {"events": ["activity", "assistant_message", "idle", "done_completion"]}}Available event types: activity, assistant_message, idle, confirm_request, confirm_resolved, tool_ask_policy_denied, question_request, question_updated, question_resolved, notification, handoff_request, handoff_cancelled, role_change, error, agent_started, agent_notify, agent_done, info, toast, done_completion, local_shell_result, assistant_rollback, todos, compaction_status, session_switched, workdir_changed, background_result, context_notice, lsp_followup, progress_notice, image_result.
For pending input changes, also subscribe to input_queue_changed; see Persistent input queue.
status
Section titled “status”Request a snapshot of the current backend state.
{"type": "status"}Response:
{ "type": "status_response", "seq": 1, "payload": { "session_id": "20260508120000000", "busy": false, "phase": "", "phase_detail": "", "pending_confirm": null, "pending_questions": [], "questions": [], "question_binding_id": "question-binding", "questions_next_after_id": "", "pending_handoff": null, "workdir": { "path": "/workspace/project", "worktree_id": "", "generation": 0 }, "last_error": "", "last_outcome": "completed", "current_role": "builder", "updated_at": "2026-05-08T12:00:00Z", "running_jobs": 0 }}pending_questions includes every visible unanswered question. questions includes those questions, requested closed questions, and a page of closed history in reverse creation order. A history page contains at most 32 records and 2 MiB of encoded snapshots. To read the next page, send {"type":"status","binding_id":"<question_binding_id>","questions_after_id":"<questions_next_after_id>"}. An empty questions_next_after_id ends pagination. Restart pagination when the binding changes; pages observe current committed state and are not a frozen export.
A client reconciling previously open questions should include their IDs in question_ids (at most 32 per query). Those records are returned even when they lie outside the history page; unknown IDs are omitted. Requested closed records have a separate 6 MiB budget; an oversized query returns an error and should be retried with fewer IDs. Merge records by question ID and version, and never infer a terminal outcome from absence in a history page.
session_id tracks the active session, not just the startup snapshot. An in-band switch that replaces the session without restarting the process (handoff plan execution, /resume <id>, /new) updates the tracked id, and the change is announced with an explicit session_switched push; the cached value alone never counts as the gateway having seen the new session. Restores that keep the session (startup replay, durable compaction rewrite) only refresh the timestamp and emit nothing. The tracked id moves even without a session_switched subscription, so status_response always reports the session the runtime actually runs.
workdir is the checkout currently used by the agent. path is the effective working directory, worktree_id is empty for the main or unmanaged checkout, and generation changes whenever the binding changes. A mid-session worktree switch updates status_response and emits workdir_changed when subscribed; integrations should use the generation to discard stale snapshots.
running_jobs counts background shell jobs of the current session that still owe an agent a completion notification: running jobs whose completion will notify an agent (including jobs the operator is stopping), and finished jobs whose notification the agent has not consumed yet. A completion notification wakes the agent; when that work finishes, a new idle carries the updated count. Services and watchers may keep running indefinitely, so a nonzero count does not promise an event within any time limit. Jobs stopped without a completion notification (the model’s job_kill, a SubAgent stop, a session switch) leave the count when the stop is requested; tool-driven stops are reflected when the active work next reaches idle, and a session switch is announced through session_switched. Jobs attributed to another session are excluded. idle carries the same count as status_response.
Send a user message to the agent. Slash commands work the same as in the TUI; bare /models is treated as /models status because there is no TUI overlay.
The example below uses default next-request delivery. To queue a separate task with delivery_policy: "after_completion", use the additional fields and operation-result handling in Persistent input queue.
{"type": "send", "request_id": "input-1", "content": "Please summarize the project structure."}A regular send retains questions and required decisions, interrupting the current wait so the agent can process new instructions. Pending confirmations are still auto-denied, and handoffs close with handoff_cancelled. Resolve questions through targeted answer or cancellation (withdrawal or replacement) operations.
An optional request_id correlates one input_result consumption reply. Replies are always emitted regardless of subscribe; inputs without an ID have no correlated reply.
{"type":"input_result","seq":12,"payload":{"request_id":"input-1","status":"started","turn_id":3}}| status | Meaning |
|---|---|
handled |
A command was consumed locally; its own response or notification describes the result |
queued |
Input entered the pending queue for a later request boundary |
started |
Input created a turn and committed the user message before model preparation |
rejected |
Empty input, a TUI-only command, shutdown, or cancellation prevented this input from starting work; message explains why |
unknown |
Saving the input could not be confirmed; inspect queue state and session history before resending |
Each input has one consumption reply. It does not promise model success, task completion, or durable delivery across disconnects. A queued reply is not followed by another started reply: subscribe to activity and follow global idle to track actual work. handled, queued, and rejected never clear existing busy work. Disconnected unconfirmed inputs have unknown outcomes; inspect the session before resending requests with side effects. Chord admits new input before resolving any blocked interaction and never waits for consumption to resolve it.
models
Section titled “models”Inspect or change model pools.
{"type": "models", "request_id": "models-1", "action": "status"}{"type": "models", "request_id": "models-2", "action": "set_current_model_pool", "pool": "thinking"}Response:
{ "type": "models_response", "payload": { "request_id": "models-2", "ok": true, "status": "Model pool: thinking\n..." }}request_id is optional and is echoed in the response when provided. Clients
should use a unique ID for each request so late responses cannot be mistaken
for a later request. status is a plain-text snapshot that mirrors /models status.
Query or switch the active main role: the remote equivalent of TUI Alt+R. list returns the current role and the ordered main-mode role list (builder first, planner second when configured, then custom roles alphabetically); set switches roles and keeps the conversation history, just like TUI cycling.
{"type": "role", "action": "list"}{"type": "role", "action": "set", "role": "planner"}Response:
{ "type": "role_response", "payload": { "ok": true, "role": "planner", "roles": [ {"name": "builder", "current": false}, {"name": "planner", "current": true} ] }}list puts the active role in role and the full list in roles, where the entry with current: true is the active one. set switches to the named role and returns the new state, and the switch takes effect immediately, even while a turn is in flight. A set is rejected while a handoff_request is pending (resolve the pending handoff before switching role), as are switches to the already-active role (already the active role: <name>), to unknown names, and to roles that exist only as SubAgent definitions. Failures carry ok: false with a human-readable message; surface the message verbatim to the user. A successful role switch is also pushed as a role_change event when subscribed, and the current role appears in status_response as current_role. Note that role_change and role_response are written by different paths, so their arrival order is not guaranteed; treat role_response as authoritative.
confirm
Section titled “confirm”Resolve a pending confirm_request. Use the request_id from the request.
{ "type": "confirm", "request_id": "r-…", "action": "allow", "final_args_json": "{\"path\":\"...\"}", "edit_summary": "", "deny_reason": "", "rule_tool": "delete", "rule_pattern": ".chord/notes/*", "rule_scope": "session"}action follows whatever the model/runtime offered (allow, deny, allow_once, …). Optional rule_pattern + rule_scope (session / project / user_global) installs a permission rule along with the answer; optional rule_tool names the tool the rule applies to and defaults to the confirmed tool. Use it when the block came from a write/delete rule, such as a delete ask raised by an apply_patch move. confirm_request carries the matched rules as {tool, pattern} entries in needs_approval_rule_items and already_allowed_rule_items, so a client can pass the matching entry’s tool through rule_tool. To install several suggestions in one answer, send rule_items instead of the single rule_pattern/rule_tool pair; each item accepts an optional tool (defaults to the confirmed tool) and a required pattern. Omitting all rule fields means a one-shot decision. session applies only to the current session; project writes to the current project’s .chord/agents/<role>.yaml; user_global writes to the user config directory’s agents/<role>.yaml (default: ~/.config/chord/agents/<role>.yaml).
When Chord receives a rule intent with a request ID, it emits a confirm_rule_intent_result after attempting the rule writes. The envelope is always emitted, independent of subscriptions, and contains request_id plus results; each result has tool and pattern, with error when that rule could not be saved. This receipt reports rule persistence separately from the confirmation decision: a failed rule write does not undo an approved call.
While the headless session and event stream remain active, every delivered confirm_request reaches a terminal outcome pushed as a confirm_resolved event: approved / denied echo a client answer, while timeout (the deadline auto-denied with no answer) and cancelled mean the request stopped being actionable without one. Retire the prompt when that event arrives instead of answering it; a late confirm for a resolved request is a no-op on the runtime side. Shutdown may stop event delivery before a terminal event is sent. When the event stream or session closes, discard any locally pending confirmation.
With confirm_ask_policy: deny, eligible permission asks are refused without opening a confirmation. Subscribe to tool_ask_policy_denied to receive the completed decision, with call_id, tool_name, agent_id, policy (deny), and reason. No confirm_request or confirm_resolved accompanies this event, and there is no request to answer. Other pending confirmations remain actionable.
question
Section titled “question”Operate on a stable question ID. Selections use IDs from option_ids; free text uses custom: true:
{"type":"question","action":"answer","operation_id":"answer-1","request_id":"q-1","answers":["brief"]}question_receipt is always emitted and contains operation_id, request_id, accepted, status, version, and error. Only accepted: true confirms durable acceptance. Timeouts or disconnects leave the outcome unknown; retry with the same operation ID and parameters.
| action | Purpose |
|---|---|
presented |
Confirm that the answer entry and default notice are available; include current version, binding_id, and supports_interaction. Channels unable to detect interaction send false and wait for timer cancellation before opening their answer entry. |
interact |
Permanently cancel this timer without answering. |
answer |
Answer a pending question. A question that is not answered must be cancelled with withdraw_requirement; there is no “declined” state. |
revise |
Append a historical revision, retaining the original outcome and task even when another question is pending. |
withdraw_requirement / replace_requirement |
Explicitly withdraw using user_text, or replace with replacement_id in the same task. Models cannot silently remove requirements. |
cancel_task / new_task |
Explicitly cancel the current task / start an independent task scope using user_text. |
user_required never expires; default_allowed requires a valid explicit single-choice default; optional may close unanswered. Clients cannot submit system outcomes. Core owns deadlines; a local countdown does not establish success. defaulted never means user authorization. Core pause suspends timing; client disconnects do not.
status_response.pending_questions lists open questions; questions also includes historical ones. Entries carry task_id, request_scope_id, version, policy, default, timer, and terminal reason. Accept only newer versions per ID and rebuild the projection after a session switch. A historical revision includes revision_result with a distinct result_id and new answer in question_updated; the original reason is retained.
handoff
Section titled “handoff”Resolve a pending handoff_request. Approving starts executing the saved plan with the selected agent; denying appends the rejection reason to the conversation and lets the planner continue from that context.
{"type": "handoff", "request_id": "handoff-…", "action": "accept", "agent": "builder", "pool": "thinking"}{"type": "handoff", "request_id": "handoff-…", "action": "deny", "deny_reason": "Please add rollout steps first."}action accepts accept / allow (or an empty action) to approve and deny / reject to reject with a reason. cancel closes the pending handoff without executing the plan and without appending a rejection message. agent defaults to the request’s default agent, and optional pool switches that agent’s model pool before execution.
A pending handoff belongs to the turn and session that raised it. Whenever Chord discards it without a client decision (on a session switch, when a superseding turn starts, or when a send auto-dismisses it, as described under send), Chord pushes a handoff_cancelled event to subscribed clients, and the following status_response reports pending_handoff: null, so an integration stops waiting instead of showing an approval prompt the agent has already abandoned.
local_shell
Section titled “local_shell”Execute a local shell command from the headless client side and receive a local_shell_result event. This is intended for gateway features that expose !-style local commands.
{"type": "local_shell", "command": "git status --short"}content is also accepted as a fallback command field. Output combines stdout and stderr, is capped, and the command has a timeout.
Security:
local_shellrunsbash -cin thechord headlessprocess environment. It is a direct local command-execution protocol feature, not a model tool request and not a substitute for sandboxing. Gateways that expose it to users must provide their own authentication, authorization, auditing, command filtering, and tenant isolation.
cancel
Section titled “cancel”Cancel the current turn (equivalent to pressing Esc twice in the TUI).
{"type": "cancel"}Persistent input queue
Section titled “Persistent input queue”MainAgent’s send accepts delivery_policy: "next_request" (the default, delivered with the next model request) or "after_completion" (a separate task that waits for the current work to finish normally). After-completion tasks run sequentially in the same session. ACP prompts use next-request delivery.
Read the queue state
Section titled “Read the queue state”ready (including the ready_paused state), session_switched, and status_response can carry an input_queue projection. Subscribe to input_queue_changed for updates. A missing or null projection means the queue state is unknown; inputs: [] confirms an empty queue.
The projection contains:
| Fields | Client use |
|---|---|
runtime_id, session_id, session_epoch, owner_task_id, work_dir_generation |
Copy all five fields into the command’s target object. The owner must be main. Refresh the target after a session or working-directory change. |
view_version, view_version_cas |
Compare versions only after checking runtime/session identity. Keep the newest view. view_version_cas: true advertises support for expected_view_version. |
queue_revision, each input’s revision |
Supply these revisions when clearing the queue or changing an item. A storage-error update can advance view_version without changing queue_revision. |
inputs, works |
Up to 128 input summaries, plus work outcomes. Each preview is limited to 160 Unicode characters; attachments are represented by counts, without paths or binary data. |
restored_held, blocked |
Show why inputs are waiting. Restored inputs stay held until the user continues or sends a new input. |
An after-completion input’s wait_work_id identifies the work it waits for in works. It starts at the first idle after that work settles successfully. Failed, cancelled, or unknown outcomes leave later tasks waiting; a new user task that finishes successfully lets them continue.
Queue a follow-up task
Section titled “Queue a follow-up task”After receiving the queue state, send a command with a unique operation_id and the current target. The example values below must be replaced with the values from that projection; send the JSON as one line over stdin:
{"type":"send","operation_id":"queue-1","request_id":"request-1","target":{"runtime_id":"runtime-1","session_id":"session-1","session_epoch":1,"owner_task_id":"main","work_dir_generation":1},"expected_view_version":7,"content":"Check the documentation","delivery_policy":"after_completion"}For a gateway-managed process, also include binding_id matching its --gateway-instance. Include the current nonzero expected_view_version to bind the operation to the displayed view; an outdated version returns conflict without applying the operation.
Inspect or change an item
Section titled “Inspect or change an item”Send type: "input_queue" with an action, a unique operation_id, the same complete target, and binding_id when required. Use expected_view_version as above. For example:
{"type":"input_queue","action":"update","operation_id":"queue-2","target":{"runtime_id":"runtime-1","session_id":"session-1","session_epoch":1,"owner_task_id":"main","work_dir_generation":1},"expected_view_version":8,"input_id":"input-1","expected_revision":1,"delivery_policy":"next_request"}| Action | Additional required fields | Description |
|---|---|---|
get |
input_id |
Returns full body text and attachment count |
update |
input_id, expected_revision |
Updates body (optional content) or policy (optional delivery_policy) |
delete |
input_id, expected_revision |
Removes the item from the queue |
hold_edit |
input_id, expected_revision |
Pauses consumption while editing |
release_edit |
input_id, expected_revision |
Releases the editing hold back to the queue |
clear |
expected_queue_revision |
Clears all unstarted after-completion inputs |
Omitting content preserves the body and attachments. Providing it replaces the text; an empty replacement is rejected. Use the local TUI to edit the body of an input with attachments. Holding or editing an item keeps it queued; items that have already started cannot be edited or deleted.
Handle results
Section titled “Handle results”Both after-completion sends and input_queue commands return input_queue_result, correlated by operation_id, regardless of event subscriptions. Results include the target and available item/queue revisions:
result |
Client action |
|---|---|
committed |
The operation succeeded. For a send, the input is durably queued; follow queue updates for execution. |
rejected |
Display reason and correct the request before submitting again. |
conflict |
Refresh the queue and revisions before deciding whether to repeat the operation. |
unknown |
Check queue state and session history before retrying; the operation may already have been saved. |
Providing request_id on a send also enables an input_result receipt once the Agent handles the submission (queued, rejected, or unknown for this delivery path). An entry-point validation failure may return only input_queue_result, so use that response to settle the operation. A queued receipt is issued once and is not followed by a second started receipt. If a connection closes before a response arrives, reconcile queue state and history before resending.
Image delivery
Section titled “Image delivery”Subscribe to image_result to receive completed generate_image results. Each result contains call_id, agent_id, status and the small saved-image summary in result. A successful result is followed by image_artifact envelopes for every original. If an original cannot be read, another image_result with the same call_id and agent_id reports delivery_error; some chunks may already have arrived. The summary’s successful status confirms the tool result, while delivery is complete only after every referenced image has a final chunk and a matching hash. Delivery errors never trigger generation again.
Each chunk has reference, call_id, request_id, agent_id, mime_type, width, height, size_bytes, byte offset, last and base64 data. Decode each chunk separately and append at its byte offset; stop at last: true and verify the original’s SHA-256 from the summary. Raw chunks are at most 384 KiB, keeping JSON frames below 600 KiB. The data is the original, not a resized model preview.
To retrieve a saved original from the active session, send:
{"type":"image_artifact","request_id":"download-1","content":"artifact:images/sha256-<digest>.png"}The response uses the same chunk shape and echoes request_id. Only generated image references under the active session are accepted; arbitrary disk paths and files from another session are rejected. If the request fails because session artifacts are unavailable or the original cannot be read, the error payload also echoes request_id so the client can settle the matching request. This command never calls an image service. A gateway that subscribes to image results must assemble and forward the bytes using its platform’s file or image API.
Events
Section titled “Events”You receive these on stdout. The list below covers what is emitted by default plus the subscribable types. Treat unknown fields as opaque so future server upgrades don’t break your client.
Always emitted (no subscription needed)
Section titled “Always emitted (no subscription needed)”| Type | When | Notable payload fields |
|---|---|---|
ready |
Server has finished startup and is ready to accept commands | session_id, worktree info (when applicable: name, branch, path, repo_root) |
question_receipt |
Durable result of a question operation | operation_id, request_id, accepted, status, version, error |
input_result |
Consumption reply for a send carrying request_id |
request_id, status, optional turn_id / message |
confirm_rule_intent_result |
Result of persisting rules attached to a confirmation | request_id, results[] with tool, pattern, optional error |
subscribe_response |
Reply to a subscribe command |
events |
status_response |
Reply to a status command |
see status |
models_response |
Reply to a models command |
ok, message, status, optional request_id |
role_response |
Reply to a role command |
ok, message, role, roles[] with {name, current} |
error |
Command parse / execution error | message, optional code (for example stdin_line_too_long), optional request_id for image_artifact failures |
Subscribable
Section titled “Subscribable”| Type | When | Notable payload fields |
|---|---|---|
workdir_changed |
The active working directory changed | path, worktree_id, generation |
image_result |
Image tool result or original-image delivery error | call_id, agent_id, status, result, delivery_error; Image delivery describes the accompanying image_artifact chunks. |
activity |
Agent enters a new phase | agent_id, type (preparing, connecting, streaming, compacting, …), detail |
assistant_message |
A complete assistant message is ready for consumption | agent_id, task_id, agent_type, parent_agent_id, text, tool_calls; delegation fields are empty for main |
idle |
The main agent and all SubAgents are globally quiescent and ready for input | last_outcome (completed / cancelled / error), suppress_user_notification (true unless the agent ran since the previous idle event), running_jobs (same count as status_response; while it is above zero, each counted job wakes the agent again when it ends and a new idle follows, so an integration waiting for the work to end should keep reading events) |
done_completion |
Done tool completed with a final report. Emitted only while a loop is running, since that is the only time done is mounted; the mode field is currently always normal |
call_id, report, reason, status, agent_id, mode |
confirm_request |
A tool needs explicit confirmation | request_id, agent_id, tool_name, args_json, needs_approval, already_allowed, needs_approval_rules, already_allowed_rules, needs_approval_rule_items, already_allowed_rule_items, timeout_ms |
confirm_resolved |
A confirmation reached a terminal outcome and its request_id is no longer actionable; close it instead of answering (approved and denied are echoes of a client answer, timeout is the auto-deny deadline, cancelled ended early) |
request_id, agent_id, tool_name, outcome (approved / denied / timeout / cancelled) |
tool_ask_policy_denied |
A permission ask was refused by configuration without opening a confirmation | call_id, tool_name, agent_id, policy (deny), reason |
question_request |
A question becomes available | request_id, binding_id, task_id, request_scope_id, version, header, question, options, option_ids, option_details, multiple, response_policy, default_option_id, timer, duration_seconds, optional deadline |
question_updated |
Timing, interaction, requirement disposition, or historical revision changes | Full question snapshot; historical replies add revision_result with a distinct result_id |
question_resolved |
A question reaches a terminal outcome | Full snapshot; reason is answered, defaulted, no_response, superseded, cancelled, or error |
notification |
A user-facing reminder for an explicit wait that is not a modal request | reason, message |
handoff_request |
A planner saved a handoff plan and needs the client to approve or reject execution | request_id, plan_path, plan_text, plan_error, agents[] with {name, default, model_pools, current_model_pool}; agents is empty when no eligible target exists |
handoff_cancelled |
A pending handoff was discarded before the client decided — a newer turn, a session switch, or an auto-dismissing send superseded it |
request_id, reason (superseded) |
role_change |
The active main role switched (via TUI Alt+R or a role set command) |
role |
local_shell_result |
Result for a local_shell command |
command, output, failed, error |
agent_started |
A delegated SubAgent runtime started, including an on-demand rehydration of a parked task | agent_id, previous_agent_id (set for rehydration), task_id, agent_type, description, parent_agent_id, parent_task_id |
agent_notify |
An agent sent a non-blocking owner or targeted delegated-workstream update | agent_id, task_id, agent_type, parent_agent_id, parent_task_id, target_agent_id, target_task_id, kind, subtype, message |
agent_done |
A SubAgent completed its task | agent_id, task_id, agent_type, parent_agent_id, parent_task_id, summary, message |
assistant_rollback |
Discard in-flight streamed assistant output (mostly relevant for streaming UIs) | agent_id, reason |
info |
Informational message from the runtime | agent_id, message |
toast |
Transient notification surfaced to the user in the TUI; safe to ignore in headless | agent_id, message, level (info / warn / error) |
todos |
Replacement todo list | todos[] with {id, content, status, active_form}. Multiple in_progress items can be valid when each maps to a distinct active workstream and uses a unique active_form. |
compaction_status |
Compaction lifecycle events: started and terminal outcomes (succeeded, skipped, failed, cancelled) |
status, trigger (manual, usage_driven, length_recovery, oversize_driven, model_driven), reason, plan_id (bounded compaction plan identifier for correlating the terminal outcome with the plan that produced it). Progress telemetry is not forwarded. |
session_switched |
The active session changed without restarting the process (handoff plan execution, /resume <id>, /new) |
session_id (the new active session) |
background_result |
A finished background job’s durable result; the only delivery channel for the JOB RESULT card, which typically lands after the turn is idle so no later assistant_message summarizes it |
session_id (the session Chord had active when it emitted the event), target_agent_id, message_index, content |
context_notice |
Durable context-pressure warning with no other headless channel | session_id (the session Chord had active when it emitted the event), target_agent_id (the SubAgent that emitted the notice, or main for the main session), level, message, message_index |
lsp_followup |
Durable LSP diagnostics that a language server reported recently written files after their tool results returned (for example gopls analyzer findings), sent when they add a new error or warning; the model receives the same text with its next request, which may be in a later turn | session_id (the session Chord had active when it emitted the event), message, message_index |
progress_notice |
Durable reminder asking the main agent to report progress during a long tool-call chain; emitted only when progress_reminder: true is configured; the agent’s actual update arrives through assistant_message |
session_id, message, message_index |
error |
Runtime error | agent_id, message, optional code |
If an input line on stdin exceeds the protocol line limit, Chord emits an error envelope with code: "stdin_line_too_long" and continues reading later lines. Integrations should use code for classification when present and keep message for human-readable diagnostics.
Silent retry telemetry is never pushed. A retry the TUI only records in the error panel emits no error envelope and leaves last_error / last_outcome (status_response and idle) untouched, so a turn that hits a silent retry and recovers still reports completed. A terminal failure is always followed by a non-silent error, which is the one integrations observe.
assistant_message.text may be empty for tool-only rounds (including a SubAgent Complete call). Chord logs a warning for observability; gateway integrations should skip the empty message and read the SubAgent completion from agent_done.
agent_done.message carries the owner-facing completion report, including reported checks, remaining limitations, and file-attribution warnings when present. File lists keep reported_files_changed separate from actual_files_changed. Use message to read the full report and summary for a short completion label. See Completion reports.
Quiescent SubAgents may release their live runtime while their task and transcript remain durable. A later authorized targeted notification can rehydrate the task with a new agent_id; use stable task_id for routing and use previous_agent_id on agent_started to replace runtime-specific labels.
idle is a global quiescence signal, not a per-request completion signal. Chord does not emit it while any agent is running, any internal event or actionable mailbox message is queued, a Handoff decision is pending, or a SubAgent has input waiting for its next request. A busy target processes queued messages at the next request boundary; a resumable non-running target is woken first. Progress and notice snapshots bound for the main inbox are actionable rather than informational: while the main is idle, Chord merges the pending undelivered updates into a single delivery batch, delivered in arrival order, and wakes the main for that delivery turn before global idle can fire; every arriving batch therefore costs one extra main turn and LLM request, and the idle event is held back until the batch has been delivered. suppress_user_notification does not change the idle state transition; it only tells user-facing integrations not to emit a generic completion reminder when the quiescence was not preceded by real agent work: for example startup, session / model-pool / MCP switches, or other user-initiated navigation. It is true unless the agent actually ran (a main turn, loop execution, or active SubAgent work) since the previous idle event. notification is the complementary explicit reminder for a runtime state that is waiting for user input; reason="user_input_required" currently covers permissions, questions, Handoff, loop decisions, and notify-protocol corrections. Permissions, questions, and Handoff already deliver their own prompt as a card or as chat text, so an integration may drop the reminder while that request is still pending; loop decisions and notify corrections have no other prompt.
Slash compatibility via send
Section titled “Slash compatibility via send”For convenience, headless also accepts these via send so you can drive Chord from a chat surface that only has a single text input:
/models status,/models <pool>,/models --agent <name> <pool>/role status,/role <name>: query or switch the active main role (same operation as theroleprotocol command)/help,/stats,/compact,/loop on,/loop off(only when the active MainAgent role can use thedonetool)
Bare /models is treated as /models status, and bare /role as /role status. /new and /resume <id> work in headless and switch the session in-band (they emit session_switched). Bare /resume still needs the TUI picker, and so do a few other slash commands such as /export; those return an error envelope explaining “X is only available in local TUI mode”.
Minimal Python client
Section titled “Minimal Python client”import jsonimport subprocessimport threading
proc = subprocess.Popen( ["chord", "headless", "-d", "/path/to/project"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL, bufsize=1, text=True,)
def reader(): for line in proc.stdout: ev = json.loads(line) print("<-", ev["type"], ev.get("payload"))
threading.Thread(target=reader, daemon=True).start()
def send(cmd: dict) -> None: proc.stdin.write(json.dumps(cmd) + "\n") proc.stdin.flush()
# Wait for ready (the first line is always "ready"), then subscribe and send.send({"type": "subscribe", "events": ["activity", "assistant_message", "idle", "done_completion"]})send({"type": "send", "content": "Summarize the project structure."})In production, also handle confirm_request (reply via confirm), question_request (reply via question), and handoff_request (reply via handoff); confirmations and handoffs wait for a decision, while questions may allow independent work to continue.
chord-gateway: recommended way to consume headless
Section titled “chord-gateway: recommended way to consume headless”If you want to drive Chord from a chat surface (Feishu, WeChat, …) or build a multi-user gateway, you usually do not need to implement the headless protocol from scratch. The companion project keakon/chord-gateway already wraps it and adds the bits the protocol intentionally leaves out:
- Process lifecycle: spawning / restarting
chord headlessper session, reaping idle processes. - Per-tenant isolation: per-user working directory, audit logs, rate limits.
- Adapters for chat platforms: Feishu / WeChat webhooks, message chunking, image relay.
- Permission UX: rendering
confirm_requestandquestion_requestas inline replies, mapping replies back toconfirm/questioncommands. - Reconnection helpers around the wire format above.
The headless protocol on this page is the lower-level contract, suitable for integrators who need something chord-gateway does not cover. If your goal is “let people talk to Chord from their phone”, start with chord-gateway and only drop down to headless when you have a specific reason.
Suitable usage
Section titled “Suitable usage”- Let the outer gateway manage process lifecycle.
- Let the outer system decide which events to show to end users.
- Enforce working-directory, permission, audit, and tenant-isolation controls in the outer layer.
Not a replacement for
Section titled “Not a replacement for”chord headless is not:
- a browser application
- a multi-tenant security boundary
- a complete permission sandbox
For higher-level deployment patterns, see chord-gateway.