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

Aperta
#150 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
58/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
markdown, python, yaml
Ambito
tooling

Direzione di ricerca

Start with skills/bmad-agent-builder/assets/init-sanctum-template.py and wake-template.py, then inspect the sample agent scripts generated from them. Trace what happens when initialization fails after creating the sanctum directory and how wake detects an incomplete sanctum; compare recovery behavior with the expected repair flow. Also inspect generate_capabilities_md() and its frontmatter parsing for table cell escaping and folded or literal descriptions. Done means interrupted initialization can recover and generated capability rows preserve descriptions without corrupting the Markdown table.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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

  • Model(s) used: n/a (deterministic script)
  • Agentic IDE used: n/a (scripts run directly)
  • BMad version: bmad-builder main @ d4a921c (v2.2.2 + #118)
  • Project language: Python 3.13, Linux
Lingua principale
Python
Stelle
220
Fork
54
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di bmad-code-org/bmad-builder

Tutte le issue di bmad-code-org/bmad-builder

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.