Documentation
¶
Index ¶
- Constants
- Variables
- func RetrieverNameFromToolName(toolName string) (name string, ok bool)
- func RetrieverToolDisplayName(retrieverKey string) string
- func RetrieverToolName(retrieverName string) string
- func RetrieverToolParamQueryValue(args map[string]any) (string, error)
- type A2ASkillFilter
- type A2ASkillSpec
- type AgentMode
- type AgentRunOptions
- type AgentRunResult
- type AgentStreamOptions
- type AgentTelemetry
- type AgentToolExecutionMode
- type ApprovalHandler
- type ApprovalRequest
- type ApprovalRequestName
- type ApprovalSender
- type ApprovalStatus
- type ConversationOptions
- type FinishReason
- type JSONSchema
- type LLMReasoning
- type LLMSampling
- type LLMUsage
- type MCPLoopback
- type MCPStdio
- type MCPStreamableHTTP
- type MCPToolFilter
- type MCPTransportConfig
- type MCPTransportType
- type OTLPProtocol
- type RetrieverMode
- type RunStatus
- type RunTelemetry
- type StorageTelemetry
- type SubAgentDelegationApprovalRequestValue
- type ToolApprovalRequestValue
- type ToolKind
- type ToolKindProvider
- type ToolSpec
- type ToolTelemetry
Constants ¶
const ( DefaultMCPTimeout = 30 * time.Second DefaultMCPRetryAttempts = 1 )
Default MCP settings applied when fields are zero.
const ( MemoryToolParamText = "text" MemoryToolParamKind = "kind" )
Memory tool JSON parameter names.
const ( // Agent API — emitted by Agent.Run (including non-blocking Done/Get usage). MetricRunStarted = "agent.run.started" MetricRunCompleted = "agent.run.completed" MetricRunFailed = "agent.run.failed" MetricRunDurationMs = "agent.run.duration_ms" // Agent API — emitted by Agent.Stream (dispatch phase only). MetricStreamStarted = "agent.stream.started" MetricStreamDispatched = "agent.stream.dispatched" MetricStreamFailed = "agent.stream.failed" MetricStreamDurationMs = "agent.stream.duration_ms" // Agent API — reconnect and control-plane (GetAgentRun / GetAgentStream / Cancel / Events). MetricRunReconnectStarted = "agent.run.reconnect.started" MetricRunReconnectFailed = "agent.run.reconnect.failed" MetricRunReconnectCompleted = "agent.run.reconnect.completed" MetricStreamReconnectStarted = "agent.stream.reconnect.started" MetricStreamReconnectFailed = "agent.stream.reconnect.failed" MetricStreamReconnectCompleted = "agent.stream.reconnect.completed" MetricStreamEventsStarted = "agent.stream.events.started" MetricStreamEventsFailed = "agent.stream.events.failed" MetricStreamEventsSubscribed = "agent.stream.events.subscribed" MetricStreamEventsDurationMs = "agent.stream.events.duration_ms" MetricRunCancelStarted = "agent.run.cancel.started" MetricRunCancelFailed = "agent.run.cancel.failed" MetricRunCancelCompleted = "agent.run.cancel.completed" MetricStreamCancelStarted = "agent.stream.cancel.started" MetricStreamCancelFailed = "agent.stream.cancel.failed" MetricStreamCancelCompleted = "agent.stream.cancel.completed" // Runtime — emitted per LLM Generate / GenerateStream call. MetricLLMCallStarted = "agent.llm.call.started" MetricLLMCallCompleted = "agent.llm.call.completed" MetricLLMCallFailed = "agent.llm.call.failed" // Runtime — token usage, recorded when provider returns non-nil LLMUsage. MetricLLMTokensInput = "agent.llm.tokens.input" MetricLLMTokensOutput = "agent.llm.tokens.output" // Runtime — LLM wall-clock latency. MetricLLMLatencyMs = "agent.llm.latency_ms" // Runtime — emitted per tool.Execute call. MetricToolCallStarted = "agent.tool.call.started" MetricToolCallCompleted = "agent.tool.call.completed" MetricToolCallFailed = "agent.tool.call.failed" // Runtime — tool wall-clock latency. MetricToolLatencyMs = "agent.tool.latency_ms" // Runtime — emitted per retriever.Search call (prefetch and hybrid modes). MetricRetrieverCallStarted = "agent.retriever.call.started" MetricRetrieverCallCompleted = "agent.retriever.call.completed" MetricRetrieverCallFailed = "agent.retriever.call.failed" // Runtime — retriever search wall-clock latency. MetricRetrieverLatencyMs = "agent.retriever.latency_ms" // Runtime — emitted per memory.Load (recall) call. MetricMemoryRecallStarted = "agent.memory.recall.started" MetricMemoryRecallCompleted = "agent.memory.recall.completed" MetricMemoryRecallFailed = "agent.memory.recall.failed" // Runtime — memory recall wall-clock latency. MetricMemoryRecallLatencyMs = "agent.memory.recall.latency_ms" // Runtime — emitted per memory.Store call. MetricMemoryStoreStarted = "agent.memory.store.started" MetricMemoryStoreCompleted = "agent.memory.store.completed" MetricMemoryStoreFailed = "agent.memory.store.failed" // Runtime — memory store wall-clock latency. MetricMemoryStoreLatencyMs = "agent.memory.store.latency_ms" // Runtime — semantic dedup lookup before memory.Store (Load for upsert decision). MetricMemoryDedupStarted = "agent.memory.dedup.started" MetricMemoryDedupCompleted = "agent.memory.dedup.completed" MetricMemoryDedupFailed = "agent.memory.dedup.failed" MetricMemoryDedupLatencyMs = "agent.memory.dedup.latency_ms" // Runtime — run-end memory extraction (StoreMode always). MetricMemoryExtractStarted = "agent.memory.extract.started" MetricMemoryExtractCompleted = "agent.memory.extract.completed" MetricMemoryExtractFailed = "agent.memory.extract.failed" MetricMemoryExtractLatencyMs = "agent.memory.extract.latency_ms" // Attribute keys used on both metrics and spans. MetricAttrModel = "model" MetricAttrProvider = "provider" MetricAttrTool = "tool" MetricAttrRetriever = "retriever" MetricAttrMemoryKind = "memory.kind" // MetricAttrMemoryDedup is "upsert" when an existing record is updated, else "append". MetricAttrMemoryDedup = "memory.dedup" )
Metric name constants for the agent SDK. All runtime implementations emit these names so dashboards and alerts work regardless of the underlying execution engine.
Counters: call Metrics.IncrementCounter. Histograms: call Metrics.RecordHistogram. Latency histograms are in milliseconds; token histograms are raw counts.
const ( // DefaultOTLPExportTimeout is the per-export call deadline. DefaultOTLPExportTimeout = 30 * time.Second // DefaultOTLPBatchTimeout is the maximum delay before a trace span batch is flushed. DefaultOTLPBatchTimeout = 5 * time.Second // DefaultOTLPMetricsInterval is how often the metrics periodic reader pushes to the collector. DefaultOTLPMetricsInterval = 60 * time.Second )
Default OTLP timing used when the caller does not override them. Shared between pkg/observability (where they are the BuildConfig fallbacks) and pkg/agent (where they are applied silently when ObservabilityConfig is used).
const ( DefaultTopK = 5 DefaultMinScore = 0.75 DefaultScheme = "http" DefaultContentField = "content" DefaultSourceField = "source" )
Default retriever settings.
const DefaultA2ATimeout = 30 * time.Second
DefaultA2ATimeout is the per-operation deadline applied when no timeout is configured. Shared between github.com/agenticenv/agent-sdk-go/pkg/a2a/client.BuildConfig and github.com/agenticenv/agent-sdk-go/pkg/agent.agentConfigFingerprint.
const MaxApprovalTimeout = 31 * 24 * time.Hour
maxApprovalTimeout caps how long a single approval wait may last in the run.
const MemoryEntryFormat = "[%d] %s\n(kind: %s, score: %.2f)\n\n"
MemoryEntryFormat is the printf format used to render a single [interfaces.MemoryEntry] for LLM context. Arguments: 1-based index (int), text (string), kind (string), score (float32).
const RetrieverDocFormat = "[%d] %s\n(source: %s, score: %.2f)\n\n"
RetrieverDocFormat is the printf format used to render a single [interfaces.Document] for LLM context. Arguments: 1-based index (int), content (string), source (string), score (float64).
const RetrieverToolNamePrefix = "retriever_"
RetrieverToolNamePrefix is the tool name prefix for agentic retriever tools (see RetrieverToolName).
const RetrieverToolParamQuery = "query"
RetrieverToolParamQuery is the tool/JSON parameter name for the query sent to a retriever.
const SaveMemoryToolName = "save_memory"
SaveMemoryToolName is the LLM-facing tool name for on-demand long-term memory store.
Variables ¶
var ErrApprovalAlreadyResolved = errors.New("runtime: approval already resolved")
ErrApprovalAlreadyResolved is returned by [StreamHandle.Approve] (and the deprecated Runtime.OnApproval) when the approval token refers to an activity task that has already been completed (approved or rejected). This happens when a reconnecting subscriber replays a CUSTOM approval event that was resolved while the subscriber was disconnected. Callers should treat this as informational: the run is already advancing.
var ErrRunAlreadyCompleted = errors.New("runtime: run already completed, stream unavailable")
ErrRunAlreadyCompleted is returned when the target run has already finished (completed, failed, timed out, or cancelled). Callers should read conversation history from the memory/conversation store instead of reconnecting. Also returned by [RunHandle.Cancel] / [StreamHandle.Cancel] when the run is already terminal (nothing left to cancel).
var ErrRunNotFound = errors.New("runtime: run not found (unknown runID)")
ErrRunNotFound is returned when a runID is not recognised by the runtime (e.g. the workflow was never started or has already been purged from history), or when the runtime cannot recover a handle for that runID (e.g. LocalRuntime [Runtime.GetRunHandle] — no durable run tracking across process restarts).
var ErrStreamAlreadyConsumed = errors.New("runtime: stream events already consumed on this handle")
ErrStreamAlreadyConsumed is returned by [StreamHandle.Events] when this handle has already handed out its in-process event channel (LocalRuntime: one Events call per stream handle).
var ErrStreamNotFound = errors.New("runtime: stream not found (unknown runID)")
ErrStreamNotFound is returned when a stream runID is not recognised by the runtime, or when the runtime cannot recover a [StreamHandle] for that runID (e.g. LocalRuntime [Runtime.GetStreamHandle] — no durable stream tracking across process restarts).
var ErrStreamOffsetNotSupported = errors.New("runtime: stream offset not supported by this runtime")
ErrStreamOffsetNotSupported is returned when the runtime cannot replay at a non-zero fromOffset (e.g. LocalRuntime — no durable event log today).
var ErrTemporalDialTimeout = errors.New("temporal: dial timeout — could not connect to Temporal server")
ErrTemporalDialTimeout is returned when the Temporal server connection cannot be established within the configured dial timeout.
var ErrTemporalNamespaceCheckTimeout = errors.New("temporal: namespace check timeout — namespace may not exist or server is overloaded")
ErrTemporalNamespaceCheckTimeout is returned when the namespace existence check does not complete within the configured timeout after connecting to the Temporal server.
Functions ¶
func RetrieverNameFromToolName ¶ added in v0.2.3
RetrieverNameFromToolName extracts the retriever name from a retriever tool name. Returns ok false when toolName does not use RetrieverToolNamePrefix or the key is empty.
func RetrieverToolDisplayName ¶ added in v0.2.3
RetrieverToolDisplayName returns the human-readable tool name for a retriever key.
func RetrieverToolName ¶ added in v0.2.3
RetrieverToolName returns the registered tool name for a retriever key (e.g. "kb" → "retriever_kb"). Returns "" when retrieverKey is empty after trim.
Types ¶
type A2ASkillFilter ¶ added in v0.1.9
type A2ASkillFilter struct {
// AllowSkills is an allow-list of skill IDs. Only listed skills are registered.
AllowSkills []string
// BlockSkills is a block-list of skill IDs. Listed skills are excluded.
BlockSkills []string
}
A2ASkillFilter restricts which skills from [interfaces.A2AClient.ListSkills] are exposed as tools (exact skill-ID match). Set either AllowSkills or BlockSkills, not both. A2ASkillFilter.Validate checks mutual exclusivity (call from config build, e.g. pkg/a2a/client.BuildConfig). A2ASkillFilter.Apply filters skill specs and assumes Validate already passed for non-empty filters.
func (A2ASkillFilter) Apply ¶ added in v0.1.9
func (f A2ASkillFilter) Apply(skills []A2ASkillSpec) []A2ASkillSpec
Apply returns the subset of skills that pass the filter. When neither list is set every skill is returned unchanged. Assumes at most one of AllowSkills / BlockSkills is non-empty (i.e. [Validate] already passed).
func (A2ASkillFilter) Validate ¶ added in v0.1.9
func (f A2ASkillFilter) Validate() error
Validate returns an error if both AllowSkills and BlockSkills are set.
type A2ASkillSpec ¶ added in v0.1.9
type A2ASkillSpec struct {
// ID is the stable machine-readable identifier for the skill (used as tool name).
ID string `json:"id"`
// Name is the human-readable display name.
Name string `json:"name,omitempty"`
// Description explains when and how to invoke this skill; shown to the LLM.
Description string `json:"description,omitempty"`
// Tags are optional categorisation labels.
Tags []string `json:"tags,omitempty"`
// InputModes overrides the agent-level default input modes for this skill.
InputModes []string `json:"inputModes,omitempty"`
// OutputModes overrides the agent-level default output modes for this skill.
OutputModes []string `json:"outputModes,omitempty"`
// Examples are optional illustrative prompt strings shown to the LLM.
Examples []string `json:"examples,omitempty"`
}
A2ASkillSpec describes one invocable skill advertised by an A2A agent. Used by the agent host to expose the remote skill as a Tool to the LLM. Canonical definition here; aliased in github.com/agenticenv/agent-sdk-go/pkg/interfaces.
type AgentMode ¶ added in v0.1.3
type AgentMode string
AgentMode distinguishes how the agent is driven: human-in-the-loop versus self-directed runs. The string value is stable for configuration and fingerprints (see pkg/agent.WithAgentMode).
const ( // AgentModeInteractive is the default: the agent expects user turns, approvals, or other // interactive signals between steps when the product requires them. AgentModeInteractive AgentMode = "interactive" // AgentModeAutonomous indicates a run where the agent proceeds without blocking on user input // for each step (subject to tool policy and limits). AgentModeAutonomous AgentMode = "autonomous" )
type AgentRunOptions ¶ added in v0.2.0
type AgentRunOptions struct {
// ConversationOptions selects a conversation session for this call.
// Required when the agent was configured with WithConversation; must be nil otherwise.
ConversationOptions *ConversationOptions `json:"conversation_options,omitempty"`
}
AgentRunOptions holds per-call options passed to [Agent.Run]. A nil pointer is valid and means "no options" (no conversation, default behaviour). Add new per-call knobs here as nested option structs; keep agent-level settings on [agentConfig].
type AgentRunResult ¶ added in v0.1.6
type AgentRunResult struct {
Content string `json:"content"`
AgentName string `json:"agent_name"`
Model string `json:"model"`
Metadata map[string]any `json:"metadata"`
// RunID identifies this run for correlation and (on Temporal) GetAgentRun / GetAgentStream.
// Populated for completed [Agent.Run] results; for live streams prefer the
// runID returned synchronously from [Agent.Stream] / [AgentRun.ID] / [AgentStream.ID].
RunID string `json:"run_id,omitempty"`
// Usage is the sum of token usage across all LLM calls in this run (when reported by the provider).
// Usage acts as the historical root for aggregated token counters.
LLMUsage *LLMUsage `json:"llm_usage,omitempty"`
// Telemetry contains the strongly typed nested metrics domain payload.
Telemetry *AgentTelemetry `json:"telemetry,omitempty"`
}
AgentRunResult is the structured result of a completed run (content, model, metadata).
type AgentStreamOptions ¶ added in v0.3.0
type AgentStreamOptions struct {
// ConversationOptions selects a conversation session for this streaming call.
// Required when the agent was configured with WithConversation; must be nil otherwise.
ConversationOptions *ConversationOptions `json:"conversation_options,omitempty"`
// DisableTokenStreaming, when true, instructs the LLM to produce a single complete
// response rather than a token-by-token stream. All other AG-UI events (lifecycle,
// tool calls, CUSTOM events) are still emitted. Default false = stream tokens.
DisableTokenStreaming bool `json:"disable_token_streaming,omitempty"`
}
AgentStreamOptions holds per-call options passed to [Agent.Stream]. A nil pointer is valid and means "no options" (LLM token streaming on, no conversation). Add new streaming-specific knobs here; keep agent-level settings on [agentConfig].
type AgentTelemetry ¶ added in v0.2.2
type AgentTelemetry struct {
// Run captures the orchestration lifecycle metrics for the run.
Run RunTelemetry `json:"run"`
// Tools tracks tool invocation counts and breakdowns for the run.
Tools ToolTelemetry `json:"tools"`
// Storage tracks data storage and retrieval operations for the run.
Storage StorageTelemetry `json:"storage"`
}
AgentTelemetry is the unified container for operational insights across a single agent run, run lifecycle, tool calls, and storage operations.
type AgentToolExecutionMode ¶ added in v0.1.7
type AgentToolExecutionMode string
ToolExecutionMode specifies how tools are executed in parallel or sequentially.
const ( // AgentToolExecutionModeParallel specifies that tools are executed in parallel. AgentToolExecutionModeParallel AgentToolExecutionMode = "parallel" // AgentToolExecutionModeSequential specifies that tools are executed sequentially. AgentToolExecutionModeSequential AgentToolExecutionMode = "sequential" )
type ApprovalHandler ¶
type ApprovalHandler func(ctx context.Context, req *ApprovalRequest)
ApprovalHandler is called when a tool needs approval (Run with WithApprovalHandler). req.Respond is always set; call req.Respond(Approved) or Rejected when ready.
type ApprovalRequest ¶
type ApprovalRequest struct {
Name ApprovalRequestName `json:"name,omitempty"`
Value any `json:"value,omitempty"`
Respond ApprovalSender `json:"-"`
}
ApprovalRequest is one pending approval callback. Name + Value match CUSTOM semantics; Value is a ToolApprovalRequestValue or SubAgentDelegationApprovalRequestValue. Set Respond before invoking the handler.
type ApprovalRequestName ¶ added in v0.1.6
type ApprovalRequestName string
ApprovalRequestName classifies the approval payload.
const ( ApprovalRequestNameTool ApprovalRequestName = "tool_approval" ApprovalRequestNameSubAgent ApprovalRequestName = "sub_agent_delegation" )
type ApprovalSender ¶
type ApprovalSender func(status ApprovalStatus) error
ApprovalSender sends an approval result. Call once per request. Safe for concurrent use— multiple approvals may be pending when tools run in parallel.
type ApprovalStatus ¶
type ApprovalStatus string
const ( ApprovalStatusNone ApprovalStatus = "NONE" ApprovalStatusPending ApprovalStatus = "PENDING" ApprovalStatusApproved ApprovalStatus = "APPROVED" ApprovalStatusRejected ApprovalStatus = "REJECTED" ApprovalStatusUnavailable ApprovalStatus = "UNAVAILABLE" // ApprovalStatusTimedOut means the approval activity hit StartToCloseTimeout (ApprovalTimeout). // The tool is not executed; the agent loop continues. ApprovalStatusTimedOut ApprovalStatus = "TIMED_OUT" )
type ConversationOptions ¶ added in v0.2.0
type ConversationOptions struct {
ID string
}
ConversationOptions identifies a conversation session for one call. ID must be a non-empty, stable string that is the same across all turns of a session (e.g. a user or chat ID). The agent loads history for this ID before the LLM call and persists the new messages after it completes.
type FinishReason ¶ added in v0.2.2
type FinishReason string
const ( // FinishReasonComplete indicates that the agent run completed normally. FinishReasonComplete FinishReason = "complete" // FinishReasonMaxIterations indicates that the agent run completed because the maximum number of iterations was reached. FinishReasonMaxIterations FinishReason = "max_iterations" )
type JSONSchema ¶ added in v0.1.2
func (JSONSchema) MarshalJSON ¶ added in v0.1.2
func (s JSONSchema) MarshalJSON() ([]byte, error)
type LLMReasoning ¶ added in v0.1.2
type LLMReasoning struct {
// Enabled requests reasoning/thinking where the provider supports it.
// Anthropic: if true and BudgetTokens is 0, uses the minimum extended-thinking budget (1024 tokens).
// OpenAI: does not infer reasoning_effort from Enabled alone (standard models reject that param).
// Gemini: contributes to turning on thought output with IncludeThoughts.
Enabled bool
// Effort is a generic reasoning intensity: "none", "minimal", "low", "medium", "high", "xhigh".
// OpenAI: sent as reasoning_effort only when non-empty; use only with reasoning-capable models.
// Gemini: mapped to ThinkingLevel when recognized (low/medium/high/minimal), unless BudgetTokens > 0.
// Anthropic: not used (use Enabled and BudgetTokens for extended thinking).
Effort string
// BudgetTokens is the token budget for internal reasoning / extended thinking.
// Anthropic: extended thinking; must be >= 1024 when non-zero (values below are clamped).
// Gemini: ThinkingBudget. If non-zero, Effort is not mapped to ThinkingLevel (API allows only one).
// OpenAI: not used.
BudgetTokens int
}
LLMReasoning configures reasoning/thinking in a provider-agnostic way. Each LLM client maps these fields to its API; fields that do not apply are ignored.
type LLMSampling ¶
type LLMSampling struct {
Temperature *float64 // 0-2 OpenAI, 0-1 Anthropic; also Gemini
MaxTokens int // 0 = provider default
TopP *float64 // 0-1; OpenAI and Gemini (not Anthropic)
TopK *int // Anthropic only
// Reasoning: optional generic reasoning/thinking; mapped per provider.
Reasoning *LLMReasoning
}
LLMSampling holds per-agent LLM sampling overrides. nil/0 = provider default. One LLM client can serve multiple agents with different sampling.
type LLMUsage ¶ added in v0.1.2
type LLMUsage struct {
PromptTokens int64 `json:"prompt_tokens,omitempty"`
CompletionTokens int64 `json:"completion_tokens,omitempty"`
TotalTokens int64 `json:"total_tokens,omitempty"`
CachedPromptTokens int64 `json:"cached_prompt_tokens,omitempty"`
ReasoningTokens int64 `json:"reasoning_tokens,omitempty"`
}
LLMUsage reports token counts from the provider for one completion. Values are best-effort: some fields may be zero when the API does not return them.
type MCPLoopback ¶ added in v0.1.2
type MCPLoopback struct {
Transport any
}
MCPLoopback is test-only wiring: it holds a pre-built protocol transport as a dynamic value. External users should use pkg/mcp transport types (MCPStdio, MCPStreamableHTTP). MCPLoopback is not re-exported from pkg/mcp.
func (MCPLoopback) Kind ¶ added in v0.1.2
func (MCPLoopback) Kind() MCPTransportType
func (MCPLoopback) Validate ¶ added in v0.1.2
func (lb MCPLoopback) Validate() error
Validate ensures Transport is a non-nil sdkmcp.Transport.
type MCPStdio ¶ added in v0.1.2
MCPStdio runs an MCP server as a subprocess (stdio).
func (MCPStdio) Kind ¶ added in v0.1.2
func (MCPStdio) Kind() MCPTransportType
type MCPStreamableHTTP ¶ added in v0.1.2
type MCPStreamableHTTP struct {
URL string
// Token is a static bearer token when OAuthClientCreds is not used for auth.
Token string
// OAuthClientCreds configures OAuth2 client-credentials; when any OAuth field is set, Token must be empty and id/secret/token_url are required together.
OAuthClientCreds *clientcredentials.Config
Headers map[string]string
SkipTLSVerify bool
}
MCPStreamableHTTP uses the streamable HTTP MCP transport.
Optional static bearer Token, or OAuthClientCreds for OAuth2 client credentials. Token and active OAuth client-credentials must not both be set; omit both for URL-only access (use Headers for custom auth headers such as API keys).
func (MCPStreamableHTTP) Kind ¶ added in v0.1.2
func (MCPStreamableHTTP) Kind() MCPTransportType
func (MCPStreamableHTTP) Validate ¶ added in v0.1.2
func (h MCPStreamableHTTP) Validate() error
Validate checks URL, rejects mixing Token with a populated OAuth client-credentials config, and rejects incomplete OAuth when any OAuth field is set.
type MCPToolFilter ¶ added in v0.1.2
MCPToolFilter restricts which tools from Discover are registered (exact name match). Set either AllowTools (allow-list) or BlockTools (block-list), not both. MCPToolFilter.Validate checks constraints (call from config build, e.g. github.com/agenticenv/agent-sdk-go/pkg/mcp/client.BuildConfig). MCPToolFilter.Apply filters tool specs and assumes Validate already passed for non-empty filters.
func (MCPToolFilter) Apply ¶ added in v0.1.2
func (f MCPToolFilter) Apply(specs []ToolSpec) []ToolSpec
Apply returns filtered specs when AllowTools or BlockTools is non-empty; otherwise returns specs unchanged. For any non-empty list, the receiver must already satisfy MCPToolFilter.Validate (mutually exclusive lists).
func (MCPToolFilter) Validate ¶ added in v0.1.2
func (f MCPToolFilter) Validate() error
Validate returns an error if both AllowTools and BlockTools are set.
type MCPTransportConfig ¶ added in v0.1.2
type MCPTransportConfig interface {
// Kind returns a stable transport id ("stdio", "streamable_http") for logging and routing.
Kind() MCPTransportType
// Validate checks the transport is usable before connect (the default MCP client calls this from NewClient).
Validate() error
}
MCPTransportConfig describes how to reach one MCP server. Concrete types are MCPStdio, MCPStreamableHTTP, and MCPLoopback (tests).
type MCPTransportType ¶ added in v0.1.2
type MCPTransportType string
const ( MCPTransportTypeStdio MCPTransportType = "stdio" MCPTransportTypeStreamableHTTP MCPTransportType = "streamable_http" )
const MCPTransportTypeLoopback MCPTransportType = "loopback"
MCPTransportTypeLoopback is only for in-repo tests (see MCPLoopback). Not exposed on the public agent API.
type OTLPProtocol ¶ added in v0.1.10
type OTLPProtocol string
OTLPProtocol selects the wire format used by OTLP trace and metrics exporters. The string value is stable and used in fingerprints — do not change existing values.
const ( // OTLPProtocolGRPC exports telemetry over gRPC. This is the default and is supported // by virtually all OpenTelemetry collectors. OTLPProtocolGRPC OTLPProtocol = "grpc" // OTLPProtocolHTTP exports telemetry over HTTP/protobuf. Use when gRPC is blocked // by a firewall or proxy that only passes HTTP/1.1 traffic. OTLPProtocolHTTP OTLPProtocol = "http" )
type RetrieverMode ¶ added in v0.1.11
type RetrieverMode string
RetrieverMode selects how registered retrievers participate in agent runs. String values are stable for configuration (see pkg/agent.WithRetrieverMode).
const ( // RetrieverModeAgentic is the default: the agent decides when to query retrievers (e.g. via tools). RetrieverModeAgentic RetrieverMode = "agentic" // RetrieverModePrefetch runs retrievers before the first LLM call and injects context up front. RetrieverModePrefetch RetrieverMode = "prefetch" // RetrieverModeHybrid combines prefetch with agentic retrieval during the run. RetrieverModeHybrid RetrieverMode = "hybrid" )
type RunStatus ¶ added in v0.3.0
type RunStatus string
const ( StatusPending RunStatus = "pending" // Scheduled or queued StatusRunning RunStatus = "running" // Actively executing StatusCompleted RunStatus = "completed" // Finished successfully StatusFailed RunStatus = "failed" // Encountered an error StatusCancelled RunStatus = "cancelled" // Stopped via context/Cancel() )
func (RunStatus) IsCancelled ¶ added in v0.3.0
func (RunStatus) IsTerminal ¶ added in v0.3.0
Helper methods attached to the RunStatus type itself
type RunTelemetry ¶ added in v0.2.2
type RunTelemetry struct {
// StartedAt tracks the start time of the agent run.
StartedAt time.Time `json:"started_at"`
// CompletedAt tracks the completion time of the agent run.
CompletedAt time.Time `json:"completed_at"`
// TotalLLMCalls counts how many LLM calls were made during the run.
// Each iteration counts as one call regardless of how many Temporal retries it took.
TotalLLMCalls int64 `json:"total_llm_calls"`
// LLMRetryCount is the total number of Temporal activity retries across all LLM calls in
// this run. A value of 0 means every LLM activity succeeded on its first attempt.
// Temporal also exposes per-activity retry counts natively in its metrics and workflow history.
LLMRetryCount int64 `json:"llm_retry_count,omitempty"`
// FinishReason explains how the run concluded. See FinishReason for possible values.
FinishReason FinishReason `json:"finish_reason"`
}
RunTelemetry captures the orchestration lifecycle metrics for a single agent run.
type StorageTelemetry ¶ added in v0.2.2
type StorageTelemetry struct {
// Retriever — RAG searches (prefetch/agentic/hybrid), zero if not configured.
TotalRetrieverSearches int64 `json:"total_retriever_searches"`
FailedRetrieverSearches int64 `json:"failed_retriever_searches"`
// Breakdown by mode — zero if mode not used.
PrefetchSearches int64 `json:"prefetch_searches,omitempty"`
AgenticSearches int64 `json:"agentic_searches,omitempty"`
// Memory — long-term recall/store operations, zero if not configured.
TotalMemoryRecalls int64 `json:"total_memory_recalls,omitempty"`
FailedMemoryRecalls int64 `json:"failed_memory_recalls,omitempty"`
TotalMemoryStores int64 `json:"total_memory_stores,omitempty"`
FailedMemoryStores int64 `json:"failed_memory_stores,omitempty"`
}
StorageTelemetry tracks RAG retrieval operations across prefetch, agentic, and hybrid modes. All fields are zero when no retriever is configured.
type SubAgentDelegationApprovalRequestValue ¶ added in v0.1.6
type SubAgentDelegationApprovalRequestValue struct {
AgentName string `json:"agentName,omitempty"`
SubAgentName string `json:"subAgentName,omitempty"`
Args map[string]any `json:"args,omitempty"`
ApprovalToken string `json:"approvalToken,omitempty"`
}
SubAgentDelegationApprovalRequestValue is the JSON payload for sub-agent delegation approval.
func ParseDelegationApproval ¶ added in v0.1.6
func ParseDelegationApproval(req *ApprovalRequest) (SubAgentDelegationApprovalRequestValue, error)
ParseDelegationApproval decodes Value for ApprovalRequestNameSubAgent.
type ToolApprovalRequestValue ¶ added in v0.1.6
type ToolApprovalRequestValue struct {
AgentName string `json:"agentName,omitempty"`
ToolCallID string `json:"toolCallId,omitempty"`
ToolName string `json:"toolName"`
ToolDisplayName string `json:"toolDisplayName,omitempty"`
Args map[string]any `json:"args,omitempty"`
ApprovalToken string `json:"approvalToken,omitempty"`
}
ToolApprovalRequestValue is the JSON payload for tool approval (same wire shape as CUSTOM approval value).
func ParseToolApproval ¶ added in v0.1.6
func ParseToolApproval(req *ApprovalRequest) (ToolApprovalRequestValue, error)
ParseToolApproval decodes Value for ApprovalRequestNameTool (handles map[string]any from JSON).
type ToolKind ¶ added in v0.2.2
type ToolKind string
ToolKind classifies SDK-built tool wrappers. User-registered tools default to ToolKindNative.
func KindOf ¶ added in v0.2.2
KindOf returns the tool kind when t implements ToolKindProvider, otherwise ToolKindNative.
func (ToolKind) CountsTowardToolTelemetry ¶ added in v0.2.2
CountsTowardToolTelemetry reports whether invocations of this kind belong in ToolTelemetry.
func (ToolKind) HooksEligible ¶ added in v0.2.3
HooksEligible reports whether [BeforeToolHook] and [AfterToolHook] run for this tool kind.
type ToolKindProvider ¶ added in v0.2.2
type ToolKindProvider interface {
ToolKind() ToolKind
}
ToolKindProvider is implemented by SDK tool wrappers (MCP, A2A, sub-agent, retriever).
type ToolSpec ¶ added in v0.1.2
type ToolSpec struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters JSONSchema `json:"parameters"`
}
ToolSpec is the schema sent to the LLM for tool selection. Convert from Tool via ToolToSpec.
type ToolTelemetry ¶ added in v0.2.2
type ToolTelemetry struct {
// TotalCalls is the total number of tool invocations made by the agent.
TotalCalls int64 `json:"total_calls"`
// FailedCalls is the number of tool invocations that returned an error.
// Excludes approval-denied and unauthorized cases.
FailedCalls int64 `json:"failed_calls"`
// Breakdown tracks invocation counts per tool name.
// Key: tool name (e.g. "palo_alto_fw_lookup"), Value: invocation count
Breakdown map[string]int64 `json:"breakdown,omitempty"`
// FailedBreakdown tracks failed invocation counts per tool name.
// Excludes approval-denied and unauthorized cases.
// Key: tool name (e.g. "palo_alto_fw_lookup"), Value: failed invocation count
FailedBreakdown map[string]int64 `json:"failed_breakdown,omitempty"`
}
ToolTelemetry tracks tool invocation counts and per-tool breakdowns across a single agent run.
func (*ToolTelemetry) Record ¶ added in v0.2.2
func (t *ToolTelemetry) Record(name string, failed bool)
Record increments tool invocation counters for name. When failed is true, failed counters are updated too. Breakdown keys are omitted when name is empty. Caller must serialize concurrent Record calls (e.g. mutex in parallel tool execution).