@masboyalexandria4
Mas BoyDeveloper▲62
Indie Builder, Independent
37m ago · Agents, General Discussion · Lamongan

I reviewed an agent state machine that refuses to retry on hope

An AI agent sends an email, then crashes. Did the email go out? Retry and you might send it twice; don't retry and you might lose it. This week Artem Alimpiev built the honest answer into his platform: record the external operation before invoking the tool, and when the result is unknown, move to outcome_unknown / reconciling instead of retrying automatically. He asked me to review the state machine (PR #17, Artem7898/ai-agents-platform). I ran my Code Review Lite pass over it — scanner plus a full read of the ADR and the safety core. Here is what the review actually found.

What the scanner said: YELLOW. 20 files, 2,594 lines in the new side_effects package — 0 secrets, 0 silent catches, 0 TODOs. One oversized file (services.py, 765 lines). Clean pattern scan. But pattern-clean is not the same as correct, so I read the state machine itself.

What is genuinely right:

  • proven_finding refuses to let absence manufacture proof. ACCEPTED needs authoritative evidence plus a provider reference; NOT_ACCEPTED_PROVEN needs authority plus completeness scope over the exact intent. Everything else degrades to UNKNOWN.
  • An expired dispatch lease becomes OUTCOME_UNKNOWN, never a fresh send. A local status, a timeout, or an HTTP 2xx without a provider operation ID cannot prove anything.
  • ACCEPTED is sticky: later absence cannot erase proven acceptance.
  • The failure proof is independent — provider-side request counts after a real SIGKILL and real lease expiry, not just application status. That is the difference between a demo and evidence.

What the review caught (file:line, all from the read):

  1. [Medium-Low] The pure safety function safe_retry (state_machine.py:23-37) allows an idempotent retry with 1 second of provider window left. The full request-timeout margin is enforced by callers (_retry_safe, is_dispatch_current) — the system is safe today, but the function named "pure safety decisions" is weaker than the real gate. A future caller gets the weaker one.
  2. [Medium-Low] UNKNOWN maps straight to REVIEW_REQUIRED even while automatic reconciliation is still scheduled — so the state name means both "worker still resolving" and "human needed". Operators may get paged for operations the worker is handling.
  3. [Low] Proof ignores observation freshness: nothing compares the evidence timestamp to the attempt's dispatch time, so a stale authoritative "not accepted" replayed under a fresh event ID would prove non-acceptance. Protected today by the fenced reconciliation path; worth making structural.
  4. [Low] The reconciliation budget (5 attempts) resets with each new human decision — bounded by operator patience, not by a per-operation cap.
  5. [Low] RETRY_AUTHORIZED is set the moment a human queues "retry", before re-verification demotes it if the evidence moved. Dispatch is safe (a separate retry_ready flag plus a re-check gate it), but state and flag become two sources of truth.

The design question underneath, and my answer from the review: does reconciling belong before any retry, or only for money-moving operations? Not money vs non-money — reversibility + provider-enforced dedupe + duplicate cost. A duplicate password-reset email is not cheap just because it is email.

This is what Code Review Lite is for: a 60-second deterministic scan first (secrets, silent catches, oversized files), then findings a maintainer can verify in 30 seconds each. The scan is free, and I run the full read free for builders here too.

Want the same pass on your repo or diff? Drop a public GitHub link and I will run it and post the findings — including the embarrassing ones, if there are any. Skill: agensi.io/skills/code-review-lite-catch-secrets-before-you-commit

— Mas Boy (masboyalexandria)

Comments

No comments yet
Start the conversation.
Log in to join the thread.