tracehook

package
v0.60.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2026 License: AGPL-3.0 Imports: 14 Imported by: 0

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

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

func New(enabled, recordIO bool) *Hook

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

func (h *Hook) Close() error

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) Name

func (*Hook) Name() string

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) Priority

func (*Hook) Priority() int

func (*Hook) Start added in v0.60.0

func (h *Hook) Start(ctx context.Context)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL