API reference¶
Everything below is importable from adk_agent_harness.
Factory¶
create_deep_agent
¶
create_deep_agent(
*,
name: str,
model_client: str | BaseLlm,
instruction: str,
description: str = "",
tools: Sequence[ToolUnion] = (),
skills: SkillToolset | None = None,
thinking: bool | ThinkingConfig = False,
compaction: CompactionConfig | None = None,
plugins: Sequence[BasePlugin] = (),
subagents: Sequence[SubAgentSpec] = (),
spawn: SpawnConfig | None = None,
elicitation: bool = False,
available_models: Sequence[str | ModelSpec] = (),
sandbox: SandboxKind
| SandboxConfig
| BaseEnvironment
| None = None,
context_cache: bool | ContextCacheConfig | None = None,
) -> App
Create a standard ADK App with deep-agent behavior pre-wired.
The returned App always includes the built-in todo task ledger, active
ledger injection before each root model request, and ToolCallRepairPlugin.
Everything else is opt-in. Run the App with any ADK Runner and the
session, artifact, and memory services your application chooses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Root agent and App name. Must be a valid Python identifier and
cannot be |
required |
model_client
|
str | BaseLlm
|
Root model. A model name string or any ADK |
required |
instruction
|
str
|
Root agent instruction. Package guidance for the enabled features is appended to it. |
required |
description
|
str
|
Optional root agent description. |
''
|
tools
|
Sequence[ToolUnion]
|
Tools for the root agent: functions, ADK |
()
|
skills
|
SkillToolset | None
|
One ADK |
None
|
thinking
|
bool | ThinkingConfig
|
|
False
|
compaction
|
CompactionConfig | None
|
Optional |
None
|
plugins
|
Sequence[BasePlugin]
|
Additional ADK plugins for the App. |
()
|
subagents
|
Sequence[SubAgentSpec]
|
Prebuilt children declared with |
()
|
spawn
|
SpawnConfig | None
|
|
None
|
elicitation
|
bool
|
Add ADK's |
False
|
available_models
|
Sequence[str | ModelSpec]
|
Models a spawned child may select, as IDs or
|
()
|
sandbox
|
SandboxKind | SandboxConfig | BaseEnvironment | None
|
Optional workspace for shell and file tools. Accepts a backend
name ( |
None
|
context_cache
|
bool | ContextCacheConfig | None
|
Optional ADK context caching. |
None
|
Returns:
| Type | Description |
|---|---|
App
|
A standard |
Raises:
| Type | Description |
|---|---|
ValueError
|
For invalid or duplicate agent names, or a subagent that requests a sandbox when none is configured. |
SandboxConfigurationError
|
When a selected sandbox backend is missing credentials or packages. |
Configuration¶
SubAgentSpec
¶
Bases: BaseModel
A prebuilt subagent, attached as a native ADK sub_agent.
ADK exposes it to the root agent as a tool named after the subagent, runs
it on its own branch of the root session, and streams its events in the
root run_async() stream.
name
instance-attribute
¶
Child name and tool name. A valid Python identifier, unique in the App.
goal
instance-attribute
¶
What the child does. Used for its default instruction and description.
instruction
class-attribute
instance-attribute
¶
Full instruction. Overrides the instruction generated from goal.
description
class-attribute
instance-attribute
¶
Tool description shown to the root agent. Defaults to goal.
model_client
class-attribute
instance-attribute
¶
Model for this child. Defaults to the root model.
tools
class-attribute
instance-attribute
¶
Tools for this child only.
skills
class-attribute
instance-attribute
¶
One ADK SkillToolset for this child.
thinking
class-attribute
instance-attribute
¶
thinking: bool | ThinkingConfig = False
Thinking settings for this child.
use_sandbox
class-attribute
instance-attribute
¶
Grant this child the root agent's configured sandbox workspace.
SpawnConfig
¶
Bases: BaseModel
On-demand spawned subagent configuration.
Enabling it adds the spawn_subagent tool. Spawned children always run in
ADK single_turn mode: they complete the delegated request once, without
user interaction, and return a result. The root agent chooses per call
whether to wait (the default) or run the child in the background.
enabled
class-attribute
instance-attribute
¶
Add the spawn_subagent tool to the root agent.
tools
class-attribute
instance-attribute
¶
Extra tools spawned children may use, by name. The root agent's own
tools and the sandbox (environment) are offered too.
skills
class-attribute
instance-attribute
¶
Skill toolsets spawned children may use, by name.
allowed_tools
class-attribute
instance-attribute
¶
Tool names a child may select. Empty allows every registered tool.
allowed_skills
class-attribute
instance-attribute
¶
Skill names a child may select. Empty allows every registered skill.
ModelSpec
¶
Bases: BaseModel
A model exposed to the root agent for spawned-agent selection.
model_client
class-attribute
instance-attribute
¶
Model name or ADK BaseLlm. Defaults to id. Never shown to the model.
description
class-attribute
instance-attribute
¶
When to use this model, shown to the root agent.
capabilities
class-attribute
instance-attribute
¶
Short capability tags shown to the root agent, such as reasoning.
ThinkingConfig
¶
Bases: BaseModel
Model thinking settings, mapped to ADK's BuiltInPlanner.
enabled
class-attribute
instance-attribute
¶
Turn thinking on. False attaches no planner.
include_thoughts
class-attribute
instance-attribute
¶
Ask the model to return thought summaries, so a UI can show reasoning.
thinking_budget
class-attribute
instance-attribute
¶
Maximum thinking tokens. None uses the model default.
CompactionConfig
¶
Bases: BaseModel
ADK event compaction settings.
When the latest prompt exceeds token_threshold, older events are
summarized with a prompt written for long-running work. The task ledger is
stored separately in session state and is never lost to compaction.
token_threshold
class-attribute
instance-attribute
¶
Prompt token count that triggers compaction.
event_retention_size
class-attribute
instance-attribute
¶
Number of most recent events kept verbatim after compaction.
compaction_interval
class-attribute
instance-attribute
¶
ADK's invocation-count trigger. The high default leaves compaction
driven by token_threshold.
overlap_size
class-attribute
instance-attribute
¶
Events shared between consecutive compaction windows.
SandboxConfig
¶
Bases: BaseModel
Declarative sandbox configuration for create_deep_agent.
working_dir
class-attribute
instance-attribute
¶
local only. Workspace directory; a temporary one is used when unset.
image
class-attribute
instance-attribute
¶
daytona and e2b only. Template, snapshot, or image name.
timeout
class-attribute
instance-attribute
¶
daytona and e2b only. Sandbox time-to-live in seconds.
api_key
class-attribute
instance-attribute
¶
daytona and e2b only. Overrides the backend API-key env var.
api_url
class-attribute
instance-attribute
¶
daytona only. Overrides DAYTONA_API_URL.
env_vars
class-attribute
instance-attribute
¶
Environment variables set inside the sandbox, not in this process.
max_output_chars
class-attribute
instance-attribute
¶
Truncation limit applied to sandbox tool output before the model sees it.
sandbox_bin
class-attribute
instance-attribute
¶
cloud_run only. Overrides the guest sandbox binary path.
allow_egress
class-attribute
instance-attribute
¶
cloud_run only. Whether the sandbox may reach the network.
validate_environment
class-attribute
instance-attribute
¶
Preflight credentials and packages while building the agent.
Background subagents¶
BackgroundTask
¶
Bases: BaseModel
Status of one background spawned subagent.
result
class-attribute
instance-attribute
¶
Final text of the child, once completed.
get_background_task
¶
get_background_task(task_id: str) -> BackgroundTask | None
Return the current status of one background task.
list_background_tasks
¶
list_background_tasks(
*,
session_id: str,
app_name: str | None = None,
user_id: str | None = None,
) -> list[BackgroundTask]
Return background tasks started from one root session, oldest first.
stream_background_task_events
async
¶
Yield the child's raw ADK events: buffered ones first, then live ones.
The iterator ends when the background task finishes.
wait_for_background_task
async
¶
wait_for_background_task(task_id: str) -> BackgroundTask
Wait until a background task finishes and return its final status.
cancel_background_task
¶
Cancel a running background task. Returns False if it already finished.
Asking the user¶
ElicitationRequest
¶
Bases: BaseModel
Stable UI-facing projection of an ADK request_input interruption.
project_elicitation_event
¶
project_elicitation_event(
event: Event,
) -> ElicitationRequest | None
Project an ADK request_input function call for a client UI.
create_elicitation_response
¶
create_elicitation_response(
request: ElicitationRequest, answers: Any
) -> Content
Build the user-role FunctionResponse that resumes an elicitation.
Interrupted tool calls¶
ToolCallRepairPlugin
¶
Bases: BasePlugin
Answer dangling tool calls before every model request.
repair_dangling_tool_calls
¶
Insert synthetic results for unanswered tool calls, in place.
Returns the number of synthetic results inserted.
Sandbox helpers¶
SandboxConfigurationError
¶
Bases: RuntimeError
Raised when a sandbox backend is selected but not usable.
missing_sandbox_requirements
¶
missing_sandbox_requirements(
config: SandboxConfig,
) -> list[str]
Return unmet requirements for a sandbox config, in report order.
describe_sandbox_requirements
¶
Return human-readable setup requirements for one sandbox backend.
sandbox_requirements_report
¶
sandbox_requirements_report(
kinds: Sequence[SandboxKind] = (
"local",
"daytona",
"e2b",
"cloud_run",
),
) -> str
Return setup requirements for the given sandbox backends.
SandboxRequirements
¶
Bases: BaseModel
Environment variables and packages one sandbox backend needs.
Task ledger¶
TaskLedgerItem
¶
Bases: BaseModel
One task item in the deep-agent ledger.
TaskLedgerResult
¶
Bases: BaseModel
Tool response returned by the built-in todo tool.
TaskLedgerSummary
¶
Bases: BaseModel
Counts for the current ledger.
Constants¶
| Name | Value | Meaning |
|---|---|---|
LEDGER_STATE_KEY |
"adk_agent_harness:todos" |
Session state key holding the task ledger |
REQUEST_INPUT_TOOL_NAME |
"adk_request_input" |
ADK's elicitation tool name |
SANDBOX_TOOLSET_NAME |
"environment" |
Tool name spawned subagents use to get the sandbox |
SANDBOX_REQUIREMENTS |
dict | Install and environment requirements per sandbox backend |