Skip to content

Bug: Agent instructions from .md files are never loaded in spawn pipeline #174

@rysweet

Description

@rysweet

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 result

2. 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_path when namespace == 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

  1. Create a bundle with an agent in agents/my-agent.md
  2. Register the bundle with amplifier bundle register
  3. Try to spawn the agent: Use bundle:my-agent to do X
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions