core

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TriggerKindUser          = "user"
	TriggerKindHITLResume    = "hitl_resume"
	TriggerKindTestHarness   = "test_harness"
	TriggerKindMCPAuthResume = "mcp_auth_resume"
	TriggerKindFork          = "fork"
)

TriggerKind values for RunRequest / lifecycle event attribution (AF-REQ-02).

View Source
const CheckpointBeforeFinalAnswer = "before_final_answer"

CheckpointBeforeFinalAnswer pauses before the agent turn that produces the final answer (before any LLM call for that turn).

View Source
const StructuredOutputProtocol = "agentbase.structured_output/v1"

StructuredOutputProtocol is the machine-contract protocol for skill JSON blocks.

View Source
const TrustModeFullTrust = "full_trust"

TrustModeFullTrust is the run-scoped mode that skips static tool-approval pauses (ApprovalPause / ApprovalAlways). Dynamic ToolApprovalEvaluator decisions (for example MCP auth or mandatory user-input tools) still apply.

Variables

This section is empty.

Functions

func BuildLifecyclePayload added in v0.3.0

func BuildLifecyclePayload(typ EventType, payload json.RawMessage, corr EpisodeCorrelation) json.RawMessage

BuildLifecyclePayload returns a lifecycle event payload that stably includes Episode/Session correlation. Terminal events use RunTerminalPayload; other lifecycle events merge correlation into an object payload.

func BuildPausedOutcomePayload added in v0.3.0

func BuildPausedOutcomePayload(corr EpisodeCorrelation) json.RawMessage

BuildPausedOutcomePayload returns a terminal-shaped payload used when a run ends paused (SSE end parity). EventStore still emits EventRunPaused separately.

func BuildRunCompletedPayload added in v0.3.0

func BuildRunCompletedPayload(output json.RawMessage, corr EpisodeCorrelation, usage *RunUsage) json.RawMessage

BuildRunCompletedPayload builds an AF-REQ-03 terminal payload with optional usage.

func ContextWithEpisodeCorrelation added in v0.3.0

func ContextWithEpisodeCorrelation(ctx context.Context, corr EpisodeCorrelation) context.Context

ContextWithEpisodeCorrelation attaches episode/session correlation used by lifecycle event emission and EventStore indexing.

func ContextWithTrustMode added in v0.3.0

func ContextWithTrustMode(ctx context.Context, mode string) context.Context

ContextWithTrustMode attaches a run-scoped trust mode (for example "full_trust") so tool-approval paths in both autonomous and workflow runtimes can honor it.

func ContextWithWorkflowNode added in v0.2.1

func ContextWithWorkflowNode(ctx context.Context, nodeID string) context.Context

ContextWithWorkflowNode attaches the active workflow node ID to ctx for observability.

func DisplayLabel added in v0.3.0

func DisplayLabel(typ EventType) string

DisplayLabel returns a short human-readable label for product UI surfaces.

func EventCategory added in v0.3.0

func EventCategory(typ EventType) string

EventCategory returns a coarse product-facing category for an event type: tool, knowledge, skill, llm, memory, or run.

func EventFilterPresetDiagnostic added in v0.3.0

func EventFilterPresetDiagnostic(typ EventType) bool

EventFilterPresetDiagnostic keeps the full event stream, including internal MemoryRead / ContextPrepared signals used by Debug and export views.

func EventFilterPresetProductUI added in v0.3.0

func EventFilterPresetProductUI(typ EventType) bool

EventFilterPresetProductUI is a preset predicate for product-facing event streams. It hides high-frequency internal noise (memory reads and context preparation) while keeping tool/LLM/skill/run lifecycle signals visible.

Use with ShouldEmitToProductUI, or pass directly to an event filter:

if EventFilterPresetProductUI(event.Type) { publish(event) }

func FinalTextFromOutput added in v0.3.0

func FinalTextFromOutput(output json.RawMessage) string

FinalTextFromOutput extracts human-readable assistant text from a step-output envelope such as {"text":"..."} or a raw JSON string / plain bytes.

func FrameworkBuildFields added in v0.3.0

func FrameworkBuildFields() map[string]string

FrameworkBuildFields returns version/commit keys for RunStarted payloads.

func FrameworkCommit added in v0.3.0

func FrameworkCommit() string

FrameworkCommit returns the short VCS revision when available.

func FrameworkVersion added in v0.3.0

func FrameworkVersion() string

FrameworkVersion returns the module version from build info (ldflags / VCS).

func HasHumanCheckpoint added in v0.3.0

func HasHumanCheckpoint(checkpoints []string, name string) bool

HasHumanCheckpoint reports whether name appears in a checkpoint list.

func IdempotencyKeyFromContext added in v0.3.1

func IdempotencyKeyFromContext(ctx context.Context) string

IdempotencyKeyFromContext returns the idempotency key bound to ctx, if any.

func IsLifecycleEvent added in v0.3.0

func IsLifecycleEvent(typ EventType) bool

IsLifecycleEvent reports whether typ is a run-lifecycle event that should carry Episode/Session correlation in its payload.

func ShouldEmitToDiagnosticUI added in v0.3.0

func ShouldEmitToDiagnosticUI(typ EventType) bool

ShouldEmitToDiagnosticUI is an alias for EventFilterPresetDiagnostic (AF-REQ-05).

func ShouldEmitToProductUI added in v0.3.0

func ShouldEmitToProductUI(typ EventType) bool

ShouldEmitToProductUI reports whether an event type belongs on a product UI timeline. MemoryRead and ContextPrepared are treated as internal noise.

func ToolApprovalDenialReason added in v0.3.0

func ToolApprovalDenialReason(tool Tool) string

ToolApprovalDenialReason returns a non-empty reason when a tool call must be denied without pausing (for example approval=always with no human gate).

func ToolApprovalPauseRequired added in v0.3.0

func ToolApprovalPauseRequired(tool Tool) bool

ToolApprovalPauseRequired reports whether executing the tool should pause for human approval when a human gate is configured.

func TrustModeFromContext added in v0.3.0

func TrustModeFromContext(ctx context.Context) string

TrustModeFromContext returns the trust mode previously attached with ContextWithTrustMode, or "" when unset.

func WithIdempotencyKey added in v0.3.1

func WithIdempotencyKey(ctx context.Context, key string) context.Context

WithIdempotencyKey attaches the idempotency key of the current tool execution to ctx. The runtime injects one key per logical tool execution before invoking the executor; side-effecting tools should deduplicate their effects by this key (upsert, dedupe table, or an idempotency-aware API).

Stability contract: the key is unchanged when the same logical execution is replayed (recovery resume, node rerun via ResumeFromStep) and across the runtime's in-memory retries of one execution; a different logical execution (another node/iteration, or a new workflow node attempt) gets a different key. An empty key is never attached.

func WorkflowNodeFromContext added in v0.2.1

func WorkflowNodeFromContext(ctx context.Context) string

WorkflowNodeFromContext returns the workflow node ID bound to ctx, if any.

Types

type Agent

type Agent struct {
	Name         string            `json:"name"`
	Description  string            `json:"description,omitempty"`
	Role         string            `json:"role,omitempty"`
	Instructions string            `json:"instructions,omitempty"`
	LLM          string            `json:"llm,omitempty"`
	Memory       string            `json:"memory,omitempty"`
	Tools        []string          `json:"tools,omitempty"`
	Skills       []string          `json:"skills,omitempty"`
	SubAgents    []string          `json:"sub_agents,omitempty"`
	Policy       AgentPolicy       `json:"policy"`
	Metadata     map[string]string `json:"metadata,omitempty"`
	// CompletionRequirement, when set, requires a successful call to Tool
	// before the autonomous tool loop may finish with a final answer.
	CompletionRequirement *CompletionRequirement `json:"completion_requirement,omitempty"`
}

type AgentInput

type AgentInput struct {
	RunID   string          `json:"run_id"`
	Prompt  string          `json:"prompt,omitempty"`
	Context json.RawMessage `json:"context,omitempty"`
}

type AgentOutput

type AgentOutput struct {
	RunID  string          `json:"run_id"`
	Text   string          `json:"text,omitempty"`
	Raw    json.RawMessage `json:"raw,omitempty"`
	Events []Event         `json:"events,omitempty"`
}

type AgentPolicy

type AgentPolicy struct {
	MaxSteps         int             `json:"max_steps,omitempty"`
	Timeout          time.Duration   `json:"timeout,omitempty"`
	RetryLimit       int             `json:"retry_limit,omitempty"`
	OutputSchema     json.RawMessage `json:"output_schema,omitempty"`
	HumanCheckpoints []string        `json:"human_checkpoints,omitempty"`
}

type AgentRunner

type AgentRunner interface {
	Run(ctx context.Context, input AgentInput) (AgentOutput, error)
}

type ApprovalPolicy

type ApprovalPolicy string
const (
	ApprovalNever  ApprovalPolicy = "never"
	ApprovalRisky  ApprovalPolicy = "risky"
	ApprovalAlways ApprovalPolicy = "always"
	// ApprovalPause pauses the run at a human gate instead of denying the tool call.
	ApprovalPause ApprovalPolicy = "pause"
)

type CheckpointState

type CheckpointState struct {
	RunID   string          `json:"run_id"`
	Version int64           `json:"version"`
	NodeID  string          `json:"node_id"`
	Payload json.RawMessage `json:"payload,omitempty"`
}

type CompletionRecovery added in v0.3.0

type CompletionRecovery struct {
	MaxRetries  int   `json:"max_retries"`
	BaseDelayMS int64 `json:"base_delay_ms"`
	MaxDelayMS  int64 `json:"max_delay_ms"`
}

CompletionRecovery controls reminder retries with exponential backoff when the required completion tool was not called.

type CompletionRequirement added in v0.3.0

type CompletionRequirement struct {
	Tool     string              `json:"tool"`
	Reminder string              `json:"reminder"`
	Recovery *CompletionRecovery `json:"recovery,omitempty"`
}

CompletionRequirement declares that the agent must call a specific tool before ending its turn (orchestrated worker pattern from grok-build).

type Decision

type Decision string

Decision is the human decision made at a human-in-the-loop checkpoint.

const (
	DecisionApprove Decision = "approve"
	DecisionReject  Decision = "reject"
	DecisionAmend   Decision = "amend"
)

func (Decision) String

func (d Decision) String() string

func (*Decision) UnmarshalText

func (d *Decision) UnmarshalText(b []byte) error

func (Decision) Valid

func (d Decision) Valid() bool

type EpisodeCorrelation added in v0.3.0

type EpisodeCorrelation struct {
	EpisodeID   string
	TriggerKind string
	SessionID   string
}

EpisodeCorrelation identifies a platform Episode (one QA test run) that may span multiple Runs or HITL resumes. thread_id remains reserved for Fork.

func EpisodeCorrelationFromContext added in v0.3.0

func EpisodeCorrelationFromContext(ctx context.Context) EpisodeCorrelation

EpisodeCorrelationFromContext returns correlation previously attached with ContextWithEpisodeCorrelation, or a zero value when unset.

func (EpisodeCorrelation) Empty added in v0.3.0

func (c EpisodeCorrelation) Empty() bool

Empty reports whether no correlation fields are set.

type Event

type Event struct {
	Type         EventType       `json:"type"`
	RunID        string          `json:"run_id"`
	TenantID     string          `json:"tenant_id,omitempty"`
	ScenarioName string          `json:"scenario_name,omitempty"`
	EpisodeID    string          `json:"episode_id,omitempty"`
	SessionID    string          `json:"session_id,omitempty"`
	TriggerKind  string          `json:"trigger_kind,omitempty"`
	Timestamp    time.Time       `json:"timestamp"`
	TraceID      string          `json:"trace_id,omitempty"`
	SpanID       string          `json:"span_id,omitempty"`
	ParentSpanID string          `json:"parent_span_id,omitempty"`
	Category     string          `json:"category,omitempty"`
	DisplayLabel string          `json:"display_label,omitempty"`
	Payload      json.RawMessage `json:"payload,omitempty"`
}

type EventFilterPreset added in v0.3.0

type EventFilterPreset string

EventFilterPreset names a read-side event view for StreamRun / ListEvents. Storage always keeps the full event stream; presets only project it.

const (
	// EventFilterProductUI hides high-frequency internal noise for chat UIs.
	EventFilterProductUI EventFilterPreset = "product_ui"
	// EventFilterDiagnostic keeps internal events (MemoryRead, ContextPrepared, …)
	// for Debug / export / SSE trace views.
	EventFilterDiagnostic EventFilterPreset = "diagnostic"
)

func NormalizeEventFilterPreset added in v0.3.0

func NormalizeEventFilterPreset(preset EventFilterPreset) EventFilterPreset

NormalizeEventFilterPreset maps empty to diagnostic; unknown values stay as-is so callers can reject them explicitly via ParseEventFilterPreset.

func ParseEventFilterPreset added in v0.3.0

func ParseEventFilterPreset(value string) (EventFilterPreset, error)

ParseEventFilterPreset accepts API values. Empty means diagnostic (full stream).

func (EventFilterPreset) Allows added in v0.3.0

func (p EventFilterPreset) Allows(typ EventType) bool

Allows reports whether typ is included in this preset's view.

type EventSink

type EventSink interface {
	Emit(ctx context.Context, event Event) error
}

type EventSinkFunc

type EventSinkFunc func(ctx context.Context, event Event) error

func (EventSinkFunc) Emit

func (f EventSinkFunc) Emit(ctx context.Context, event Event) error

type EventType

type EventType string
const (
	EventRunStarted                EventType = "RunStarted"
	EventRunCompleted              EventType = "RunCompleted"
	EventRunFailed                 EventType = "RunFailed"
	EventRunCancelled              EventType = "RunCancelled"
	EventRunPaused                 EventType = "RunPaused"
	EventRunResumed                EventType = "RunResumed"
	EventStepStarted               EventType = "StepStarted"
	EventStepCompleted             EventType = "StepCompleted"
	EventStepFailed                EventType = "StepFailed"
	EventSubgraphStarted           EventType = "SubgraphStarted"
	EventSubgraphCompleted         EventType = "SubgraphCompleted"
	EventToolCalled                EventType = "ToolCalled"
	EventToolReturned              EventType = "ToolReturned"
	EventToolDenied                EventType = "ToolDenied"
	EventLLMCalled                 EventType = "LLMCalled"
	EventLLMReturned               EventType = "LLMReturned"
	EventLLMTokenUsage             EventType = "LLMTokenUsage"
	EventHumanGateOpened           EventType = "HumanGateOpened"
	EventHumanGateDecided          EventType = "HumanGateDecided"
	EventHumanGateExpired          EventType = "HumanGateExpired"
	EventMemoryRead                EventType = "MemoryRead"
	EventMemoryWrite               EventType = "MemoryWrite"
	EventMemoryPromoted            EventType = "MemoryPromoted"
	EventMemoryDemoted             EventType = "MemoryDemoted"
	EventMemoryEvicted             EventType = "MemoryEvicted"
	EventContextPrepared           EventType = "ContextPrepared"
	EventContextIncomplete         EventType = "ContextIncomplete"
	EventSkillApplied              EventType = "SkillApplied"
	EventCompletionRecovery        EventType = "CompletionRecovery"
	EventCompletionRequirementFail EventType = "CompletionRequirementFail"
	EventInterjectionDrained       EventType = "InterjectionDrained"
	EventHITLDenyBreakerTripped    EventType = "HITLDenyBreakerTripped"
	EventTurnStopContinued         EventType = "TurnStopContinued"
)

type HumanGate

type HumanGate interface {
	Pause(ctx context.Context, state CheckpointState) (token string, err error)
	Resume(ctx context.Context, token string, decision Decision, amendment json.RawMessage) error
}

type HumanInLoopPolicy

type HumanInLoopPolicy struct {
	Enabled     bool     `json:"enabled"`
	Checkpoints []string `json:"checkpoints,omitempty"`
}

type KnowledgeCollection added in v0.1.5

type KnowledgeCollection struct {
	Name         string   `json:"name"`
	Description  string   `json:"description,omitempty"`
	Namespace    string   `json:"namespace"`
	Tool         string   `json:"tool,omitempty"`
	EmbedProfile string   `json:"embed_profile,omitempty"`
	SearchMode   string   `json:"search_mode,omitempty"`
	Agents       []string `json:"agents,omitempty"`
	TenantScoped bool     `json:"tenant_scoped,omitempty"`
}

KnowledgeCollection binds agents to a retriever tool and vector namespace.

type KnowledgeConfig added in v0.1.5

type KnowledgeConfig struct {
	Collections []KnowledgeCollection `json:"collections,omitempty"`
}

KnowledgeConfig groups knowledge collections for scenario-level RAG binding.

type LLMProfileRef

type LLMProfileRef struct {
	Provider            string               `json:"provider"`
	Model               string               `json:"model"`
	Endpoint            string               `json:"endpoint,omitempty"`
	APIKeyEnv           string               `json:"api_key_env,omitempty"`
	ContextWindowTokens int                  `json:"context_window_tokens,omitempty"`
	MaxOutputTokens     int                  `json:"max_output_tokens,omitempty"`
	Temperature         *float32             `json:"temperature,omitempty"`
	TopP                *float32             `json:"top_p,omitempty"`
	Timeout             time.Duration        `json:"timeout,omitempty"`
	Thinking            llm.ThinkingConfig   `json:"thinking,omitempty"`
	ReasoningEffort     string               `json:"reasoning_effort,omitempty"`
	Context             contextwindow.Policy `json:"context,omitempty"`
	ExtraBody           map[string]any       `json:"extra_body,omitempty"`
	Capabilities        []string             `json:"capabilities,omitempty"`
	Metadata            map[string]string    `json:"metadata,omitempty"`
}

type LifecycleCorrelationPayload added in v0.3.0

type LifecycleCorrelationPayload struct {
	EpisodeID   string `json:"episode_id,omitempty"`
	TriggerKind string `json:"trigger_kind,omitempty"`
	SessionID   string `json:"session_id,omitempty"`
}

LifecycleCorrelationPayload is written into non-terminal lifecycle event payloads so Episode/Session identifiers are stably available on the wire.

type MCPConfig added in v0.1.5

type MCPConfig struct {
	Servers []MCPServer `json:"servers,omitempty"`
}

type MCPServer added in v0.1.5

type MCPServer struct {
	Name       string            `json:"name"`
	Transport  string            `json:"transport"` // stdio | http
	Command    []string          `json:"command,omitempty"`
	URL        string            `json:"url,omitempty"`
	ToolPrefix string            `json:"tool_prefix,omitempty"`
	Metadata   map[string]string `json:"metadata,omitempty"`
}

MCPServer declares an MCP server wired into scenario tools at Framework build time. Metadata["mcp_protocol_mode"] selects "legacy" (default, 2025-11-25 initialize/session) or "modern" (2026-07-28 stateless requests).

type MemoryRef

type MemoryRef struct {
	Type      string              `json:"type"`
	Scope     string              `json:"scope"`
	Namespace string              `json:"namespace,omitempty"`
	Metadata  map[string]string   `json:"metadata,omitempty"`
	Tiers     *MemoryTierSettings `json:"tiers,omitempty"`
}

type MemoryTierColdSummarySettings added in v0.2.0

type MemoryTierColdSummarySettings struct {
	Enabled         bool   `json:"enabled,omitempty"`
	MinBytes        int64  `json:"min_bytes,omitempty"`
	MaxSummaryChars int    `json:"max_summary_chars,omitempty"`
	SummaryProfile  string `json:"summary_profile,omitempty"`
}

type MemoryTierRecallBudget added in v0.1.9

type MemoryTierRecallBudget struct {
	Total int `json:"total,omitempty"`
	Hot   int `json:"hot,omitempty"`
	Warm  int `json:"warm,omitempty"`
	Cold  int `json:"cold,omitempty"`
}

type MemoryTierRecallWeights added in v0.1.9

type MemoryTierRecallWeights struct {
	Semantic   float64 `json:"semantic,omitempty"`
	Recency    float64 `json:"recency,omitempty"`
	Importance float64 `json:"importance,omitempty"`
}

type MemoryTierSettings added in v0.1.9

type MemoryTierSettings struct {
	Enabled       bool                           `json:"enabled,omitempty"`
	HotCapacity   int                            `json:"hot_capacity,omitempty"`
	WarmCapacity  int                            `json:"warm_capacity,omitempty"`
	ColdCapacity  int                            `json:"cold_capacity,omitempty"`
	HotTTL        string                         `json:"hot_ttl,omitempty"`
	WarmTTL       string                         `json:"warm_ttl,omitempty"`
	PromoteAccess int                            `json:"promote_access,omitempty"`
	DemoteIdle    string                         `json:"demote_idle,omitempty"`
	RecallBudget  MemoryTierRecallBudget         `json:"recall_budget,omitempty"`
	RecallWeights MemoryTierRecallWeights        `json:"recall_weights,omitempty"`
	ColdSummary   *MemoryTierColdSummarySettings `json:"cold_summary,omitempty"`
}

MemoryTierSettings configures hot/warm/cold tiered recall for a memory reference.

type NamedToolApprovalEvaluator added in v0.3.0

type NamedToolApprovalEvaluator interface {
	ToolApprovalEvaluator
	Name() string
}

NamedToolApprovalEvaluator is an optional extension that exposes a stable evaluator name for RunPaused observability (AF-REQ-04).

type Orchestration

type Orchestration struct {
	Mode        OrchestrationMode   `json:"mode"`
	Workflow    *Workflow           `json:"workflow,omitempty"`
	Workflows   map[string]Workflow `json:"workflows,omitempty"`
	MaxParallel int                 `json:"max_parallel,omitempty"`
	HumanInLoop HumanInLoopPolicy   `json:"human_in_loop"`
	Planning    PlanningPolicy      `json:"planning,omitempty"`
}

type OrchestrationMode

type OrchestrationMode string
const (
	OrchestrationAutonomous    OrchestrationMode = "autonomous"
	OrchestrationFixedWorkflow OrchestrationMode = "fixed_workflow"
	OrchestrationHybrid        OrchestrationMode = "hybrid"
)

type PauseTokenDecoder added in v0.3.0

type PauseTokenDecoder interface {
	RunIDFromPauseToken(token string) (string, error)
}

PauseTokenDecoder is an optional HumanGate extension for deployments that do not use HMAC-signed pause tokens. ResumeAndContinue uses it to resolve the run ID before calling Resume.

type PlanningPolicy

type PlanningPolicy struct {
	Enabled  bool   `json:"enabled,omitempty"`
	Agent    string `json:"agent,omitempty"`
	MaxSteps int    `json:"max_steps,omitempty"`
	// Execute tracks plan step completion in run state during the tool loop.
	Execute bool `json:"execute,omitempty"`
	// Replan retries planning when execute mode stalls before max steps.
	ReplanOnFailure bool `json:"replan_on_failure,omitempty"`
	// AfterWorkflow enables planning during hybrid phase-2 after workflow outputs
	// are hydrated into run context.
	AfterWorkflow bool `json:"after_workflow,omitempty"`
}

type PromptFragment

type PromptFragment struct {
	Name    string `json:"name,omitempty"`
	Content string `json:"content"`
}

type RetryPolicy

type RetryPolicy struct {
	MaxAttempts int `json:"max_attempts,omitempty"`
}

type RunTerminalPayload added in v0.3.0

type RunTerminalPayload struct {
	Status                string          `json:"status"`
	OutcomeKind           string          `json:"outcome_kind,omitempty"`
	FinalText             string          `json:"final_text,omitempty"`
	StructuredOutput      json.RawMessage `json:"structured_output,omitempty"`
	StructuredOutputError string          `json:"structured_output_error,omitempty"`
	Output                json.RawMessage `json:"output,omitempty"`
	Error                 string          `json:"error,omitempty"`
	Usage                 *RunUsage       `json:"usage,omitempty"`
	EpisodeID             string          `json:"episode_id,omitempty"`
	TriggerKind           string          `json:"trigger_kind,omitempty"`
	SessionID             string          `json:"session_id,omitempty"`
}

RunTerminalPayload is the structured lifecycle payload for terminal run events (RunCompleted / RunFailed / RunCancelled). Output holds the prior raw final-answer bytes when present.

type RunUsage added in v0.3.0

type RunUsage struct {
	InputTokens  int `json:"input_tokens,omitempty"`
	OutputTokens int `json:"output_tokens,omitempty"`
	TotalTokens  int `json:"total_tokens,omitempty"`
}

RunUsage is token usage attached to terminal lifecycle payloads (AF-REQ-03).

type RuntimePolicy

type RuntimePolicy struct {
	Timeout             time.Duration `json:"timeout,omitempty"`
	MaxSteps            int           `json:"max_steps,omitempty"`
	MaxRetries          int           `json:"max_retries,omitempty"`
	MaxParallel         int           `json:"max_parallel,omitempty"`
	StepOutputThreshold int64         `json:"step_output_threshold,omitempty"`
	// ValidateToolInput is retained for source/configuration compatibility.
	// Tool input validation is now enabled by default.
	ValidateToolInput bool `json:"validate_tool_input,omitempty"`
	// DisableToolInputValidation explicitly restores advisory-only schemas.
	// Production scenarios should leave this false.
	DisableToolInputValidation bool `json:"disable_tool_input_validation,omitempty"`
	// DoomLoopLimit, when > 0, denies a tool call that repeats the same
	// canonical input this many times within one autonomous run (including
	// the current attempt). Zero disables the check.
	DoomLoopLimit int `json:"doom_loop_limit,omitempty"`
	// HITLDenyLimit, when > 0, fails the run after this many consecutive
	// approval denials (soft deny or cached deny). Orthogonal to DoomLoopLimit.
	HITLDenyLimit int               `json:"hitl_deny_limit,omitempty"`
	Secrets       map[string]string `json:"secrets,omitempty"`
}

type Scenario

type Scenario struct {
	Name          string                   `json:"name"`
	Description   string                   `json:"description,omitempty"`
	LLMs          map[string]LLMProfileRef `json:"llms,omitempty"`
	Memories      map[string]MemoryRef     `json:"memories,omitempty"`
	Knowledge     KnowledgeConfig          `json:"knowledge,omitempty"`
	MCP           MCPConfig                `json:"mcp,omitempty"`
	Tools         map[string]Tool          `json:"tools,omitempty"`
	Skills        map[string]Skill         `json:"skills,omitempty"`
	Agents        map[string]Agent         `json:"agents,omitempty"`
	Triggers      []Trigger                `json:"triggers,omitempty"`
	Orchestration Orchestration            `json:"orchestration"`
	Runtime       RuntimePolicy            `json:"runtime"`
}

type SideEffectLevel

type SideEffectLevel string
const (
	SideEffectNone      SideEffectLevel = "none"
	SideEffectRead      SideEffectLevel = "read"
	SideEffectWrite     SideEffectLevel = "write"
	SideEffectExternal  SideEffectLevel = "external"
	SideEffectDangerous SideEffectLevel = "dangerous"
)

type Skill

type Skill struct {
	Name             string            `json:"name"`
	Description      string            `json:"description,omitempty"`
	Version          string            `json:"version,omitempty"`
	Kind             SkillKind         `json:"kind,omitempty"`
	CompatibleAgents []string          `json:"compatible_agents,omitempty"`
	PromptFragments  []PromptFragment  `json:"prompt_fragments,omitempty"`
	AgentPolicy      AgentPolicy       `json:"agent_policy,omitempty"`
	ToolPolicies     []SkillToolPolicy `json:"tool_policies,omitempty"`
	Workflow         *Workflow         `json:"workflow,omitempty"`
	Metadata         map[string]string `json:"metadata,omitempty"`
}

type SkillKind added in v0.3.0

type SkillKind string

SkillKind distinguishes prompt-fragment skills from script skills.

const (
	SkillKindPrompt SkillKind = "prompt"
	SkillKindScript SkillKind = "script"
)

type SkillToolPolicy

type SkillToolPolicy struct {
	Tool       string          `json:"tool"`
	Approval   ApprovalPolicy  `json:"approval,omitempty"`
	SideEffect SideEffectLevel `json:"side_effect,omitempty"`
	RateCap    int             `json:"rate_cap,omitempty"`
}

type StructuredOutputExtract added in v0.3.0

type StructuredOutputExtract struct {
	// Block is the last fenced JSON object whose protocol matches StructuredOutputProtocol.
	Block map[string]any
	// OutcomeKind is structured_output | plain_text | error_only | paused.
	OutcomeKind string
	// Error is set when a protocol-claiming fence failed to parse.
	Error string
}

StructuredOutputExtract is the result of scanning assistant text for the agentbase.structured_output/v1 machine contract.

func ExtractStructuredOutput added in v0.3.0

func ExtractStructuredOutput(content string) StructuredOutputExtract

ExtractStructuredOutput finds the last ```json fence whose parsed object has protocol=agentbase.structured_output/v1. It does not guess from prose.

type Tool

type Tool struct {
	Name         string          `json:"name"`
	Description  string          `json:"description,omitempty"`
	Type         string          `json:"type"`
	InputSchema  json.RawMessage `json:"input_schema,omitempty"`
	OutputSchema json.RawMessage `json:"output_schema,omitempty"`
	SideEffect   SideEffectLevel `json:"side_effect,omitempty"`
	Approval     ApprovalPolicy  `json:"approval,omitempty"`
	LLM          string          `json:"llm,omitempty"`
	RateCap      int             `json:"rate_cap,omitempty"`
	// Timeout bounds a single tool execution attempt. Zero (the default)
	// disables the per-tool timeout, so the call is only bounded by the
	// run/agent context deadline, preserving the previous behavior.
	Timeout  time.Duration     `json:"timeout,omitempty"`
	Metadata map[string]string `json:"metadata,omitempty"`
}

type ToolApprovalEvaluator added in v0.3.0

type ToolApprovalEvaluator interface {
	PauseRequired(ctx context.Context, runID string, tool Tool, call llm.ToolCall) (bool, error)
}

ToolApprovalEvaluator allows hosts to require human approval for tool calls beyond static scenario Tool.Approval policies (for example MCP invoke proxies that delegate to remote tools discovered at runtime).

type ToolCall

type ToolCall struct {
	RunID string `json:"run_id"`
	Agent string `json:"agent,omitempty"`
	Tool  string `json:"tool"`
	// ToolCallID is the LLM-issued identifier for this call (e.g.
	// llm.ToolCall.ID), when the call originated from a tool-calling LLM
	// turn. Executors that must correlate calls by tool_call_id (rather
	// than by name alone) can use this field.
	ToolCallID string            `json:"tool_call_id,omitempty"`
	Input      json.RawMessage   `json:"input,omitempty"`
	Metadata   map[string]string `json:"metadata,omitempty"`
}

type ToolExecutor

type ToolExecutor interface {
	Execute(ctx context.Context, call ToolCall) (ToolResult, error)
}

type ToolResolver

type ToolResolver interface {
	ResolveTool(ctx context.Context, tool Tool) (ToolExecutor, error)
}

ToolResolver resolves a declared tool manifest to an executor at call time. Resolvers are useful for heavy or tenant-scoped tools whose clients should not be initialized during scenario loading.

type ToolResolverFunc

type ToolResolverFunc func(ctx context.Context, tool Tool) (ToolExecutor, error)

func (ToolResolverFunc) ResolveTool

func (fn ToolResolverFunc) ResolveTool(ctx context.Context, tool Tool) (ToolExecutor, error)

type ToolResult

type ToolResult struct {
	Tool   string          `json:"tool"`
	Output json.RawMessage `json:"output,omitempty"`
	Error  string          `json:"error,omitempty"`
}

type ToolStreamEvent added in v0.3.0

type ToolStreamEvent struct {
	Progress json.RawMessage `json:"progress,omitempty"`
	Result   *ToolResult     `json:"result,omitempty"`
	Error    string          `json:"error,omitempty"`
	Terminal bool            `json:"terminal,omitempty"`
}

ToolStreamEvent is one item in a tool progress stream. Shape: zero or more Progress-only events, then exactly one Terminal (Result set) or a failed Terminal (Error set). Matching grok-build's Progress* → Terminal invariant.

type ToolStreamer added in v0.3.0

type ToolStreamer interface {
	ToolExecutor
	ExecuteStream(ctx context.Context, call ToolCall) (<-chan ToolStreamEvent, error)
}

ToolStreamer is an optional ToolExecutor extension that emits progress before the terminal result. Runtimes that do not care about progress continue to call Execute only.

type Trigger added in v0.1.2

type Trigger struct {
	Event         string `json:"event"`
	Agent         string `json:"agent,omitempty"`
	PromptPath    string `json:"prompt_path,omitempty"`
	ContextPath   string `json:"context_path,omitempty"`
	RunIDPath     string `json:"run_id_path,omitempty"`
	DefaultPrompt string `json:"default_prompt,omitempty"`
}

Trigger maps an external event type to a run request template.

type TurnStopDecision added in v0.3.0

type TurnStopDecision struct {
	Continue           bool
	ContinuationPrompt string
}

TurnStopDecision lets a host veto turn completion (Codex stop-hooks style). When Continue is true and ContinuationPrompt is non-empty, the runtime appends the prompt as a user message and samples again.

type TurnStopHook added in v0.3.0

type TurnStopHook func(ctx context.Context, info TurnStopInfo) (TurnStopDecision, error)

TurnStopHook is an optional host callback after a candidate final answer.

type TurnStopInfo added in v0.3.0

type TurnStopInfo struct {
	RunID  string
	Agent  string
	Answer string
}

TurnStopInfo is passed to TurnStopHook after the model produces a final answer (no tool calls) and CompletionRequirement is satisfied.

type Workflow

type Workflow struct {
	Nodes []WorkflowNode `json:"nodes,omitempty"`
	Edges []WorkflowEdge `json:"edges,omitempty"`
}

type WorkflowEdge

type WorkflowEdge struct {
	From      string `json:"from"`
	To        string `json:"to"`
	Condition string `json:"condition,omitempty"`
}

type WorkflowNode

type WorkflowNode struct {
	ID        string           `json:"id"`
	Kind      WorkflowNodeKind `json:"kind"`
	Ref       string           `json:"ref,omitempty"`
	Input     json.RawMessage  `json:"input,omitempty"`
	DependsOn []string         `json:"depends_on,omitempty"`
	Condition string           `json:"condition,omitempty"`
	Interrupt bool             `json:"interrupt,omitempty"`
	Retry     RetryPolicy      `json:"retry"`
}

type WorkflowNodeKind

type WorkflowNodeKind string
const (
	NodeAgent         WorkflowNodeKind = "agent"
	NodeTool          WorkflowNodeKind = "tool"
	NodeSkill         WorkflowNodeKind = "skill"
	NodeHumanGate     WorkflowNodeKind = "human_gate"
	NodeTransform     WorkflowNodeKind = "transform"
	NodeParallelGroup WorkflowNodeKind = "parallel_group"
	NodeLoop          WorkflowNodeKind = "loop"
	NodeQueryRouter   WorkflowNodeKind = "query_router"
	NodeRAGGrade      WorkflowNodeKind = "rag_grade"
	NodeSupervisor    WorkflowNodeKind = "supervisor"
	NodeSubgraph      WorkflowNodeKind = "subgraph"
	NodeMap           WorkflowNodeKind = "map"
)

Jump to

Keyboard shortcuts

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