session

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext(ctx context.Context, s Session) context.Context

NewContext returns a new context with the given Session attached. Servers use this to inject session context before invoking tool handlers.

Types

type Session

type Session interface {
	// Logger returns a slog.Logger for structured logging during tool execution.
	Logger() *slog.Logger

	// Tracer returns the OpenTelemetry tracer for distributed tracing.
	// May return nil if no tracer was configured.
	Tracer() trace.Tracer
}

Session provides contextual services for tool execution, such as logging and distributed tracing. Use FromContext to retrieve the session injected by the server, or a safe no-op default if none is present.

func FromContext

func FromContext(ctx context.Context) Session

FromContext returns the Session injected into ctx for the current tool call. If no session is present (e.g. in unit tests that invoke Run directly), a no-op session backed by slog.Default() is returned.

Jump to

Keyboard shortcuts

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