wire

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAgent

func NewAgent(gw *gateway.LLMGateway, model protocol.ModelDescriptor, instructions string, settings Settings, tools []loop.AgentTool) *agent.Agent

NewAgent builds a pith agent wired to the given gateway, model, and tools.

func NewStreamFn

func NewStreamFn(gw *gateway.LLMGateway, settings Settings) loop.StreamFn

NewStreamFn returns a StreamFn that delegates to the gateway and merges settings.

func RunCtx added in v0.2.0

func RunCtx(holder *RunScopeHolder) context.Context

RunCtx returns the active run context from holder, or context.Background().

func RunWithHooks added in v0.2.0

func RunWithHooks(holder *RunScopeHolder, toolName, callID string, params map[string]any, run func() (string, error)) (string, error)

RunWithHooks runs BeforeToolCall, invoke, and AfterToolCall for a tool handler.

func ToAgentTools

func ToAgentTools(typed []TypedTool, holder *RunScopeHolder) []loop.AgentTool

ToAgentTools converts typed tools into loop.AgentTool values.

Types

type HookSet added in v0.2.0

type HookSet struct {
	BeforeToolCall func(sessionID, runID, toolName, callID string, args map[string]any) (block bool, reason string, err error)
	AfterToolCall  func(sessionID, runID, toolName, callID string, args map[string]any, result string, resultErr error) (override string, err error)
}

HookSet holds SDK-level hooks for tool call lifecycle.

type RunScope

type RunScope struct {
	Ctx       context.Context
	Local     any
	SessionID string
	RunID     string
	Hooks     *HookSet
}

RunScope holds per-run context passed to tool handlers.

type RunScopeHolder

type RunScopeHolder struct {
	// contains filtered or unexported fields
}

RunScopeHolder stores the active run scope for tool execution.

func NewRunScopeHolder

func NewRunScopeHolder() *RunScopeHolder

NewRunScopeHolder creates a holder for per-run tool context.

func (*RunScopeHolder) Clear

func (h *RunScopeHolder) Clear()

Clear removes the active run scope after a run completes.

func (*RunScopeHolder) Current

func (h *RunScopeHolder) Current() *RunScope

Current returns the active run scope, or nil if none is set.

func (*RunScopeHolder) Set

func (h *RunScopeHolder) Set(ctx context.Context, local any, sessionID, runID string, hooks *HookSet)

Set activates a run scope for the current Session.Run call.

type Settings

type Settings struct {
	Temperature *float64
	MaxTokens   *int
}

Settings holds optional generation parameters applied at the gateway boundary.

type TypedTool

type TypedTool struct {
	Name        string
	Description string
	Parameters  any
	Handler     func(holder *RunScopeHolder, callID string, params map[string]any) (string, error)
}

TypedTool is a tool definition with a handler that receives the active run scope.

Jump to

Keyboard shortcuts

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