Documentation
¶
Index ¶
- Constants
- Variables
- func AsyncManagerFromContext(ctx context.Context) (*asynccfg.Manager, bool)
- func AsyncNarratorRunnerFromContext(ctx context.Context) (asyncnarrator.LLMRunner, bool)
- func ConsumeAsyncWaitAfterStatus(ctx context.Context) []string
- func ExecuteToolStep(ctx context.Context, reg tool.Registry, step StepInfo, conv apiconv.Client) (out plan.ToolCall, span plan.CallSpan, retErr error)
- func IsChainMode(ctx context.Context) bool
- func IsQueued(err error) bool
- func PatchAsyncToolPersistence(ctx context.Context, conv apiconv.Client, rec *asynccfg.OperationRecord, ...)
- func PollAsyncOperation(ctx context.Context, manager *asynccfg.Manager, reg tool.Registry, ...)
- func SynthesizeToolStep(ctx context.Context, conv apiconv.Client, step StepInfo, toolResult string) error
- func WithAsyncCompletionObserver(ctx context.Context, observer AsyncCompletionObserver) context.Context
- func WithAsyncConversation(ctx context.Context, conv apiconv.Client) context.Context
- func WithAsyncManager(ctx context.Context, manager *asynccfg.Manager) context.Context
- func WithAsyncNarratorRunner(ctx context.Context, runner asyncnarrator.LLMRunner) context.Context
- func WithAsyncWaitState(ctx context.Context) context.Context
- func WithChainMode(ctx context.Context, enabled bool) context.Context
- func WithFeedNotifier(ctx context.Context, n FeedNotifier) context.Context
- func WithToolTimeout(ctx context.Context, d time.Duration) context.Context
- func WithWorkdir(ctx context.Context, workdir string) context.Context
- func WorkdirFromContext(ctx context.Context) (string, bool)
- type AsyncCompletionObserver
- type FeedNotifier
- type StepInfo
Constants ¶
const ( SystemDocumentTag = "system_doc" SystemDocumentMode = "system_document" ResourceDocumentTag = "resource_doc" )
Variables ¶
var ErrQueued = errToolQueued
ErrQueued is the exported signal that ExecuteToolStep returned because the tool was routed to the approval queue rather than executed. Callers that drive ExecuteToolStep from outside an agent turn (e.g. host-mediated MCP UI guest tool calls) use it via errors.Is to distinguish a queued result from a normal failure without inventing a parallel approval model.
Functions ¶
func AsyncManagerFromContext ¶
AsyncManagerFromContext returns the concrete async Manager attached to ctx. Returns (nil, false) if none is present.
Formerly returned an interface that mirrored a subset of *Manager's methods. The interface was unused as an abstraction — there was only one concrete implementation and no alternative backend — so callers now depend on the concrete type directly. Adding a new method to the Manager is a one-place change; nothing else has to track it.
func AsyncNarratorRunnerFromContext ¶ added in v0.1.8
func AsyncNarratorRunnerFromContext(ctx context.Context) (asyncnarrator.LLMRunner, bool)
func ExecuteToolStep ¶
func ExecuteToolStep(ctx context.Context, reg tool.Registry, step StepInfo, conv apiconv.Client) (out plan.ToolCall, span plan.CallSpan, retErr error)
ExecuteToolStep runs a tool via the registry, records transcript, and updates traces. Returns normalized plan.ToolCall, span and any combined error.
func IsChainMode ¶
IsChainMode reports whether current execution is internal chain execution.
func IsQueued ¶ added in v0.1.9
IsQueued reports whether err signals that a tool execution was routed to the approval queue. It hides whether the queued sentinel is wrapped one or more times by errors.Join from callers outside of toolexec.
func PatchAsyncToolPersistence ¶ added in v0.1.8
func PollAsyncOperation ¶
func PollAsyncOperation(ctx context.Context, manager *asynccfg.Manager, reg tool.Registry, cfg *asynccfg.Config, turn runtimerequestctx.TurnMeta, opID string, conv apiconv.Client)
PollAsyncOperation drives the background status-polling loop for an async op. The heavy lifting is split into pollerState setup + handleTimeoutIfExpired + executeStatusTick so the tick-path logic is unit-testable with synthetic state. This function itself is just the loop/ticker orchestrator plus the narration lifecycle.
func SynthesizeToolStep ¶
func SynthesizeToolStep(ctx context.Context, conv apiconv.Client, step StepInfo, toolResult string) error
SynthesizeToolStep persists a tool call using a precomputed result without invoking the actual tool. It mirrors ExecuteToolStep's persistence flow (messages, request/response payloads, status), setting status to "completed".
func WithAsyncCompletionObserver ¶ added in v0.1.13
func WithAsyncCompletionObserver(ctx context.Context, observer AsyncCompletionObserver) context.Context
func WithAsyncConversation ¶
func WithAsyncManager ¶
WithAsyncManager attaches an async Manager to ctx. Thin wrapper over async.WithManager — kept for backwards compatibility with existing call sites in the service layer. Prefer the canonical async.WithManager directly in new code.
func WithAsyncNarratorRunner ¶ added in v0.1.8
func WithChainMode ¶
WithChainMode marks tool/message execution context as internal chain execution.
func WithFeedNotifier ¶
func WithFeedNotifier(ctx context.Context, n FeedNotifier) context.Context
WithFeedNotifier attaches a FeedNotifier to the context.
func WithToolTimeout ¶
WithToolTimeout attaches a per-tool execution timeout to the context.
func WithWorkdir ¶
WithWorkdir attaches a resolved default workdir to the execution context.
Types ¶
type AsyncCompletionObserver ¶ added in v0.1.13
type AsyncCompletionObserver func(ctx context.Context, rec *asynccfg.OperationRecord)
func AsyncCompletionObserverFromContext ¶ added in v0.1.13
func AsyncCompletionObserverFromContext(ctx context.Context) (AsyncCompletionObserver, bool)
type FeedNotifier ¶
type FeedNotifier interface {
// NotifyToolCompleted is called with the tool name, request payload, and result after execution.
// Implementations should check if the tool matches any feed spec and emit SSE events.
NotifyToolCompleted(ctx context.Context, toolName string, request map[string]interface{}, result string)
}
FeedNotifier is called after a tool completes to check if a feed should be activated.