Documentation
¶
Index ¶
- type A2AAgentCard
- type A2AArtifact
- type A2AClient
- type A2AMessage
- type A2APart
- type A2ASendMessageRequest
- type A2ASendMessageResult
- type A2ASkillSpec
- type A2AStreamEvent
- type A2AStreamSeq
- type A2AStreamingClient
- type A2ATask
- type A2ATaskClient
- type A2ATaskStatus
- type A2ATaskStatusUpdate
- type AgentToolApprovalPolicy
- type Attribute
- type Conversation
- type Document
- type JSONSchema
- type LLMClient
- type LLMProvider
- type LLMReasoning
- type LLMRequest
- type LLMResponse
- type LLMStream
- type LLMStreamChunk
- type LLMUsage
- type ListMessagesOption
- type ListMessagesOptions
- type LoadMemoryOption
- type LoadMemoryOptions
- type Logs
- type MCPClient
- type MCPPromptClient
- type MCPResourceClient
- type Memory
- type MemoryEntry
- type MemoryKind
- type MemoryRecord
- type MemoryScope
- type Message
- type MessageRole
- type Metrics
- type OTelTracer
- type PromptSpec
- type ResourceSpec
- type ResponseFormat
- type ResponseFormatType
- type Retriever
- type Span
- type StoreMemoryOption
- type StoreMemoryOptions
- type Tool
- type ToolApproval
- type ToolAuthorizationDecision
- type ToolAuthorizer
- type ToolCall
- type ToolSpec
- type Tracer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type A2AAgentCard ¶ added in v0.1.9
type A2AAgentCard struct {
// Name is the human-readable agent name.
Name string `json:"name"`
// Description summarises what the agent does.
Description string `json:"description,omitempty"`
// Version is the agent's own version string.
Version string `json:"version,omitempty"`
// URL is the base endpoint of the agent server.
URL string `json:"url"`
// DocumentationURL is an optional link to agent documentation.
DocumentationURL string `json:"documentationUrl,omitempty"`
// Skills lists the capabilities the agent advertises.
Skills []A2ASkillSpec `json:"skills,omitempty"`
// InputModes lists MIME types or mode tokens the agent accepts (e.g. "text/plain", "application/json").
InputModes []string `json:"defaultInputModes,omitempty"`
// OutputModes lists MIME types or mode tokens the agent produces.
OutputModes []string `json:"defaultOutputModes,omitempty"`
}
A2AAgentCard describes a remote A2A agent: its identity, reachability, and declared skills. Returned by ResolveCard; mirrors the agent card defined in the A2A protocol spec. The agent package also accepts this type as A2AServerConfig.AgentCard when exposing an inbound server.
type A2AArtifact ¶ added in v0.1.9
type A2AArtifact struct {
// ArtifactID is an optional server-assigned identifier.
ArtifactID string `json:"artifactId,omitempty"`
// Name is a human-readable label for the artifact.
Name string `json:"name,omitempty"`
// Parts holds the artifact content.
Parts []A2APart `json:"parts,omitempty"`
// Metadata holds optional key/value annotations.
Metadata map[string]string `json:"metadata,omitempty"`
}
A2AArtifact is a named output produced by a task (e.g. a generated file or structured result).
type A2AClient ¶ added in v0.1.9
type A2AClient interface {
// Name identifies this connection for logging and tool prefixes (e.g. agent config key).
Name() string
// Ping checks that the agent server is reachable. The implementation should use a lightweight
// check (e.g. fetching the agent card or a health endpoint) with a short-lived connection.
Ping(ctx context.Context) error
// ResolveCard fetches the AgentCard from the server's well-known endpoint.
// It describes the agent's identity, capabilities, and supported input/output modes.
ResolveCard(ctx context.Context) (A2AAgentCard, error)
// ListSkills returns the skill specs derived from the agent's AgentCard.
// Skills are the A2A equivalent of tools: each represents an invocable capability.
ListSkills(ctx context.Context) ([]A2ASkillSpec, error)
// SendMessage sends a message to the agent and returns the result.
// The result is either a completed Message or a Task (when the agent handles the request asynchronously).
SendMessage(ctx context.Context, req A2ASendMessageRequest) (A2ASendMessageResult, error)
// Close releases the connection or session.
Close() error
}
A2AClient is a client to one A2A agent server: discovery, skill invocation, and optional close. Implementations may wrap github.com/a2aproject/a2a-go/v2/a2aclient or other transports. A remote A2A agent is treated as a tool provider: ResolveCard/ListSkills correspond to ListTools in MCPClient, and SendMessage corresponds to CallTool.
type A2AMessage ¶ added in v0.1.9
type A2AMessage struct {
// MessageID is an optional client-assigned identifier for this message.
MessageID string `json:"messageId,omitempty"`
// Role is "user" or "agent".
Role string `json:"role"`
// Parts holds the content of the message as an ordered slice of heterogeneous parts.
Parts []A2APart `json:"parts"`
// Metadata holds optional protocol-level key/value annotations.
Metadata map[string]string `json:"metadata,omitempty"`
}
A2AMessage is a single turn message exchanged with the agent. Role is "user" when sending and "agent" (or "assistant") when receiving.
type A2APart ¶ added in v0.1.9
type A2APart struct {
// Kind discriminates the part type: "text", "data", or "file".
Kind string `json:"kind"`
// Text holds the content when Kind is "text".
Text string `json:"text,omitempty"`
// Data holds structured JSON content when Kind is "data".
Data json.RawMessage `json:"data,omitempty"`
// FileMIMEType is the MIME type hint when Kind is "file".
FileMIMEType string `json:"fileMimeType,omitempty"`
// FileBytes holds base64-encoded file content when Kind is "file".
FileBytes string `json:"fileBytes,omitempty"`
// FileURI holds a URI reference to file content when Kind is "file".
FileURI string `json:"fileUri,omitempty"`
}
A2APart is one content part of a message. Exactly one of Text, Data, or File will be populated depending on Kind.
type A2ASendMessageRequest ¶ added in v0.1.9
type A2ASendMessageRequest struct {
// Message is the user-turn message to send.
Message A2AMessage `json:"message"`
// TaskID optionally resumes an existing async task.
TaskID string `json:"taskId,omitempty"`
// SessionID optionally groups related tasks into a logical session.
SessionID string `json:"sessionId,omitempty"`
// AcceptedOutputModes lists the output modes the caller can handle.
// If empty, the agent uses its default output modes.
AcceptedOutputModes []string `json:"acceptedOutputModes,omitempty"`
}
A2ASendMessageRequest is the input to SendMessage or SendStreamingMessage.
type A2ASendMessageResult ¶ added in v0.1.9
type A2ASendMessageResult struct {
// Message is set when the agent returned a complete message response inline.
Message *A2AMessage `json:"message,omitempty"`
// Task is set when the agent created or updated an async task.
Task *A2ATask `json:"task,omitempty"`
}
A2ASendMessageResult is the output of a non-streaming SendMessage call. Either Message or Task is set depending on whether the agent handled the request synchronously (message response) or asynchronously (task).
type A2ASkillSpec ¶ added in v0.1.9
type A2ASkillSpec = types.A2ASkillSpec
A2ASkillSpec describes one invocable skill advertised by the agent. Used by the agent host to expose the remote skill as a Tool to the LLM. Canonical definition in github.com/agenticenv/agent-sdk-go/internal/types.
type A2AStreamEvent ¶ added in v0.1.9
type A2AStreamEvent struct {
// Kind discriminates the event type: "message", "taskStatus", or "artifact".
Kind string `json:"kind"`
// TaskID is the server-assigned task ID; present on all event kinds.
TaskID string `json:"taskId,omitempty"`
// IsFinal is true on the last event for this stream.
IsFinal bool `json:"final,omitempty"`
// Message is set when Kind is "message".
Message *A2AMessage `json:"message,omitempty"`
// TaskStatus is set when Kind is "taskStatus".
TaskStatus *A2ATaskStatusUpdate `json:"taskStatus,omitempty"`
// Artifact is set when Kind is "artifact".
Artifact *A2AArtifact `json:"artifact,omitempty"`
}
A2AStreamEvent is one event yielded by SendStreamingMessage. Exactly one of Message, TaskStatus, or Artifact is populated depending on Kind.
type A2AStreamSeq ¶ added in v0.1.9
type A2AStreamSeq func(yield func(A2AStreamEvent, error) bool)
A2AStreamSeq is the iterator returned by A2AStreamingClient.SendStreamingMessage. Spelled as a plain func type (same underlying type as iter.Seq2) so mockgen does not emit invalid generic syntax like iter.Seq2[github.com/.../A2AStreamEvent, error].
type A2AStreamingClient ¶ added in v0.1.9
type A2AStreamingClient interface {
A2AClient
// SendStreamingMessage sends a message and returns an iterator over events streamed back by
// the agent. Each event is either a message delta, a task status update, or an artifact update.
// The caller must consume or break the iterator to release server-side resources.
SendStreamingMessage(ctx context.Context, req A2ASendMessageRequest) (A2AStreamSeq, error)
}
A2AStreamingClient extends A2AClient with streaming message support. Use when the agent server supports the SendStreamingMessage A2A protocol method.
type A2ATask ¶ added in v0.1.9
type A2ATask struct {
// ID is the server-assigned task identifier.
ID string `json:"id"`
// SessionID is the optional session this task belongs to.
SessionID string `json:"sessionId,omitempty"`
// Status is the current lifecycle state of the task.
Status A2ATaskStatus `json:"status"`
// Message is the latest agent message associated with this task, if any.
Message *A2AMessage `json:"message,omitempty"`
// Artifacts holds any named outputs produced by the task.
Artifacts []A2AArtifact `json:"artifacts,omitempty"`
// Metadata holds optional server-supplied key/value annotations.
Metadata map[string]string `json:"metadata,omitempty"`
}
A2ATask represents the state of a long-running async task on the agent server.
type A2ATaskClient ¶ added in v0.1.9
type A2ATaskClient interface {
A2AClient
// GetTask retrieves the current state of an async task by its ID.
GetTask(ctx context.Context, taskID string) (A2ATask, error)
// CancelTask requests cancellation of an in-progress task.
// The returned Task reflects the state after the cancellation request is acknowledged.
CancelTask(ctx context.Context, taskID string) (A2ATask, error)
}
A2ATaskClient extends A2AClient with async task management. Use when the agent returns Task results that may need polling or cancellation.
type A2ATaskStatus ¶ added in v0.1.9
type A2ATaskStatus string
A2ATaskStatus is the lifecycle state of an async task.
const ( A2ATaskStatusSubmitted A2ATaskStatus = "submitted" A2ATaskStatusWorking A2ATaskStatus = "working" A2ATaskStatusInputRequired A2ATaskStatus = "input-required" A2ATaskStatusCompleted A2ATaskStatus = "completed" A2ATaskStatusCanceled A2ATaskStatus = "canceled" A2ATaskStatusFailed A2ATaskStatus = "failed" A2ATaskStatusRejected A2ATaskStatus = "rejected" A2ATaskStatusAuthRequired A2ATaskStatus = "auth-required" A2ATaskStatusUnknown A2ATaskStatus = "unknown" )
type A2ATaskStatusUpdate ¶ added in v0.1.9
type A2ATaskStatusUpdate struct {
// Status is the updated lifecycle state.
Status A2ATaskStatus `json:"status"`
// Message is an optional agent message accompanying the status change.
Message *A2AMessage `json:"message,omitempty"`
}
A2ATaskStatusUpdate carries the new status and optional message in a task status event.
type AgentToolApprovalPolicy ¶
AgentToolApprovalPolicy determines if a tool execution requires approval. Implement for custom behavior. Built-in policies: agent.RequireAllToolApprovalPolicy (default), agent.AutoToolApprovalPolicy(), agent.AllowlistToolApprovalPolicy(agent.AllowlistToolApprovalConfig{...}) (may error on invalid sub-agent names).
type Attribute ¶ added in v0.1.10
Attribute is a simple key-value pair for traces and metrics (no OpenTelemetry dependency in interfaces).
type Conversation ¶
type Conversation interface {
// AddMessage adds a message to the conversation identified by id. Id is passed at runtime (e.g. from Run input, workflow).
AddMessage(ctx context.Context, id string, msg Message) error
// ListMessages returns messages for the conversation identified by id.
ListMessages(ctx context.Context, id string, opts ...ListMessagesOption) ([]Message, error)
// Clear removes all messages for the conversation identified by id. Called by the user when ending a session.
Clear(ctx context.Context, id string) error
// IsDistributed returns true if the implementation uses distributed storage (Redis, Postgres, etc.).
// In-memory implementations return false. Use distributed implementations when using remote workers.
IsDistributed() bool
}
type JSONSchema ¶
type JSONSchema = types.JSONSchema
JSONSchema is a loose JSON Schema object for tool parameters (canonical definition in types.JSONSchema).
type LLMClient ¶
type LLMClient interface {
// Generate generates a response from the LLM.
Generate(ctx context.Context, request *LLMRequest) (*LLMResponse, error)
// GenerateStream generates a response from the LLM using streaming.
GenerateStream(ctx context.Context, request *LLMRequest) (LLMStream, error)
// GetModel returns the model name.
GetModel() string
// GetProvider returns the provider name.
GetProvider() LLMProvider
// IsStreamSupported returns true if the client supports streaming (e.g. OpenAI, Anthropic).
IsStreamSupported() bool
}
type LLMProvider ¶
type LLMProvider string
const ( LLMProviderOpenAI LLMProvider = "openai" LLMProviderAnthropic LLMProvider = "anthropic" LLMProviderGemini LLMProvider = "gemini" )
type LLMReasoning ¶ added in v0.0.10
type LLMReasoning = types.LLMReasoning
LLMReasoning configures reasoning/thinking in a provider-agnostic way (canonical definition in types.LLMReasoning).
type LLMRequest ¶
type LLMRequest struct {
SystemMessage string
ResponseFormat *ResponseFormat
Tools []ToolSpec // Tool specs for the LLM to choose from
// Messages is the conversation history. For first turn, use one user message.
// For continuation after tool use: append assistant (with ToolCalls) + tool result messages.
Messages []Message
// Sampling (per-request; typically set from agent config). nil/0 = provider default.
Temperature *float64 // 0-2 OpenAI, 0-1 Anthropic; also Gemini
MaxTokens int // 0 = provider default
TopP *float64 // 0-1; OpenAI and Gemini (Anthropic client does not set TopP)
TopK *int // Anthropic only
// Reasoning configures generic reasoning/thinking when non-nil; each LLM client maps fields to its API.
Reasoning *LLMReasoning
}
type LLMResponse ¶
type LLMStream ¶
type LLMStream interface {
Next() bool
Current() *LLMStreamChunk
Err() error
// GetResult returns the accumulated content and tool calls after streaming completes.
// Call after the Next loop; returns nil if streaming failed or was not completed.
GetResult() *LLMResponse
}
LLMStream yields partial content and optional thinking/tool-call chunks from a streaming LLM response.
type LLMStreamChunk ¶
type LLMStreamChunk struct {
ContentDelta string // partial text content
ThinkingDelta string // Anthropic extended thinking (optional)
ToolCalls []*ToolCall // set on final chunk when tool calls are present
}
LLMStreamChunk is a single chunk from a streaming LLM response.
type LLMUsage ¶ added in v0.0.10
LLMUsage reports token counts from the provider (canonical definition in types.LLMUsage).
type ListMessagesOption ¶
type ListMessagesOption func(*ListMessagesOptions)
func WithLimit ¶
func WithLimit(limit int) ListMessagesOption
WithLimit sets the maximum number of messages to retrieve
func WithOffset ¶
func WithOffset(offset int) ListMessagesOption
WithOffset sets the number of messages to skip
func WithRoles ¶
func WithRoles(roles ...MessageRole) ListMessagesOption
WithRoles filters messages by role
type ListMessagesOptions ¶
type ListMessagesOptions struct {
// Limit is the maximum number of messages to retrieve from recent. -1 = all.
Limit int
// Offset is the number of most recent messages to skip. -1 = 0 (default).
Offset int
// Roles filters messages by role
Roles []MessageRole
}
type LoadMemoryOption ¶ added in v0.2.2
type LoadMemoryOption func(*LoadMemoryOptions)
func WithLoadKinds ¶ added in v0.2.2
func WithLoadKinds(kinds ...MemoryKind) LoadMemoryOption
WithLoadKinds restricts recall to the given memory kinds.
func WithLoadLimit ¶ added in v0.2.2
func WithLoadLimit(limit int) LoadMemoryOption
WithLoadLimit sets the maximum number of memories to return. Zero or negative means backend default.
func WithMinScore ¶ added in v0.2.2
func WithMinScore(minScore float32) LoadMemoryOption
WithMinScore filters out entries below the given relevance score.
type LoadMemoryOptions ¶ added in v0.2.2
type LoadMemoryOptions struct {
// Limit is the maximum number of memories to return. Zero or negative means backend default.
Limit int
// MinScore filters out entries below the given relevance score when Score is applicable.
MinScore float32
// Kinds restricts recall to the given memory kinds. Empty means all kinds.
Kinds []MemoryKind
}
LoadMemoryOptions configures a Memory.Load call.
type Logs ¶ added in v0.1.10
type Logs interface {
// Shutdown flushes buffered log records and releases the exporter connection.
Shutdown(ctx context.Context) error
}
Logs manages the OTLP log exporter and flushes buffered log records on Shutdown. Obtain one with pkg/observability.NewLogs; pkg/observability.DefaultNoopLogs is used when observability is unconfigured or [ObservabilityConfig.DisableLogs] is true.
type MCPClient ¶ added in v0.1.2
type MCPClient interface {
// Name identifies this connection for logging and tool prefixes (e.g. [github.com/agenticenv/agent-sdk-go/pkg/agent.MCPServers] key or [github.com/agenticenv/agent-sdk-go/pkg/mcp/client.NewClient] first argument).
Name() string
// Ping checks that the server responds (MCP ping on a short-lived session). The default
// implementation connects, pings, and disconnects; ListTools and CallTool each open their own session.
Ping(ctx context.Context) error
// ListTools returns tool definitions from the server (tools/list).
ListTools(ctx context.Context) ([]ToolSpec, error)
// CallTool invokes a tool by name with JSON arguments (tools/call).
CallTool(ctx context.Context, tool string, input json.RawMessage) (json.RawMessage, error)
// Close releases the connection or session.
Close() error
}
MCPClient is a client to one MCP server: optional reachability check, tools, optional close. Implementations may wrap modelcontextprotocol/go-sdk or other transports.
type MCPPromptClient ¶ added in v0.1.2
type MCPPromptClient interface {
MCPClient
// ListPrompts returns available prompts (prompts/list).
ListPrompts(ctx context.Context) ([]PromptSpec, error)
// GetPrompt resolves a prompt template with arguments (prompts/get).
GetPrompt(ctx context.Context, name string, args map[string]string) (json.RawMessage, error)
}
MCPPromptClient extends MCPClient with MCP prompts. Optional: tool-only agents need only MCPClient.
type MCPResourceClient ¶ added in v0.1.2
type MCPResourceClient interface {
MCPClient
// ListResources returns available resources (resources/list).
ListResources(ctx context.Context) ([]ResourceSpec, error)
// ReadResource returns the resource body for uri (resources/read).
ReadResource(ctx context.Context, uri string) (json.RawMessage, error)
}
MCPResourceClient extends MCPClient with MCP resources. Optional: tool-only agents need only MCPClient.
type Memory ¶ added in v0.2.2
type Memory interface {
// Store persists a new memory in the given scope and returns its assigned ID.
// The returned ID is always non-empty; implementations must assign one if the
// backend does not (e.g. a UUID).
//
// Expiry (ExpiresAt on [MemoryRecord]) is set by the agent SDK from TTL policy.
// Use [WithMemoryID] to upsert an existing record.
Store(ctx context.Context, scope MemoryScope, record MemoryRecord, opts ...StoreMemoryOption) (id string, err error)
// Load retrieves memories within scope.
// Query drives ranking or filtering; pass empty query to list by recency when supported.
// Implementations must omit expired entries (ExpiresAt non-zero and in the past).
//
// Non-empty scope fields filter results (AND). Use [WithLoadLimit], [WithMinScore],
// and [WithLoadKinds] to narrow recall.
Load(ctx context.Context, scope MemoryScope, query string, opts ...LoadMemoryOption) ([]MemoryEntry, error)
// Clear removes all memories matching the scope. Called by the application when
// required (e.g. user offboarding). Not invoked by the agent runtime.
// Warning: a TenantID-only scope deletes all memories for that tenant across every user and agent.
Clear(ctx context.Context, scope MemoryScope) error
}
Memory stores and retrieves long-term agent context across runs.
Store/Load/Clear with scope and query work with vector, relational, or key-value backends. Scope drives isolation; query semantics are backend-specific (semantic search, filter, etc.).
Agent SDK usage (runtime):
- Store — persist extracted context after a run.
- Load — recall memories for the current query before or during a run.
Application usage (optional, not invoked by agent runtime):
- Clear — remove all memories in a scope (e.g. tenant offboarding, forget-me).
type MemoryEntry ¶ added in v0.2.2
type MemoryEntry struct {
// ID is the stable record identifier assigned by the backend.
// Always non-empty; required for upserts via [WithMemoryID].
ID string
Text string
Kind MemoryKind
Scope MemoryScope
Metadata map[string]string
ExpiresAt time.Time
// Score is query relevance when the backend supports ranked retrieval (e.g. vector search).
// Zero means not applicable (e.g. key-value or recency-only backends).
Score float32
CreatedAt time.Time
UpdatedAt time.Time
}
MemoryEntry is a memory returned from Memory.Load.
func (MemoryEntry) Expired ¶ added in v0.2.2
func (e MemoryEntry) Expired() bool
Expired reports whether the entry has passed its expiry time. Entries with a zero ExpiresAt never expire.
type MemoryKind ¶ added in v0.2.2
type MemoryKind string
MemoryKind is an arbitrary label for categorizing memories (e.g. "preference", "fact", "bug_report"). Different agents define their own taxonomies; the interface does not prescribe fixed kinds.
type MemoryRecord ¶ added in v0.2.2
type MemoryRecord struct {
// Text is the distilled fact, preference, or instruction to remember.
Text string
// Kind is an optional category label for filtered recall. Empty is allowed.
Kind MemoryKind
// Metadata holds optional attributes (source run, confidence, custom tags).
// Scope fields from [MemoryScope] are stored separately and should not be duplicated here.
Metadata map[string]string
// ExpiresAt is when the entry should no longer be recalled. Zero means no expiry.
// The agent SDK sets this from [memory.Config] TTL policy on Store; direct callers may leave it zero.
ExpiresAt time.Time
}
MemoryRecord is the content written to long-term storage.
type MemoryScope ¶ added in v0.2.2
type MemoryScope struct {
UserID string
TenantID string
AgentID string
// Tags holds additional scope dimensions (e.g. project, team, environment).
// Do not duplicate UserID, TenantID, or AgentID as tag keys.
Tags map[string]string
}
MemoryScope identifies the namespace a memory belongs to. Non-empty fields are AND-ed when storing, loading, or clearing.
UserID, TenantID, and AgentID are common isolation dimensions; Tags hold custom keys (e.g. project_id, env). The agent SDK may populate scope via pkg/memory ScopeConfig; implementations only see the resolved MemoryScope values.
type Message ¶
type Message struct {
Role MessageRole `json:"role"`
Content string `json:"content"`
ToolName string `json:"tool_name"`
ToolCallID string `json:"tool_call_id"`
ToolCalls []*ToolCall `json:"tool_calls"`
Metadata map[string]any `json:"metadata"`
CreatedAt time.Time `json:"created_at"`
}
Message represents a conversation turn for multi-turn (including tool use).
type MessageRole ¶
type MessageRole string
const ( MessageRoleSystem MessageRole = "system" MessageRoleUser MessageRole = "user" MessageRoleAssistant MessageRole = "assistant" MessageRoleTool MessageRole = "tool" MessageRoleReasoning MessageRole = "reasoning" )
type Metrics ¶ added in v0.1.10
type Metrics interface {
// IncrementCounter adds one to a named counter with optional attributes.
IncrementCounter(ctx context.Context, name string, attrs ...Attribute)
// RecordHistogram records a sample on a histogram-style instrument.
RecordHistogram(ctx context.Context, name string, value float64, attrs ...Attribute)
// Shutdown flushes exporters and releases resources when the agent or worker stops.
Shutdown(ctx context.Context) error
}
Metrics records counters and histograms for agent execution without coupling callers to OTel APIs.
type OTelTracer ¶ added in v0.1.10
type OTelTracer interface {
// OTelTracer returns the underlying OpenTelemetry Tracer.
OTelTracer() trace.Tracer
}
OTelTracer is an optional OTel specific extension to the trace.Tracer interface.
type PromptSpec ¶ added in v0.1.2
type PromptSpec struct {
Name string `json:"name"` // Prompt identifier.
Description string `json:"description,omitempty"` // Short description.
}
PromptSpec is one entry from prompts/list (subset of MCP; fields may grow with spec versions).
type ResourceSpec ¶ added in v0.1.2
type ResourceSpec struct {
URI string `json:"uri"` // Resource URI.
Name string `json:"name,omitempty"` // Human-readable name.
Description string `json:"description,omitempty"` // Short description.
MimeType string `json:"mimeType,omitempty"` // Optional MIME type hint.
}
ResourceSpec is one entry from resources/list (subset of MCP; fields may grow with spec versions).
type ResponseFormat ¶
type ResponseFormat struct {
Type ResponseFormatType
Name string
Schema JSONSchema
}
type ResponseFormatType ¶
type ResponseFormatType string
const ( ResponseFormatJSON ResponseFormatType = "json" ResponseFormatText ResponseFormatType = "text" )
type Span ¶ added in v0.1.10
type Span interface {
// End completes the span; safe to call once.
End()
// SetAttribute attaches a typed attribute to this span.
SetAttribute(key string, value any)
// RecordError records err on the span when non-nil.
RecordError(err error)
}
Span is an active trace span created by Tracer.StartSpan.
type StoreMemoryOption ¶ added in v0.2.2
type StoreMemoryOption func(*StoreMemoryOptions)
func WithMemoryID ¶ added in v0.2.2
func WithMemoryID(id string) StoreMemoryOption
WithMemoryID upserts the record with the given ID when the backend supports stable identifiers. Use the ID returned by a prior Memory.Store call.
type StoreMemoryOptions ¶ added in v0.2.2
type StoreMemoryOptions struct {
// ID upserts the record when non-empty. Use the ID returned by a prior Store call.
ID string
}
StoreMemoryOptions configures a Memory.Store call.
type Tool ¶
type Tool interface {
// Name returns the tool identifier (e.g. "search", "calculator"). Used by the LLM in tool calls.
Name() string
// DisplayName returns the tool display name (e.g. "Search", "Calculator"). Used by the LLM in tool calls.
DisplayName() string
// Description describes when and how to use this tool. Shown to the LLM for tool selection.
Description() string
// Parameters returns the JSON schema for the tool's input. The LLM produces args matching this schema.
// Use tools.Params with tools.ParamString, ParamInteger, etc. for type-safe construction.
Parameters() JSONSchema
// Execute runs the tool with the given args. Args match the Parameters schema.
// Called by the agent when the LLM returns a tool call for this tool.
Execute(ctx context.Context, args map[string]any) (any, error)
}
Tool is a callable capability the agent can offer to the LLM. Register tools via agent.WithTools. The LLM receives tool definitions and chooses which to call; the agent executes the chosen tool.
type ToolApproval ¶
type ToolApproval interface {
ApprovalRequired() bool
}
ToolApproval is an optional interface for tools that require interactive human approval before execution. When implemented, the agent honors ApprovalRequired() when no agent-level approval policy is set. WithToolApprovalPolicy overrides this tool-level default when set.
type ToolAuthorizationDecision ¶ added in v0.1.3
type ToolAuthorizationDecision struct {
Allow bool `json:"allow"`
Reason string `json:"reason,omitempty"`
}
ToolAuthorizationDecision is the structured authorization outcome for one tool call. Reason is optional and primarily useful when Allow is false.
type ToolAuthorizer ¶ added in v0.1.3
type ToolAuthorizer interface {
Authorize(ctx context.Context, args map[string]any) (ToolAuthorizationDecision, error)
}
ToolAuthorizer is an optional interface for tools that enforce programmatic authorization. When implemented, the agent checks Authorize before approval/Execute in the tool call flow. Return a decision with Allow=true/false and optional deny metadata.
type ToolCall ¶
type ToolCall struct {
ToolCallID string `json:"tool_call_id"` // from API; needed to match tool results
ToolName string `json:"tool_name"`
Args map[string]any `json:"args"`
}
ToolCall is the LLM's decision to invoke a tool.
type ToolSpec ¶
ToolSpec is the schema sent to the LLM for tool selection (canonical definition in types.ToolSpec).
func ToolToSpec ¶
ToolToSpec converts a Tool to its spec for the LLM.
func ToolsToSpecs ¶
ToolsToSpecs converts a slice of Tool to specs for the LLM.
type Tracer ¶ added in v0.1.10
type Tracer interface {
// StartSpan creates a span named name and returns a context that carries it plus the span handle.
StartSpan(ctx context.Context, name string, attrs ...Attribute) (context.Context, Span)
// Shutdown flushes exporters and releases resources when the agent or worker stops.
Shutdown(ctx context.Context) error
}
Tracer is the tracing surface used by the SDK for OpenTelemetry-backed implementations (see pkg/observability). Callers construct spans around LLM and tool work without importing OTel types.