Skip to content

fix(headless): retry malformed meta-agent candidates - #382

Merged
Astro-Han merged 2 commits into
mainfrom
codex/rsi-meta-agent-retry
Jul 1, 2026
Merged

Astro-Han merged 2 commits into
mainfrom
codex/rsi-meta-agent-retry

Conversation

@Astro-Han

@Astro-Han Astro-Han commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Retry scripted meta-agent completions when returned JSON fails the required candidateRationale schema.
  • Feed back a bounded validation error on retry without including the raw invalid model output.
  • Add regression coverage for the candidateRationale.evidenceRefs string-vs-array crash and invalid JSON retry prompt redaction.

Closes #311.

Why

A real RSI pilot crashed after round-0 because the meta-agent returned candidateRationale.evidenceRefs as a string instead of an array. That is a recoverable schema correction, not a reason to kill the whole run after Harbor work has already been spent.

With #311 scoped to first accepted pilot evidence, this PR also carries the closing validation: the fixed pilot run completed, discarded one flat candidate, kept one improving candidate, passed structural smoke, and preserved the R2 safety boundary.

Scope

Changed:

  • packages/headless/src/prompt-candidate-loop.ts
  • packages/headless/src/__tests__/prompt-candidate-loop.test.ts

Not included:

  • No RSI gate or acceptance-threshold changes.
  • No task-set, profile, budget, provider, or Harbor adapter changes.
  • No reward-hack or trace-attribution behavior changes.
  • No full 10-round Harbor run.

Verification

  • RED: node --test --test-name-pattern "retries scripted meta-agent after candidateRationale schema errors" packages/headless/dist/__tests__/prompt-candidate-loop.test.js failed with candidateRationale.evidenceRefs must be an array before the fix.
  • RED: node --test --test-name-pattern "does not echo invalid JSON text into the meta-agent retry prompt" packages/headless/dist/__tests__/prompt-candidate-loop.test.js failed before the redaction fix because the retry prompt contained SECRET_CAN from SyntaxError.message.
  • GREEN: node --test --test-name-pattern "retries scripted meta-agent after candidateRationale schema errors|does not echo invalid JSON text into the meta-agent retry prompt" packages/headless/dist/__tests__/prompt-candidate-loop.test.js
  • npm run -w @maka/headless test
  • Real pilot run: rsi-meta-retry-pilot-light-20260701-011258
    • structural smoke: pass
    • stopReason: rounds_complete
    • decisions: keep=1, discard=1
    • task events: completed=30, infra_failed=0, plumbing_failed=0
    • cost: 0.119795 / 1.25
    • round-0 decision: discard/held_in_within_noise
    • round-1 decision: keep/held_in_improved
    • held-in improved from 6/8 to 7/8; held-out passed 3/3

User-facing impact

No desktop UI impact. Headless RSI prompt-optimization runs are less likely to waste a run when the meta-agent returns a fixable JSON schema mistake.

Reviewer notes

Run artifacts are under /Users/yuhan/workspace/oss/maka-agent/maka-eval/rsi-runs/rsi-meta-retry-pilot-light-20260701-011258 on the local machine.

@Astro-Han
Astro-Han merged commit 2323195 into main Jul 1, 2026
@Astro-Han
Astro-Han deleted the codex/rsi-meta-agent-retry branch July 1, 2026 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(headless): validate RSI R2 first accepted pilot evidence

1 participant