Documentation
¶
Index ¶
- Constants
- func EnsureJSONResponse(ctx context.Context, text string, target interface{}) error
- 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 SynthesizeToolStep(ctx context.Context, conv apiconv.Client, step StepInfo, toolResult string) error
- 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 FeedNotifier
- type StepInfo
Constants ¶
const ( SystemDocumentTag = "system_doc" SystemDocumentMode = "system_document" ResourceDocumentTag = "resource_doc" )
Variables ¶
This section is empty.
Functions ¶
func EnsureJSONResponse ¶
EnsureJSONResponse extracts and unmarshals valid JSON content from a given string into the target interface. It trims potential code block markers and identifies the JSON object or array to parse. Returns an error if no valid JSON is found or if unmarshalling fails.
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 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 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 FeedNotifier ¶
type FeedNotifier interface {
// NotifyToolCompleted is called with the tool name and result after execution.
// Implementations should check if the tool matches any feed spec and emit SSE events.
NotifyToolCompleted(ctx context.Context, toolName string, result string)
}
FeedNotifier is called after a tool completes to check if a feed should be activated.