[Feature Request]: Lightweight Non-Conversational `WorkerAgent(BaseAgent)` for Token-Efficient Workflows and Sub-Agents
維護者通常 3 天內回覆
@Jacksunwei 已經在處理了。
開始於 2026年11月20日。
評估
- 難度
- 5/5
- 預估耗時
- 一週以上
- 新手友好度
- 35/100
- Issue 類型
- 功能
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- python
研究方向
Start by reading BaseAgent, LlmAgent, and the workflow or sub-agent execution paths to understand how agents resolve models, build requests, invoke tools, and write session state. The issue proposes a new WorkerAgent API but does not identify implementation files or tests. Done means implementing the non-conversational execution and state I/O behavior, then adding tests for model inheritance, overrides, input validation, and structured output.
由索引模型根據 Issue 內容生成。
描述
Is your feature request related to a problem? Please describe.
Currently, LlmAgent (aliased as Agent) serves as both the top-level conversational orchestrator and the building block for leaf sub_agents and Workflow nodes.
Using a full conversational LlmAgent for bounded, single-responsibility worker tasks introduces unnecessary token overhead and surface-area coupling:
- Token Bloat from Transcript Inheritance:
LlmAgentruns full conversational flow processors and inheritssession.eventshistory (include_contents='default') by default, forcing leaf workers to re-process unrelated chat turns unless manually disabled on every instance. - Conversational & Routing Surface Area:
LlmAgentexposessub_agents,global_instruction, and autonomoustransfer_to_agentmechanics by default—requiring defensive boilerplate (disallow_transfer_to_parent=True,disallow_transfer_to_peers=True,include_contents='none') for simple task execution. - Repeated Model Configuration: Teams must duplicate
model/ customBaseLlmgateway settings across dozens of leaf workers instead of inheriting the orchestrator's model by default.
Describe the solution you'd like
Introduce a lightweight WorkerAgent class—subclassing BaseAgent directly—engineered as a non-conversational, Single-Responsibility (SR), token-efficient execution kernel for Workflow nodes and sub_agents hierarchies.
Proposed Core API
from pydantic import BaseModel
from google.adk.agents import WorkerAgent, LlmAgent
class AnomalyReport(BaseModel):
is_anomalous: bool
severity: str
summary: str
# 1. Lightweight WorkerAgent: inherits parent model, clean-room context, strict I/O
anomaly_worker = WorkerAgent(
name="anomaly_worker",
description="Evaluates parsed sensor telemetry against baseline thresholds.",
instruction="Inspect {parsed_telemetry} using check_thresholds and return a report.",
tools=[check_thresholds],
input_keys=["parsed_telemetry"],
output_schema=AnomalyReport,
output_key="anomaly_report",
)
# 2. Optional model override for high-volume / low-cost steps
formatter_worker = WorkerAgent(
name="formatter_worker",
model="gemini-2.5-flash", # Explicit override
description="Formats anomaly report into a concise alert summary.",
instruction="Format {anomaly_report} into an alert message.",
input_keys=["anomaly_report"],
output_key="alert_summary",
)
# 3. Root orchestrator owns conversation state and primary model infrastructure
orchestrator = LlmAgent(
name="operations_orchestrator",
model="gemini-2.5-pro",
instruction="Coordinate telemetry anomaly detection and alert formatting.",
sub_agents=[anomaly_worker, formatter_worker],
)
Key Design Pillars
Non-Conversational BaseAgent Execution (Token Reduction):
- Never reads session.events chat history or injects transfer_to_agent tools. Constructs a minimal LlmRequest solely from instruction, tools, and declared input_keys from session.state.
Ancestor Model Inheritance (model: Optional[Union[str, BaseLlm]] = None):
- Defaults to None, walking up self.parent_agent to inherit the nearest orchestrator's resolved BaseLlm instance—while allowing an explicit model override per worker for cost/latency tuning.
Explicit State I/O Contracts (input_keys → output_schema / output_key):
- Validates upfront that declared input_keys exist in ctx.session.state before invoking the LLM, then writes structured output to output_key and exits immediately.
Note on Single-Responsibility (SR) Composition: To enforce strict Single Responsibility at runtime, a WorkerAgent can also be bound to a single Skill and its scoped Command (see #8263), allowing the worker kernel to remain completely domain-agnostic while executing one focused capability with minimal prompt and tool-schema overhead.
Describe alternatives you've considered
-
Subclassing LlmAgent with Defensive Defaults: Even with include_contents='none' and transfer-lock flags, inheriting from LlmAgent still exposes conversational attributes (sub_agents, global_instruction, planner) and executes the full conversational processor pipeline.
-
Writing Custom BaseAgent Subclasses per Pipeline: Forces teams to repeatedly re-implement BaseLlm lookup, tool-call loops, structured output parsing, and state validation across every project.
Impact & Backwards Compatibility
100% Additive: Introduces WorkerAgent(BaseAgent) alongside existing Agent and Workflow classes with zero breaking changes
- 主要語言
- Python
- 星號
- 22.3k
- 分支
- 4.4k
- 平均合併
- 1 天 2 小時
- 30 天內合併 PR
- 6
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
google/adk-python 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
google/adk-python#8360 ·
維護者通常 3 天內回覆
-
難度 2/5 1-3 小時 新手友好度 82/100
google/adk-python#8359 ·
維護者通常 3 天內回覆
-
Can pin to litellm version be changed?可能已有人在做 @llalitkumarrr 於 10 天前認領。 未關閉models
難度 1/5 1 小時以內 新手友好度 65/100
google/adk-python#8129 · 2 則留言 · 已指派 1 人 ·
維護者通常 3 天內回覆
-
OpenAPI tools ignore operation- and path-level server overrides可能已有人在做 @sanketpatil06 於 14 天前認領。 未關閉tools
難度 2/5 1-3 小時 新手友好度 75/100
google/adk-python#8064 · 4 則留言 · 已指派 1 人 ·
維護者通常 3 天內回覆
-
Two docstrings in openapi_tool document parameters the signatures do not accept可能已有人在做 @surajksharma07 於 17 天前認領。 未關閉
難度 1/5 1 小時以內 新手友好度 88/100
google/adk-python#8024 · 1 則留言 · 已指派 1 人 ·
維護者通常 3 天內回覆
查看 google/adk-python 的全部 Issue
相似的 Issue
-
🧫10장-투향
難度 2/5 1-3 小時 新手友好度 65/100
hyunjimoon/golden-cage-book#188 ·
-
agent/scanner bug stage/010-actionable
難度 1/5 1 小時以內 新手友好度 88/100
torch-spyre/spyre-inference#1812 ·
維護者通常 1 天內回覆
-
Bug: fenced drafts inside <think> tags break parsing or are returned instead of the answer可能已有人在做 @aad1tyaaaaa 今天認領。 未關閉
難度 2/5 1-3 小時 新手友好度 76/100
google/langextract#639 ·
維護者通常 1 天內回覆
-
[oblt-aw][autodoc] Update autodoc routing docs for relative in-repo lock uses可能已有人在做 @github-actions 今天認領。 未關閉
難度 1/5 1-3 小時 新手友好度 87/100
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 88/100
維護者通常 1 天內回覆