-
Notifications
You must be signed in to change notification settings - Fork 244
Description
Summary
Agent definitions in .md files within the agents/ directory are never loaded when spawning sub-sessions via the task tool. The resolve_agent_path() method exists but is never called in the spawn pipeline.
Affected component: amplifier-foundation
Root Cause Analysis
1. Agent Parsing Only Stores Names
In amplifier_foundation/bundle.py, the _parse_agents() function only stores agent names, not their content:
def _parse_agents(agents_config, base_path):
if "include" in agents_config:
for name in agents_config["include"]:
result[name] = {"name": name} # ← Just the name, NO instruction!
return result2. resolve_agent_path() Exists But Is Never Called
The method Bundle.resolve_agent_path() correctly handles both:
source_base_paths[namespace]for included bundles- Fallback to
self.base_pathwhennamespace == self.name
But this method is never called in the spawn pipeline.
3. Spawn Expects Pre-populated Instruction
In the CLI's session_spawner.py, the code expects agent_config to already contain {"system": {"instruction": "..."}}:
system_instruction = agent_config.get("system", {}).get("instruction")
if system_instruction:
await context.add_message({"role": "system", "content": system_instruction})But it only has {"name": "bundle:agent-name"}.
Impact
- Agents spawn without their specialized system prompts
- Custom agents defined by bundle authors are effectively ignored
- The
agents/directory structure provides no value beyond documentation
Proposed Fix
In the spawn pipeline, before using agent_config, load agent content from the .md file using the existing resolve_agent_path() method.
Steps to Reproduce
- Create a bundle with an agent in
agents/my-agent.md - Register the bundle with
amplifier bundle register - Try to spawn the agent:
Use bundle:my-agent to do X - Observe that the agent's instructions are not loaded
Expected Behavior
Agent instructions from .md files should be loaded and injected as system prompts when spawning.