Embedding

Drive zot from another program.

Two ways to drive zot from another program. Both share the same event schema, so transcripts captured by one can be replayed through the other.

Go, in-process

Import github.com/patriceckhart/zot/packages/agent/sdk. One Runtime per project; Prompt(ctx, text, images) returns a channel of Event. Example in examples/sdk/.

Any language, out-of-process

Spawn zot rpc as a subprocess and exchange NDJSON over its stdin/stdout. Reference clients for Python, Node, shell, and Go live under examples/rpc/.

Compaction guidance

The Go SDK accepts Config.AppendCompactionPrompt, a string slice of additional summarization instructions. Direct core integrations can set Agent.CompactionPrompt to replace the summary template and Agent.CompactionInstructions to append guidance before use.

RPC processes can receive the repeatable startup flag without changing the RPC request schema:

shell
zot rpc --append-compaction-prompt "Preserve unresolved tasks and reference existing documents by path."

A nonblank $ZOT_HOME/COMPACT.md replaces the built-in summary template for manual and automatic compaction. Per-run additions follow the selected template. Missing or blank files retain the default template, while other read failures stop initialization. Reconfigure the agent after editing the file.

The default side mode uses a separate summarization system prompt, unaffected by ordinary system-prompt configuration. To opt into in_place, set "compaction_mode": "in_place" in $ZOT_HOME/config.json before starting the runtime or RPC process. Direct core users can set Agent.CompactionMode before use. In-place mode retains the active system prompt, tools, reasoning settings, and structured message prefix, then appends the summary instruction. Both modes support custom summary templates without imposing the built-in format.

This adds no RPC request field or dedicated Go SDK configuration field. Zot never executes local tools during summarization, but advertised provider-hosted tools may run remotely in in-place mode. The summarizer cannot open local referenced files. See Sessions for fallback behavior and cache limitations.

Optional reasoning events

Readable reasoning is opt-in. Start zot rpc --show-reasoning or zot --json --show-reasoning to receive reasoning_delta events. In the in-process Go SDK, set sdk.Config{ShowReasoning: true}. The saved interactive show_reasoning preference does not enable these events for machine clients, so default streams remain unchanged.

json
{"type":"reasoning_delta","delta":"Checking the constraints."}

Accumulate these chunks separately from text_delta. They contain readable reasoning or summaries, never signatures or encrypted payloads. Opting in requests readable summaries on Responses/Codex calls and summarized thinking on native Anthropic calls with thinking enabled, without changing configured effort. Providers may still return no readable reasoning.

assistant_start begins a new model call. On assistant_message, turn_end, or done, finish the transient preview and optionally keep the collected reasoning beside the reply. The TUI keeps a compact tail before each answer rather than discarding it. Stored assistant messages can retain up to 8,192 Unicode characters in display-only meta.readable_reasoning, including in sessions and continuous entries. This metadata is stripped from subsequent model inputs. It is not a new field in JSON/RPC notifications or SDK message objects, so machine clients that want a persistent display should retain the deltas themselves.

Use a zot binary or Go SDK version that includes this opt-in. Packaged clients may not expose the flag through their own configuration yet.

Extension prompt hooks in RPC

RPC mode supports the before_agent_start extension hook. Subscribed extensions receive the complete assembled system prompt before the first model call and can replace it exactly. This uses the extension subprocess protocol, not a new RPC client command. Ordinary follow-up prompts reuse the result; an accepted clear or model change invalidates it for the next prompt. Failures keep the current prompt and surface as ext_notify warnings. See Extensions for lifecycle, privacy, and response limits.

RPC state changes while busy

clear, set_model, and set_reasoning require an idle agent. During prompt preparation, including extension hooks, model/tool execution, or compaction, they return success:false with an agent is busy error and leave state unchanged. These commands are not queued.

Wait for the active operation to finish, or send abort, wait for completion, and retry. The RPC read loop remains responsive to abort while an extension hook or provider is busy.

Packaged SDKs

For the two most common app targets, drop-in packages wrap the RPC handshake so you do not manage the child process by hand:

  • Node.js SDK - a TypeScript client (@patriceckhart/zot-sdk-javascript) that runs zot rpc for you in any Node-compatible server runtime.
  • Swift bridge - zot's Go agent core compiled into an Apple xcframework for native, on-device chat in iOS and macOS apps.