flower: retry prompts that pi 1.x rejects without calling preflightResult #40
Loading…
Reference in a new issue
No description provided.
Delete branch "flower/preflight-reject-compat"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Splits the one code change that the pi-coding-agent 1.x bump in #39 needs out of that PR. It works on both versions, so it can land first.
The problem. In 1.x,
PromptOptions.preflightResultis no longer called when pi rejects a prompt (an auth failure or a missing API key). In 0.84.4 it was called withfalse. On acceptance, 1.x passes"handled" | "queued" | "started"where 0.84.4 passedtrue.runtime.mjscheckedpreflightAccepted === false, so on 1.x a rejected prompt counted as an accepted turn. Flower then failed closed with "outcome is uncertain" and refused every retry. The existing test didn't catch this because its mock still callspreflightResult(false).The fix.
modules/flower/pi/runtime.mjs:276-282records acceptance asaccepted !== false, and a throw is treated as a rejection unless the callback ran.false, so the turn counts as rejected (same behaviour as before).Test.
runtime.test.mjsadds a case wherepromptthrows without callingpreflightResult; the retry must succeed. I ran it in a throwawaynode:22container with no network:runtime.mjs, the new case fails.🤖 Generated with Claude Code
Landed in #39 (merged together with the npm audit fixes). Closing.