Builds an agent in steps from the host language. Every setter
returns the same builder, so calls chain; nothing is checked until
build, which consumes the settings.
The one error type of the neutral API: a stable code, a message
that never holds a key or secret, and the run_id text when the
failure belongs to a run that can be resumed or inspected.
One event of a run: its run id text, its seq (ordered within one
run id), the clock time in milliseconds since the Unix epoch, and
the kind. Delivered by RunStream::next or an EventListener.
Token counts and cost of a run or step, as plain numbers.
cost_usd_micros is millionths of a US dollar from the model price;
host models are free unless priced with host_model_priced.
Builds a graph of agent and step nodes in steps from the host
language. Every setter returns the same builder; nothing is checked
until build, which consumes the settings.
A failure inside host code, as a message. Foreign exceptions arrive
as this type from the adapters. A host tool’s error reaches the model
as an error result; a host model’s error fails the run with
HostCallback; a host transport’s error is retried (Retries).
One HTTP header: name, value, and sensitive, set when the value is
a credential such as the vendor API key. Debug shows a sensitive
value as [redacted]; adapters must hide it in their text forms too.
One HTTP request a host transport sends: method, absolute URL,
headers and body bytes, only for model and embedding calls to the
resolved vendor. The key header is sensitive; Debug redacts it.
One message of a host model request: role (user, assistant,
tool), its text, the assistant’s tool calls as JSON text, and the
tool call id a tool message answers.
What a host model can do: native tool calls (tools), JSON Schema
constrained output (json_schema), token streaming (streaming)
and its context window in tokens. Default: none, 4096 tokens.
A host model’s reply: the whole text (also when it was streamed
through TokenSink), the token counts the model reported, and for a
model with native tools its calls as a JSON list of {id, name, arguments}. Start from HostReply::default() and set the fields.
One request to a host model: the system prompt, the conversation,
the tools as a JSON array, the output JSON Schema, and the reply’s
token cap. Built by troupekit, read by the host.
Where a host transport reports an HTTP response: head once with
the status, the final URL and the headers, then chunk for each
part of the body. Built by troupekit for each send call.
Knowledge settings for AgentBuilder::knowledge: the document
dir to ingest at build, an optional index and store path, and
whether files that fail to load are allowed.
Memory settings for AgentBuilder::memory: the user and session
the facts belong to, an optional SQLite path, and whether known facts
are put in the system prompt (preamble).
A run in progress that yields its events: pull them with next, or
hand them to an EventListener, not both. The buffer drops text
deltas when full and never lifecycle events.
Process-wide settings of the neutral runtime: worker threads (1 to
64, default 2), the largest caller string in bytes (1 KiB to 64 MiB,
default 1 MiB) and the stream event buffer (16 to 1 048 576, 4096).
Where a host model pushes text deltas while it generates. Each
delta reaches the run’s stream as a TextDelta event, except when
troupekit emulates tools: then the parsed answer is sent once.
Built by troupekit for each HostModel::generate call.
Stable numeric code of every failure the neutral API reports.
The numbers are fixed forever: a binding may match on them, store
them or send them over the wire. New codes only ever get new numbers.
What happened in one event, mirroring the engine’s event bodies:
run and step lifecycle, text deltas, tool calls, pauses, the end.
Hosts match it with a fallback arm, since new kinds may be added.
Why a run paused: a graph node waits for an approval or an answer,
or a budget limit (call, run, a period) would be passed.
Resume after the host has dealt with it.
Where a run stands after one resume_for window: Done with the
answer text, or Pending when the budget ran out first; the run
then continues from its last checkpoint on the next call.
Receives every event of a stream as it happens, as the callback form
of RunStream::next. Called on one thread per stream,
troupekit-listener, never the caller’s; a slow listener only
slows its own delivery, and the buffer drops text deltas meanwhile.
An embedding model run by the host, for knowledge search.
Every vector must have dims numbers; troupekit checks the shape
and sends at most 256 texts per call.
A model run by the host, such as the phone’s built-in model.
troupekit renders each request for the model’s capabilities and
parses tool calls out of plain text when it has no native tools.
A tool written in the host language: a name the model calls it by,
a description, a JSON Schema for its arguments and the call itself.
troupekit checks name and schema when it is added.
An HTTP client in the host language, used only for model and
embedding calls to the resolved vendor. The host must turn off
redirect following and report a 3xx as received; troupekit refuses
it. The response goes through HttpSink: head, then chunks.
Receives every trace record of a traced build or run, as the
callback form of trace_jsonl. Called on the thread that writes the
record, so it should return fast; keys are scrubbed before the call.
Sets the runtime settings once, before the first agent or graph call.
Input: the settings. Output: Ok, also for a repeat with the same
settings, or InvalidArgument for a value out of range or other settings.
Returns the troupekit version this library was built from.
Input: none. Output: the workspace package version, for example 0.1.0,
which every troupekit crate shares, so it matches troupekit-core.