Implement initial PyAutoBrain Build Agent - #3
Merged
Conversation
The Build Agent is the executive/orchestration layer for execution work. It
does not build software itself — PyAutoBuild does. It decides whether, what, and
which PyAutoBuild capability to invoke, then delegates. This makes it the
canonical example of the Brain coordinating multiple organs.
Architectural centrepiece: Brain agents consult one another. The Build Agent
does not query PyAutoHeart directly — it consults the sibling Health Agent, and
only the Health Agent talks to the Heart organ:
Mind -> Build Agent -> Health Agent -> Heart -> GREEN/YELLOW/RED
-> Build Agent -> PyAutoBuild (execute)
Release is kept as a *mode* (build/deploy/release) with a clean seam to a future
Release Agent: release reasoning is isolated, consults health more strictly
(refreshes the verdict first), and never bleeds into generic build execution.
- agents/build/build.sh: deterministic entrypoint. Parses mode/action, consults
the Health Agent, applies a per-mode gate (build lenient, deploy/release need
--force on yellow, red always aborts, unknown collapses to yellow), emits a
structured BuildDecision (JSON), then delegates to the matching autobuild
capability. --dry-run plans without executing.
- agents/build/AGENTS.md: concise agent doc (<200 lines) incl. the BuildDecision
schema and mode/gate table.
- agents/build/BUILD_CAPABILITIES.md: audit of every PyAutoBuild execution
capability the agent calls, plus the boundary finding that the health-shim
commands (verify_install, url_check, watch/status/tick/fix) belong to Heart
and are refused here — reached via `pyauto-brain health`.
- agents/_common.sh: consult_health_agent_verdict helper (agent-to-agent
consult, pipefail-safe).
- bin/pyauto-brain: register the build agent (listed first).
- README.md, AGENTS.md: document the organism, multi-organ coordination, the
society-of-agents pattern, and the future Release Agent split.
Validated: dispatcher listing, help, all gate policies (green/yellow/red/
unknown across the three modes), health-shim rejection, invalid mode/action,
and the full green happy path delegating to a stubbed autobuild.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Self-review of the Build Agent surfaced one real bug: - `--mode` as the final argument (no value) caused an infinite loop: under `set -uo pipefail` (no errexit), `shift 2` fails when only one positional remains, the loop condition stays true, and `$1` is still `--mode`, so it spins forever. Guard with an explicit arity check that errors (exit 5) when `--mode` has no value. - Removed a leftover no-op line (`[[ ... ]] || true`) that computed and discarded a condition. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds the Build Agent — the second canonical PyAutoBrain reasoning agent and the reference example of the Brain coordinating multiple organs. It is the executive/orchestration layer for execution work: it owns the build workflow but delegates the building to PyAutoBuild and the health decision to the Health Agent. It reasons; PyAutoBuild executes.
Implements the task in
PyAutoMind/feature/pyautobrain/build.md.Architecture
The centrepiece: Brain agents consult one another. The Build Agent does not query PyAutoHeart directly — it consults the sibling Health Agent, and only the Health Agent talks to the Heart organ.
This generalises to a future society of agents (Feature Agent asks Health Agent about refactor readiness; Release Agent asks Build Agent to package).
Release as a mode, with a clean seam
Release is in scope today (PyAutoBuild owns release/build/deploy execution) but isolated as a mode, so release-specific reasoning never bleeds into generic build execution and can split into a dedicated Release Agent later — one agent now, clean seam for two later.
buildrun_alldeploygenerate--force, RED abortsreleasepre_build--force, RED abortsAn unknown verdict collapses to YELLOW — never silently GREEN.
Files
agents/build/build.sh— deterministic entrypoint. Parses mode/action, consults the Health Agent, applies the per-mode gate, emits a structuredBuildDecision(JSON), then delegates to the matchingautobuildcapability.--dry-runplans without executing.agents/build/AGENTS.md— concise agent doc (<200 lines) incl. theBuildDecisionschema and mode/gate table.agents/build/BUILD_CAPABILITIES.md— audit of every PyAutoBuild execution capability the agent calls, plus the boundary finding: the health-shim commands (verify_install,url_check,watch/status/tick/fix) belong to Heart and are refused here, reached viapyauto-brain health.agents/_common.sh—consult_health_agent_verdicthelper (agent-to-agent consult, pipefail-safe).bin/pyauto-brain— register the build agent (listed first).README.md,AGENTS.md— document the organism, multi-organ coordination, the society-of-agents pattern, and the future Release Agent split.BuildDecision
{ "agent": "build", "mode": "build|deploy|release", "requested_action": "<PyAutoBuild capability>", "health_status": "green|yellow|red|unknown", "decision": "proceed|proceed-with-caution|abort", "execution_plan": ["autobuild <action> <args>"], "execution_summary": "<one line>", "warnings": ["..."], "blockers": ["..."], "follow_up_recommendations": ["..."], "dry_run": false }Validation
Exercised end-to-end with stubbed Heart/autobuild:
help,help build,build --help,pyauto-agentback-compat shim--dry-run(plan only, no execution)build tick→ pointed atpyauto-brain health)autobuildwith forwarded args.mdfiles under the 200-line guidance; bash syntax checks passNo existing functionality regresses — every PyAutoBuild execution capability remains usable through the Build Agent.
🤖 Generated with Claude Code
Generated by Claude Code