Documentation
¶
Overview ¶
Package runtime wires the pieces — an agentkit LLM, a toolset, skills, permission gating and session defaults — into ready-to-run sessions. Build a Runtime once, then start Sessions or one-shot Once calls that all share its policy, grants, approver and tools. It is the composition root: the plumbing lives here so a consumer configures, not wires.
Share the tools, not a snapshot of them: a Runtime holds the toolset as a function its sessions ask at the start of every turn (see WithToolsFunc). A consumer whose available tools change while conversations are open therefore answers the next turn with the new set, without reopening anything — and a turn still works with one fixed set from beginning to end.
Index ¶
- type Option
- func WithContext(fn func(context.Context) context.Context) Option
- func WithGate(policy gate.Policy, grants gate.Grants, approver gate.Approver) Option
- func WithGateLogger(log agentkit.Logger) Option
- func WithResultFilter(f agentkit.ResultFilter) Option
- func WithSession(opts ...agentkit.Option) Option
- func WithSkills(ss agentkit.SkillSet) Option
- func WithSkillsFunc(fn func() agentkit.SkillSet) Option
- func WithTools(ts agentkit.ToolSet) Option
- func WithToolsFunc(fn func() agentkit.ToolSet) Option
- func WithoutGate() Option
- type Runtime
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Runtime)
Option configures a Runtime.
func WithContext ¶
WithContext adds fn to what every session's ctx passes through when the session is built, before the gate is installed on it. A consumer uses it to put on the ctx what its policy reads — who the work is for, say — so every tool call of the session, and of its sub-agents, carries it. Several apply in the order given.
func WithGate ¶
WithGate installs permission gating: a Policy plus a Grants store (nil = in-memory) and an Approver (nil = unattended, so any Ask is denied). Without WithGate or WithoutGate no machinery is installed, and every action a tool checks is denied (gate.ErrDeniedUnconfigured).
func WithGateLogger ¶
WithGateLogger sets the logger that traces gate decisions (allow/deny/ask/grant). Pass the same logger the sessions use so the lines carry ws/chat/component; nil (the default) traces nothing.
func WithResultFilter ¶
func WithResultFilter(f agentkit.ResultFilter) Option
WithResultFilter installs f on every session's ctx (agentkit.WithResultFilter): every tool result, in this session and its sub-agents, passes through it before the model sees it.
func WithSession ¶
WithSession adds default agentkit session options — system prompt, timeout, token limit, tokenizer, store — applied when each Session/Once is BUILT.
Applied once is not the same as fixed once, and the difference matters here: an option installs whatever the session then consults. WithTimeout and WithStore install values, read as they are for the session's life. WithSystem installs a function that returns a constant, and WithSystemFunc one that need not — either way the session asks it at the start of every turn, so a consumer folding in mutable context is answered by the next turn rather than the next session.
Tools and skills do NOT come through here: they are the Runtime's own, see WithToolsFunc.
func WithSkillsFunc ¶
WithSkillsFunc is WithToolsFunc for the skill catalog.
func WithTools ¶
WithTools sets a fixed toolset. When gating is configured (WithGate), each call is gated on its name; a tool that self-checks a runtime target (a host) is checked on that too — classify its target axis, not its name, so the name check just passes.
func WithToolsFunc ¶
WithToolsFunc sets the toolset through a function the session evaluates once per turn, for a consumer whose available tools change while conversations are open. Gating still applies: it rides the session's ctx (gate.With installs the name check as agentkit's CallGuard), so tools that appear later are gated exactly like the ones that were there at the start.
func WithoutGate ¶
func WithoutGate() Option
WithoutGate runs the sessions ungated, on purpose: every action a tool checks is allowed (gate.Open). For tests, examples and consumers that gate on their own. WithGate wins over it.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime holds the shared configuration for a set of sessions.