Documentation
¶
Index ¶
- func BuildAgent(cfg Config, runner *agentsdk.Runner, hostBundle ToolBundle) (*agentsdk.Agent, []agentsdk.Tool)
- func BuildAgentWithSpecialists(cfg Config, runner *agentsdk.Runner, hostBundle ToolBundle) (*agentsdk.Agent, []agentsdk.Tool, map[string]*agentsdk.Agent)
- func BuildRunConfig(cfg Config, hooks agentsdk.RunHooks) agentsdk.RunConfig
- func BuildRunner(cfg Config) (*agentsdk.Runner, error)
- func ProviderSpec(cfg Config) sdkproviders.ProviderSpec
- type AsyncSubAgentFeatures
- type Builder
- type Bundle
- type Config
- type Features
- type GuardrailFeatures
- type HandoffFeatures
- type MCPFeatures
- type ModeFeatures
- type ModeOverrides
- type Option
- type ProjectStateFeatures
- type RuntimeFeatures
- type SessionState
- type SignalFeatures
- type SubAgentFeatures
- type ToolBundle
- type ToolFeatures
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildAgent ¶
func ProviderSpec ¶
func ProviderSpec(cfg Config) sdkproviders.ProviderSpec
Types ¶
type AsyncSubAgentFeatures ¶ added in v0.0.7
AsyncSubAgentFeatures gates the managed sub-agent tool surface: subagent (spawn sync/background, single or DAG) and subagent_wait (block until background tasks finish) under Task, subagent_status (summary/activity/graph introspection) under Status, subagent_control (steer/cancel) under Control.
type Bundle ¶
type Bundle struct {
Runner *agentsdk.Runner
Agent *agentsdk.Agent
Config agentsdk.RunConfig
Tracker *agentsdk.ProgressTracker
Tools []agentsdk.Tool
SpecialistAgents map[string]*agentsdk.Agent
SessionState *SessionState
Closers []io.Closer
}
Bundle is the complete runnable runtime produced by Builder.
type Config ¶
type Config struct {
Provider string
DefaultProvider string
Model string
BaseURL string
APIKey string
AuthMode string
APIMode string
OpenAIOAuthPath string
OpenAIOAuthAccountID string
OpenAIOAuthAccountIDPath string
OpenAIAuthSession *sdkopenai.AuthSession
// CopilotOAuthPath points at Copilot auth JSON holding the long-lived
// GitHub OAuth token so the copilot provider can self-refresh the
// short-lived (~25–30 min) Copilot API token per request.
CopilotOAuthPath string
// AnthropicOAuthPath points at Anthropic OAuth auth JSON (Claude Code
// .credentials.json or the SDK flat shape) so the anthropic provider can
// resolve the bearer token per request: re-reading external rotations and
// self-refreshing near expiry instead of pinning the startup token.
AnthropicOAuthPath string
ProviderAPIKeys map[string]string
ProviderBaseURLs map[string]string
ProviderAPIModes map[string]string
// ProviderAuthModes optionally pins the auth mode ("oauth" or "api-key")
// per canonical provider leg, taking precedence over the top-level
// AuthMode scoping. Lets one registry mix auth flavors (e.g. an API-key
// default provider with an OAuth secondary leg) for live provider
// switches. Missing entries keep the inferred behavior.
ProviderAuthModes map[string]string
// Routes declares named provider instances registered under arbitrary
// routing prefixes, letting the same base provider be exposed under
// multiple prefixes with independent auth (e.g. "anthropic" via API key and
// "anthropic-oauth" via OAuth). Callers select the auth by model prefix.
Routes []sdkproviders.ProviderRoute
// ModelFallbacks is an ordered list of fallback model identifiers used by
// OpenAI-compatible providers (e.g. OpenRouter) to retry the next model when
// one is unavailable. Empty disables fallback routing.
ModelFallbacks []string
// FallbackModels is an ordered list of SDK-level fallback model identifiers.
// When a model call fails with a rate-limit or quota-style error, the runner
// retries the request through the next model, including cross-provider models
// such as "anthropic/claude-sonnet-4-6" or "copilot/gpt-4.1".
FallbackModels []string
WorkDir string
AgentName string
Instructions string
ActiveMode string
ModeSnapshot *sdkmode.TemplateSpec
RoleCatalog agentsdk.RoleCatalog
Reasoning string
Verbosity string
ModelSettings *agentsdk.ModelSettings
MaxTokens int
MaxTurns int
SubAgentMaxTurns int
MaxConcurrentSubAgents int
ToolTimeout int
ToolAccess agentsdk.ToolAccessLevel
PermissionMode policy.PermissionMode
CommandSandboxConfig *sdksandbox.Config
Features *Features
EnableTools bool
EnableMCP bool
EnableHandoffs bool
EnableSubAgents bool
EnableGuardrails bool
EnableCompaction bool
EnableApproval bool
EnableRetry bool
EnableAsyncShell bool
ForceFinalSummary bool
FinalCheckInstructions string
Debug bool
AllowPrivateNetworkURLs bool
DisableWebTools bool
OutputSchema *agentsdk.OutputSchema
MCPConfig *sdkmcp.Config
ExtraTools []agentsdk.Tool
DisableDefaultTools bool
DisableSignalTools bool
ToolInputRules []agentsdk.ToolInputGuardrail
ToolOutputRules []agentsdk.ToolOutputGuardrail
EventWriter io.Writer
EventSession int
TracingProcessor agentsdk.TracingProcessor
WorkingStateText string
FeatureSummary string
ModeDirectiveText string
EnableProjectState bool
ProjectID string
ProjectStateDir string
ProjectStateActor string
ProjectStateActiveTaskID string
ProjectStateStore sdkprojectstate.Store
Trace *agentsdk.Trace
ParentSpanID string
ImmediateInputPoller agentsdk.ImmediateInputPoller
CompactionConfig *agentsdk.CompactionConfig
// CompactionModelResolver, when set, resolves per-model compaction
// thresholds (typically from authoritative provider /models metadata with a
// static fallback) so each agent — including sub-agents on different models
// than the parent — compacts at its own model's context window. When nil the
// builder synthesizes a default resolver from OpenAIAuthSession + BaseURL,
// falling back to the static CompactionDefaultsForModel table.
CompactionModelResolver agentsdk.CompactionModelResolver
CompactionRecorder func(tokensBefore, tokensAfter int, summary string)
CompactionFailureReporter func(scope, reason string, tokensBefore, tokensAfter int)
CompactionCarryForward func(context.Context) string
HandoffHistory *agentsdk.HandoffHistoryConfig
SessionState *SessionState
// SpecialistOutputExtractor, when set, post-processes each specialist
// sub-agent's RunResult before its text is returned to the parent agent.
// Use it to return a compact or structured view of specialist work.
SpecialistOutputExtractor func(*agentsdk.RunResult) string
}
Config is the SDK-native runtime builder input. Hosts should populate this from flags, CRDs, files, or environment variables, then provide only the remaining platform adapters.
type Features ¶ added in v0.0.7
type Features struct {
Tools ToolFeatures
MCP MCPFeatures
Handoffs HandoffFeatures
SubAgents SubAgentFeatures
Guardrails GuardrailFeatures
Modes ModeFeatures
ProjectState ProjectStateFeatures
Runtime RuntimeFeatures
}
Features is the explicit runtime feature surface. All zero values are off.
Config.Features is intentionally a pointer: nil preserves the legacy compatibility behavior driven by Config.Enable*/Disable* fields, while a non-nil Features value opts into strict explicit selection.
type GuardrailFeatures ¶ added in v0.0.7
type GuardrailFeatures struct {
Builtin bool
}
type HandoffFeatures ¶ added in v0.0.7
type MCPFeatures ¶ added in v0.0.7
type ModeFeatures ¶ added in v0.0.7
type ModeOverrides ¶
type ModeOverrides struct {
Model string
FallbackModels []string
Reasoning string
ModelSettings agentsdk.ModelSettings
MaxTurns int
SubAgentMaxTurns int
MaxConcurrentSubAgents int
ModeInstructions string
}
ModeOverrides are runtime settings derived from a mode template snapshot.
func ModeOverridesFromSnapshot ¶
func ModeOverridesFromSnapshot(spec *sdkmode.TemplateSpec, instructionsOverride string) ModeOverrides
type ProjectStateFeatures ¶ added in v0.0.7
type RuntimeFeatures ¶ added in v0.0.7
type SessionState ¶
type SessionState struct {
// contains filtered or unexported fields
}
SessionState holds SDK runtime state that should survive multiple runtime builds for one host session. Reuse the same SessionState across user turns when managed async sub-agent tasks should remain listable, waitable, and collectible across host rebuilds.
func NewSessionState ¶
func NewSessionState() *SessionState
func (*SessionState) SubAgentScheduler ¶
func (s *SessionState) SubAgentScheduler() *agentsdk.SubAgentScheduler
type SignalFeatures ¶ added in v0.0.7
type SubAgentFeatures ¶ added in v0.0.7
type SubAgentFeatures struct {
GenericFallback bool
Async AsyncSubAgentFeatures
}
type ToolBundle ¶
ToolBundle is the SDK-built host-neutral tool set.
func BuildToolBundle ¶
func BuildToolBundle(ctx context.Context, cfg Config) (ToolBundle, error)