Skip to content
This repository was archived by the owner on Nov 25, 2026. It is now read-only.
This repository was archived by the owner on Nov 25, 2026. It is now read-only.

Agent First Breath: an interrupted init-sanctum leaves a half-built sanctum that wake.py and init-sanctum.py then deadlock on; CAPABILITIES.md table not escaped #150

Open

Description

@CloneOfAlex

Describe the bug

This affects the memory-agent scaffolding emitted by skills/bmad-agent-builder/assets/init-sanctum-template.py and wake-template.py, and every sample agent built from them.

1. Interrupted First Breath permanently bricks the agent. init-sanctum.py creates _bmad/memory/<skill>/ first, then copies references, scripts and templates, and writes CAPABILITIES.md. If anything fails after the mkdir, the sanctum is left half-built: a missing or unreadable reference, a decode error, a full disk, or a killed session. After that:

  • wake.py checks for CREED.md + MEMORY.md. They're missing, so it prints MODE: FIRST_BREATH / NO SANCTUM at ..., even though the directory exists.
  • first-breath.md tells the agent to run init-sanctum.py, which sees the directory and prints "This agent has already been born. Skipping First Breath scaffolding."

Every activation loops between the two. Only a manual rm -rf of the sanctum recovers it.

2. CAPABILITIES.md rows are not escaped. generate_capabilities_md() writes each capability's description raw into a markdown table. A | in a description adds a cell and corrupts the row. A folded description: > (the frontmatter parser is line-based) appears as >.

Steps to reproduce

cp -r samples/bmad-agent-sentinel /tmp/s/skill && mkdir -p /tmp/s/proj/_bmad && cd /tmp/s
# (1) simulate a failure after the sanctum dir is created
mv skill/references skill/refs_moved
python3 skill/scripts/init-sanctum.py proj skill      # FileNotFoundError ... skill/references
mv skill/refs_moved skill/references                  # cause fixed
python3 skill/scripts/wake.py proj | head -2          # MODE: FIRST_BREATH / NO SANCTUM at ...
python3 skill/scripts/init-sanctum.py proj skill      # "This agent has already been born. Skipping..."
ls proj/_bmad/memory/bmad-agent-sentinel              # capabilities references sessions  (no PERSONA/CREED/MEMORY/CAPABILITIES)

# (2) table escaping
rm -rf proj/_bmad/memory
sed -i 's/^description:.*/description: Scans risks | ranks them by impact/' skill/references/risk-radar.md
python3 skill/scripts/init-sanctum.py proj skill
grep risk-radar proj/_bmad/memory/*/CAPABILITIES.md
# | [RR] | risk-radar | Scans risks | ranks them by impact | `./references/risk-radar.md` |   <- 5 cells

Expected behavior

  • Build the sanctum in a temp sibling directory (<skill>.tmp-<pid>) and os.replace it into place only after everything is written, or write a completion marker last. Treat "dir exists but no marker / no CREED.md" as resume or repair, not already born.
  • Make wake.py's message accurate ("incomplete sanctum at ...") and route to repair.
  • Escape | (and newlines) in table cells, and parse capability frontmatter with a YAML parser so folded and literal descriptions work.

Environment

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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