[Feature Request]: Lightweight Non-Conversational `WorkerAgent(BaseAgent)` for Token-Efficient Workflows and Sub-Agents
Les mainteneurs répondent en général sous 3 jours
@Jacksunwei y travaille déjà.
Depuis le 20/11/2026.
Évaluation
- Difficulté
- 5/5
- Temps estimé
- Plus d'une semaine
- Accessibilité débutants
- 35/100
- Type d'issue
- Fonctionnalité
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- python
- Domaine
- ai-infra-agents
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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
- Langage dominant
- Python
- Étoiles
- 22.3k
- Forks
- 4.4k
- Merge moyen
- 1 j 2 h
- PR mergées (30 j)
- 6
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de google/adk-python
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
google/adk-python#8360 ·
Les mainteneurs répondent en général sous 3 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
google/adk-python#8359 ·
Les mainteneurs répondent en général sous 3 jours
-
Can pin to litellm version be changed?Peut-être pris @llalitkumarrr l’a pris il y a 10 jours. Ouvertemodels
Difficulté 1/5 Moins d'une heure Accessibilité débutants 65/100
google/adk-python#8129 · 2 commentaires · 1 personne assignée ·
Les mainteneurs répondent en général sous 3 jours
-
OpenAPI tools ignore operation- and path-level server overridesPeut-être pris @sanketpatil06 l’a pris il y a 14 jours. Ouvertetools
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
google/adk-python#8064 · 4 commentaires · 1 personne assignée ·
Les mainteneurs répondent en général sous 3 jours
-
Two docstrings in openapi_tool document parameters the signatures do not acceptPeut-être pris @surajksharma07 l’a pris il y a 17 jours. Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
google/adk-python#8024 · 1 commentaire · 1 personne assignée ·
Les mainteneurs répondent en général sous 3 jours
Toutes les issues de google/adk-python
Issues similaires
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
vllm-project/vllm#70030 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
TigreGotico/tugaphone#408 ·
Les mainteneurs répondent en général sous 1 jour
-
needs-triage
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
gke-labs/kube-agents#7308 ·
Les mainteneurs répondent en général sous 1 jour
-
t: bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 3 jours
-
chore
Difficulté 1/5 1-3 heures Accessibilité débutants 88/100
lugassawan/swe-workbench#841 ·