deep

package
v0.10.0-alpha.21 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 19 Imported by: 12

Documentation

Overview

Package deep provides a prebuilt agent with deep task orchestration.

Index

Constants

View Source
const (
	SessionKeyTodos = "deep_agent_session_key_todos"
)

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, cfg *Config) (adk.ResumableAgent, error)

New creates a new Deep agent instance with the provided configuration. This function initializes built-in tools, creates a task tool for subagent orchestration, and returns a fully configured ChatModelAgent ready for execution.

func NewTyped added in v0.9.0

func NewTyped[M adk.MessageType](ctx context.Context, cfg *TypedConfig[M]) (adk.TypedResumableAgent[M], error)

NewTyped creates a new typed Deep agent instance with the provided configuration. This function initializes built-in tools, creates a task tool for subagent orchestration, and returns a fully configured TypedChatModelAgent ready for execution.

Types

type BackgroundConfig

type BackgroundConfig = TypedBackgroundConfig[*schema.Message]

type Config

type Config = TypedConfig[*schema.Message]

Config defines the configuration for creating a standard DeepAgent.

type DurableSubAgentConfig

type DurableSubAgentConfig = TypedDurableSubAgentConfig[*schema.Message]

type LocalShellConfig

type LocalShellConfig struct {
	Shell          filesystem.Shell
	StreamingShell filesystem.StreamingShell
	OutputDir      string
}

LocalShellConfig configures managed process-local shell commands.

type RecoverableShellConfig

type RecoverableShellConfig struct {
	Shell              backgroundshell.RecoverableShell
	OutputMaterializer backgroundtool.OutputMaterializer
}

RecoverableShellConfig configures recoverable managed shell commands.

type TODO

type TODO struct {
	Content    string `json:"content"`
	ActiveForm string `json:"activeForm"`
	Status     string `json:"status" jsonschema:"enum=pending,enum=in_progress,enum=completed"`
}

type TypedBackgroundConfig

type TypedBackgroundConfig[M adk.MessageType] struct {
	// Manager is the single lifecycle authority shared by every enabled capability.
	Manager *backgroundtask.Manager
	// Executors is the registry configured on Manager and shared by every capability.
	Executors *backgroundtask.ExecutorRegistry
	// SubAgents enables reconstructable sub-agent runs.
	SubAgents *TypedDurableSubAgentConfig[M]
	// RecoverableShell enables task-ID-keyed commands that workers can recover.
	RecoverableShell *RecoverableShellConfig
	// LocalShell enables managed process-local Shell or StreamingShell runs.
	LocalShell *LocalShellConfig
	// ForegroundTimeoutMs and ShouldAutoBackground apply to every enabled capability.
	ForegroundTimeoutMs  *int
	ShouldAutoBackground func(context.Context, *foreground.CandidateInfo) bool
	// TranscriptFormat customizes durable sub-agent session views.
	TranscriptFormat subagent.TranscriptFormat[M]
}

TypedBackgroundConfig enables selected background-task capabilities for a DeepAgent's top-level agent under one shared task-ID space.

type TypedConfig added in v0.9.0

type TypedConfig[M adk.MessageType] struct {
	// Name is the identifier for the Deep agent.
	Name string
	// Description provides a brief explanation of the agent's purpose.
	Description string

	// ChatModel is the model used by DeepAgent for reasoning and task execution.
	// If the agent uses any tools, this model must support the model.WithTools call option,
	// as that's how the agent configures the model with tool information.
	ChatModel model.BaseModel[M]
	// Instruction contains the system prompt that guides the agent's behavior.
	// When empty, a built-in default system prompt will be used, which includes general assistant
	// behavior guidelines, security policies, coding style guidelines, and tool usage policies.
	Instruction string
	// SubAgents are specialized agents that can be invoked by the agent.
	// For M = *schema.AgenticMessage, only agentic sub-agents are accepted.
	SubAgents []adk.TypedAgent[M]
	// ToolsConfig provides the tools and tool-calling configurations available for the agent to invoke.
	ToolsConfig adk.ToolsConfig
	// MaxIteration limits the maximum number of reasoning iterations the agent can perform.
	MaxIteration int

	// Backend provides filesystem operations used by tools and offloading.
	// If set, filesystem tools (read_file, write_file, edit_file, glob, grep) will be registered.
	// For advanced filesystem middleware configuration, leave Backend, Shell, and StreamingShell empty
	// and pass a manually constructed filesystem middleware through Handlers.
	// Optional.
	Backend filesystem.Backend
	// Shell provides shell command execution capability.
	// If set, an execute tool will be registered to support shell command execution.
	// For advanced filesystem middleware configuration, leave Backend, Shell, and StreamingShell empty
	// and pass a manually constructed filesystem middleware through Handlers.
	// Optional. Mutually exclusive with StreamingShell and Background.LocalShell.
	Shell filesystem.Shell
	// StreamingShell provides streaming shell command execution capability.
	// If set, a streaming execute tool will be registered to support streaming shell command execution.
	// For advanced filesystem middleware configuration, leave Backend, Shell, and StreamingShell empty
	// and pass a manually constructed filesystem middleware through Handlers.
	// Optional. Mutually exclusive with Shell and Background.LocalShell.
	StreamingShell filesystem.StreamingShell
	// Background configures selected background-task capabilities for the
	// top-level agent under one task-ID space, and injects task_output/task_stop
	// once. Background is intentionally NOT propagated to the general or user
	// sub-agents: their shell runs stay foreground/buffered and they cannot launch
	// background work, so background orchestration is a top-level concern only. When
	// nil, the top-level agent has no background-task support. See BackgroundConfig.
	Background *TypedBackgroundConfig[M]

	// WithoutWriteTodos disables the built-in write_todos tool when set to true.
	WithoutWriteTodos bool
	// WithoutGeneralSubAgent disables the general-purpose subagent when set to true.
	WithoutGeneralSubAgent bool
	// TaskToolDescriptionGenerator allows customizing the description for the task tool.
	// If provided, this function generates the tool description based on available subagents.
	TaskToolDescriptionGenerator func(ctx context.Context, availableAgents []adk.TypedAgent[M]) (string, error)

	Middlewares []adk.AgentMiddleware

	// Handlers configures interface-based handlers for extending agent behavior.
	// Unlike Middlewares (struct-based), Handlers allow users to:
	//   - Add custom methods to their handler implementations
	//   - Return modified context from handler methods
	//   - Centralize configuration in struct fields instead of closures
	//
	// Handlers are processed after Middlewares, in registration order.
	// See adk.ChatModelAgentMiddleware documentation for when to use Handlers vs Middlewares.
	Handlers []adk.TypedChatModelAgentMiddleware[M]

	ModelRetryConfig *adk.TypedModelRetryConfig[M]
	// ModelFailoverConfig configures failover behavior for the ChatModel.
	// When set, the agent will automatically fail over to alternative models on errors.
	// This config is also propagated to the general sub-agent.
	ModelFailoverConfig *adk.ModelFailoverConfig[M]
	// OutputKey stores the agent's response in the session.
	// Optional. When set, stores output via AddSessionValue(ctx, outputKey, msg.Content).
	OutputKey string
}

TypedConfig defines the configuration for creating a DeepAgent parameterized by message type. An Agentic DeepAgent (M = *schema.AgenticMessage) only supports Agentic sub-agents, and a standard DeepAgent (M = *schema.Message) only supports standard sub-agents. This is enforced by the type system through the SubAgents field.

type TypedDurableSubAgentConfig

type TypedDurableSubAgentConfig[M adk.MessageType] struct {
	// Executor owns durable sub-agent session dependencies.
	Executor *durablesubagent.Executor[M]
	// RunOptionsFactories reconstructs deployment-owned options on every worker
	// attempt and is forwarded to the durable sub-agent middleware. Equivalent
	// configuration must remain available for the full lifetime of resumable tasks.
	RunOptionsFactories map[string]durablesubagent.RunOptionsFactory
}

TypedDurableSubAgentConfig configures reconstructable sub-agent runs.

Jump to

Keyboard shortcuts

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