Documentation
¶
Overview ¶
Package tracehook is the core agent trace hook: it logs LLM, tool, and memory activity via slog and, when OTel tracing is enabled, records the session/turn/LLM/tool/memory span hierarchy. It is always part of the agent runtime hook set — it is not a user-managed plugin. Span export is owned by the global tracer provider set up in package observability; this hook only produces spans, resolving the global tracer lazily at span-start time.
Index ¶
- type Hook
- func (h *Hook) Close() error
- func (*Hook) Name() string
- func (h *Hook) OnPostAgentCall(ctx context.Context, hctx *hooks.PostAgentCallContext)
- func (h *Hook) OnPostLLMCall(ctx context.Context, hctx *hooks.PostLLMCallContext)
- func (h *Hook) OnPostMemoryCall(ctx context.Context, hctx *hooks.PostMemoryCallContext)
- func (h *Hook) OnPostToolCall(ctx context.Context, hctx *hooks.PostToolCallContext)
- func (h *Hook) OnPreAgentCall(ctx context.Context, hctx *hooks.PreAgentCallContext)
- func (h *Hook) OnPreLLMCall(ctx context.Context, hctx *hooks.PreLLMCallContext) (hooks.PreLLMCallResult, error)
- func (h *Hook) OnPreMemoryCall(ctx context.Context, hctx *hooks.PreMemoryCallContext) (hooks.PreMemoryCallResult, error)
- func (h *Hook) OnPreToolCall(ctx context.Context, hctx *hooks.PreToolCallContext) (hooks.PreToolCallResult, error)
- func (*Hook) Priority() int
- func (h *Hook) Start(ctx context.Context)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Hook ¶
type Hook struct {
// contains filtered or unexported fields
}
Hook logs LLM, tool, and memory call details via slog, and records OTel spans when tracing is enabled.
func New ¶
New builds the core trace hook. enabled mirrors whether the global tracer provider was installed (see observability.Init); recordIO is the OTEL_STELLA_RECORD_TOOL_IO opt-in. Both are passed by the caller so the hook and the global provider share a single source of truth instead of each reading the environment. Span export is handled by that global provider.
func (*Hook) Close ¶
Close ends any in-flight session spans and stops the reaper. It does not shut down the tracer provider — that lifecycle is owned by package observability.
func (*Hook) OnPostAgentCall ¶
func (h *Hook) OnPostAgentCall(ctx context.Context, hctx *hooks.PostAgentCallContext)
func (*Hook) OnPostLLMCall ¶
func (h *Hook) OnPostLLMCall(ctx context.Context, hctx *hooks.PostLLMCallContext)
func (*Hook) OnPostMemoryCall ¶
func (h *Hook) OnPostMemoryCall(ctx context.Context, hctx *hooks.PostMemoryCallContext)
func (*Hook) OnPostToolCall ¶
func (h *Hook) OnPostToolCall(ctx context.Context, hctx *hooks.PostToolCallContext)
func (*Hook) OnPreAgentCall ¶
func (h *Hook) OnPreAgentCall(ctx context.Context, hctx *hooks.PreAgentCallContext)
func (*Hook) OnPreLLMCall ¶
func (h *Hook) OnPreLLMCall(ctx context.Context, hctx *hooks.PreLLMCallContext) (hooks.PreLLMCallResult, error)
func (*Hook) OnPreMemoryCall ¶
func (h *Hook) OnPreMemoryCall(ctx context.Context, hctx *hooks.PreMemoryCallContext) (hooks.PreMemoryCallResult, error)
func (*Hook) OnPreToolCall ¶
func (h *Hook) OnPreToolCall(ctx context.Context, hctx *hooks.PreToolCallContext) (hooks.PreToolCallResult, error)
func (*Hook) Start ¶ added in v0.60.0
Start launches the idle-session reaper. It is a no-op when tracing is disabled and is idempotent. The composition root calls it once after New with the daemon lifecycle context, so the reaper exits on ctx cancellation; Close also stops it during the reverse-Close shutdown phase.