Home

mweinbach / agent-coworker

publicmweinbach/agent-coworker
Overview Code History Branches Pull requestsIssuesInsights
main
HomeOverview Code PRsIssues

[codex] make child-agent reports parseable (#71)

6 months ago

a8e471b
Authored
Max Weinbach4/12/2026, 12:09:07 AM
* fix: make child-agent results parseable

Child-agent outputs were too loose for the parent to consume reliably, so inspectAgent had to guess at trailing JSON from arbitrary prose.

This makes the completion contract explicit in the role prompts, moves parsing into a server-owned module, and keeps a compatibility fallback for older plain or fenced JSON reports so existing child outputs still inspect cleanly.

Constraint: Keep the existing inspectAgent wire schema and lastMessagePreview behavior unchanged
Rejected: Add a new verdict field to ChildAgentReport | existing status values already cover reviewer PASS/PARTIAL/FAIL mapping
Confidence: high
Scope-risk: moderate
Reversibility: clean
Directive: Keep child-report parsing server-owned and require tagged footers for new prompt contracts; do not move parser heuristics back into shared types
Tested: bun test test/agentReportParser.test.ts test/agentControl.test.ts test/prompt.test.ts test/persistentAgents.tool.test.ts test/tools.test.ts test/server.jsonrpc.control.test.ts test/jsonrpc.control-schemas.test.ts; bun run typecheck; bun test test/run_raw_agent_loops.test.ts; bun test
Not-tested: Remote MCP integration tests skipped by default in bun test

* fix: prefer the trailing child-agent report footer

The initial parser stopped at the first `<agent_report>` tag, which let echoed examples shadow the actual final footer and break inspectAgent parsing for otherwise valid child outputs.

This switches tagged parsing to the last footer in the message, keeps legacy fallback behavior for untagged outputs, and adds a regression test covering earlier example tags.

Constraint: Keep malformed final tagged footers failing closed instead of falling back to earlier tagged content
Rejected: Parse the first valid tagged block | it can still accept an echoed example instead of the real completion footer
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: For footer-style model output parsers, prefer the trailing completion block and keep an explicit regression test for echoed format examples
Tested: bun test test/agentReportParser.test.ts test/agentControl.test.ts test/persistentAgents.tool.test.ts test/run_raw_agent_loops.test.ts; bun run typecheck
Not-tested: Full bun test rerun after this narrow parser-only follow-up; remote MCP tests remain skipped by default

Parentbbeab4c

16 files changed
  • prompts/sub-agents/base.md+9−0
  • prompts/sub-agents/default.md+13−0
  • prompts/sub-agents/explorer.md+12−0
  • prompts/sub-agents/reviewer.md+18−1
  • prompts/sub-agents/worker.md+16−1
  • scripts/run_raw_agent_loops.ts+1−1
  • src/server/agents/AgentControl.ts+1−1
  • src/server/agents/reportParser.ts+60
−0
  • src/shared/agents.ts+0−49
  • tasks/lessons.md+1−0
  • test/agentControl.test.ts+46−3
  • test/agentReportParser.test.ts+120−0
  • test/persistentAgents.tool.test.ts+2−2
  • test/prompt.test.ts+54−1
  • test/server.jsonrpc.control.test.ts+1−1
  • test/tools.test.ts+1−1