Documentation
¶
Index ¶
- type ChainHooks
- func (c *ChainHooks) Add(hook Hooks)
- func (c *ChainHooks) OnAfterEnd(ctx context.Context, hc *HookContext, finalResult *types.AgentResult) error
- func (c *ChainHooks) OnAfterIteration(ctx context.Context, hc *HookContext, iteration int, result *types.AgentResult) error
- func (c *ChainHooks) OnAfterLLMCall(ctx context.Context, hc *HookContext, response *types.Message) error
- func (c *ChainHooks) OnAfterToolCall(ctx context.Context, hc *HookContext, toolName string, output interface{}, ...) error
- func (c *ChainHooks) OnBeforeIteration(ctx context.Context, hc *HookContext, iteration int) error
- func (c *ChainHooks) OnBeforeLLMCall(ctx context.Context, hc *HookContext, messages []types.Message) error
- func (c *ChainHooks) OnBeforeStart(ctx context.Context, hc *HookContext, input *types.AgentInput) error
- func (c *ChainHooks) OnBeforeToolCall(ctx context.Context, hc *HookContext, toolName string, ...) error
- func (c *ChainHooks) OnError(ctx context.Context, hc *HookContext, err error) error
- type HookContext
- type HookFunc
- type Hooks
- type HooksFunc
- func (h *HooksFunc) OnAfterEnd(ctx context.Context, hc *HookContext, finalResult *types.AgentResult) error
- func (h *HooksFunc) OnAfterIteration(ctx context.Context, hc *HookContext, iteration int, result *types.AgentResult) error
- func (h *HooksFunc) OnAfterLLMCall(ctx context.Context, hc *HookContext, response *types.Message) error
- func (h *HooksFunc) OnAfterToolCall(ctx context.Context, hc *HookContext, toolName string, output interface{}, ...) error
- func (h *HooksFunc) OnBeforeIteration(ctx context.Context, hc *HookContext, iteration int) error
- func (h *HooksFunc) OnBeforeLLMCall(ctx context.Context, hc *HookContext, messages []types.Message) error
- func (h *HooksFunc) OnBeforeStart(ctx context.Context, hc *HookContext, input *types.AgentInput) error
- func (h *HooksFunc) OnBeforeToolCall(ctx context.Context, hc *HookContext, toolName string, ...) error
- func (h *HooksFunc) OnError(ctx context.Context, hc *HookContext, err error) error
- type NoOpHooks
- func (NoOpHooks) OnAfterEnd(ctx context.Context, hc *HookContext, finalResult *types.AgentResult) error
- func (NoOpHooks) OnAfterIteration(ctx context.Context, hc *HookContext, iteration int, result *types.AgentResult) error
- func (NoOpHooks) OnAfterLLMCall(ctx context.Context, hc *HookContext, response *types.Message) error
- func (NoOpHooks) OnAfterToolCall(ctx context.Context, hc *HookContext, toolName string, output interface{}, ...) error
- func (NoOpHooks) OnBeforeIteration(ctx context.Context, hc *HookContext, iteration int) error
- func (NoOpHooks) OnBeforeLLMCall(ctx context.Context, hc *HookContext, messages []types.Message) error
- func (NoOpHooks) OnBeforeStart(ctx context.Context, hc *HookContext, input *types.AgentInput) error
- func (NoOpHooks) OnBeforeToolCall(ctx context.Context, hc *HookContext, toolName string, ...) error
- func (NoOpHooks) OnError(ctx context.Context, hc *HookContext, err error) error
- type Runner
- func (r *Runner) AfterEnd(finalResult *types.AgentResult) error
- func (r *Runner) AfterIteration(iteration int, result *types.AgentResult) error
- func (r *Runner) AfterLLMCall(response *types.Message) error
- func (r *Runner) AfterToolCall(toolName string, output interface{}, err error) error
- func (r *Runner) BeforeIteration(iteration int) error
- func (r *Runner) BeforeLLMCall(messages []types.Message) error
- func (r *Runner) BeforeStart(input *types.AgentInput) error
- func (r *Runner) BeforeToolCall(toolName string, input map[string]interface{}) error
- func (r *Runner) OnError(err error) error
- type TraceEvent
- type Tracer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChainHooks ¶
type ChainHooks struct {
// contains filtered or unexported fields
}
ChainHooks chains multiple hooks together
func NewChainHooks ¶
func NewChainHooks(hooks ...Hooks) *ChainHooks
func (*ChainHooks) Add ¶
func (c *ChainHooks) Add(hook Hooks)
func (*ChainHooks) OnAfterEnd ¶
func (c *ChainHooks) OnAfterEnd(ctx context.Context, hc *HookContext, finalResult *types.AgentResult) error
func (*ChainHooks) OnAfterIteration ¶
func (c *ChainHooks) OnAfterIteration(ctx context.Context, hc *HookContext, iteration int, result *types.AgentResult) error
func (*ChainHooks) OnAfterLLMCall ¶
func (c *ChainHooks) OnAfterLLMCall(ctx context.Context, hc *HookContext, response *types.Message) error
func (*ChainHooks) OnAfterToolCall ¶
func (c *ChainHooks) OnAfterToolCall(ctx context.Context, hc *HookContext, toolName string, output interface{}, err error) error
func (*ChainHooks) OnBeforeIteration ¶
func (c *ChainHooks) OnBeforeIteration(ctx context.Context, hc *HookContext, iteration int) error
func (*ChainHooks) OnBeforeLLMCall ¶
func (c *ChainHooks) OnBeforeLLMCall(ctx context.Context, hc *HookContext, messages []types.Message) error
func (*ChainHooks) OnBeforeStart ¶
func (c *ChainHooks) OnBeforeStart(ctx context.Context, hc *HookContext, input *types.AgentInput) error
func (*ChainHooks) OnBeforeToolCall ¶
func (c *ChainHooks) OnBeforeToolCall(ctx context.Context, hc *HookContext, toolName string, input map[string]interface{}) error
func (*ChainHooks) OnError ¶
func (c *ChainHooks) OnError(ctx context.Context, hc *HookContext, err error) error
type HookContext ¶
type HookContext struct {
AgentID string
SessionID string
Iteration int
Timestamp time.Time
Metadata map[string]interface{}
}
HookContext holds context information for hook execution
type HookFunc ¶
type HookFunc func(ctx context.Context, hc *HookContext, data interface{}) (interface{}, error)
HookFunc is a function that can be registered as a hook
type Hooks ¶
type Hooks interface {
// Before execution hooks
OnBeforeStart(ctx context.Context, hc *HookContext, input *types.AgentInput) error
OnBeforeIteration(ctx context.Context, hc *HookContext, iteration int) error
OnBeforeLLMCall(ctx context.Context, hc *HookContext, messages []types.Message) error
OnBeforeToolCall(ctx context.Context, hc *HookContext, toolName string, input map[string]interface{}) error
// After execution hooks
OnAfterToolCall(ctx context.Context, hc *HookContext, toolName string, output interface{}, err error) error
OnAfterLLMCall(ctx context.Context, hc *HookContext, response *types.Message) error
OnAfterIteration(ctx context.Context, hc *HookContext, iteration int, result *types.AgentResult) error
OnAfterEnd(ctx context.Context, hc *HookContext, finalResult *types.AgentResult) error
// Error hooks
OnError(ctx context.Context, hc *HookContext, err error) error
}
Hooks defines lifecycle hooks for agent execution
type HooksFunc ¶
type HooksFunc struct {
// contains filtered or unexported fields
}
HooksFunc is a functional adapter for Hooks
func NewHooksFunc ¶
func NewHooksFunc( onBeforeStart func(ctx context.Context, hc *HookContext, input *types.AgentInput) error, onBeforeIteration func(ctx context.Context, hc *HookContext, iteration int) error, onBeforeLLMCall func(ctx context.Context, hc *HookContext, messages []types.Message) error, onBeforeToolCall func(ctx context.Context, hc *HookContext, toolName string, input map[string]interface{}) error, onAfterToolCall func(ctx context.Context, hc *HookContext, toolName string, output interface{}, err error) error, onAfterLLMCall func(ctx context.Context, hc *HookContext, response *types.Message) error, onAfterIteration func(ctx context.Context, hc *HookContext, iteration int, result *types.AgentResult) error, onAfterEnd func(ctx context.Context, hc *HookContext, finalResult *types.AgentResult) error, onError func(ctx context.Context, hc *HookContext, err error) error, ) *HooksFunc
NewHooksFunc creates a new HooksFunc with the given functions
func (*HooksFunc) OnAfterEnd ¶
func (h *HooksFunc) OnAfterEnd(ctx context.Context, hc *HookContext, finalResult *types.AgentResult) error
func (*HooksFunc) OnAfterIteration ¶
func (h *HooksFunc) OnAfterIteration(ctx context.Context, hc *HookContext, iteration int, result *types.AgentResult) error
func (*HooksFunc) OnAfterLLMCall ¶
func (*HooksFunc) OnAfterToolCall ¶
func (*HooksFunc) OnBeforeIteration ¶
func (*HooksFunc) OnBeforeLLMCall ¶
func (*HooksFunc) OnBeforeStart ¶
func (h *HooksFunc) OnBeforeStart(ctx context.Context, hc *HookContext, input *types.AgentInput) error
func (*HooksFunc) OnBeforeToolCall ¶
type NoOpHooks ¶
type NoOpHooks struct{}
NoOpHooks is a no-op implementation of Hooks
func (NoOpHooks) OnAfterEnd ¶
func (NoOpHooks) OnAfterEnd(ctx context.Context, hc *HookContext, finalResult *types.AgentResult) error
func (NoOpHooks) OnAfterIteration ¶
func (NoOpHooks) OnAfterIteration(ctx context.Context, hc *HookContext, iteration int, result *types.AgentResult) error
func (NoOpHooks) OnAfterLLMCall ¶
func (NoOpHooks) OnAfterToolCall ¶
func (NoOpHooks) OnBeforeIteration ¶
func (NoOpHooks) OnBeforeLLMCall ¶
func (NoOpHooks) OnBeforeStart ¶
func (NoOpHooks) OnBeforeStart(ctx context.Context, hc *HookContext, input *types.AgentInput) error
func (NoOpHooks) OnBeforeToolCall ¶
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner is a helper to run hooks from AgentEngine
func (*Runner) AfterIteration ¶
func (r *Runner) AfterIteration(iteration int, result *types.AgentResult) error
func (*Runner) AfterToolCall ¶
func (*Runner) BeforeIteration ¶
func (*Runner) BeforeStart ¶
func (r *Runner) BeforeStart(input *types.AgentInput) error
func (*Runner) BeforeToolCall ¶
type TraceEvent ¶ added in v1.10.0
type TraceEvent struct {
Type string
Iteration *int
ThreadID string
ParentTraceID string
Payload any // must be json.Marshal-able
}
TraceEvent is the minimal event an engine recording point passes to a Tracer. The recorder fills envelope fields (seq/wall_time/trace_id/turn_id).
type Tracer ¶ added in v1.10.0
type Tracer interface {
// Record appends an event. Non-blocking: implementations must never block
// the caller (the engine's hot path); dropping is an acceptable degradation.
Record(ev TraceEvent)
// Flush best-effort persists queued events (called at turn_end so a
// completed turn is readable).
Flush() error
// Close drains, fsyncs, and closes. Idempotent.
Close() error
}
Tracer is the engine-held trace handle. nil = disabled (zero overhead: a pointer compare per recording point, no recorder object, no goroutine).
The interface lives in agent/hooks (not dino/trace) so agent/engine can hold it without importing dino (design §3.2④, review B1 precedent — agent/engine never imports dino). dino/trace.Recorder implements it; dino/factory injects it via SetTracer.