Documentation
¶
Overview ¶
Package agent runs the conversation loop: send the history, stream the reply, execute whatever tools the model called, feed the results back, and repeat until the model ends its turn.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SystemPrompt ¶
SystemPrompt assembles tomo's identity plus whatever memory and skills indexes the caller has. Kept small on purpose: memory topics and skill bodies load on demand, not here. A non-empty persona sets a specialist worker's role on top of the shared identity.
Types ¶
type Agent ¶
type Agent struct {
Provider provider.Provider
Model string
System string
Tools *tool.Registry
Gate Gate
MaxTokens int
MaxTurns int
}
Agent binds a provider, a toolset, and the loop knobs.
func (*Agent) Turn ¶
func (a *Agent) Turn(ctx context.Context, history []provider.Message, user provider.Message, sink Sink) ([]provider.Message, error)
Turn runs one user turn to completion and returns every message it generated, the user message first, so the caller can persist them. On error the messages so far come back too, so a partial turn is not lost.
type Gate ¶
type Gate interface {
// Allow decides whether a call may run, blocking for approval if needed.
// When it returns false the reason is fed back to the model as the tool
// result, so a refusal becomes something the model can work around.
Allow(ctx context.Context, name string, class tool.Class, input json.RawMessage) (bool, string)
// Ingested is called after a tool ran so the gate can track taint.
Ingested(class tool.Class, isErr bool)
}
Gate is the policy check the loop consults before and after every tool run. A nil Gate means allow everything, which is only appropriate for tests.