<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/our-approval-gate-refused-a-valid-approval-then-took-the-identical-one-on-retry--8gwydjbla" -->

---
title: Our approval gate refused a valid approval, then took...
description: An engineer describes a subtle race condition in an approval gate designed to let a human authorize an AI agent's actions (sending email or pushing to prod)...
canonical: https://daily.dev/posts/our-approval-gate-refused-a-valid-approval-then-took-the-identical-one-on-retry--8gwydjbla
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Our approval gate refused a valid approval, then took the identical one on retry. | daily.dev
og:description: An engineer describes a subtle race condition in an approval gate designed to let a human authorize an AI agent's actions (sending email or pushing to prod)...
og:url: https://daily.dev/posts/our-approval-gate-refused-a-valid-approval-then-took-the-identical-one-on-retry--8gwydjbla
og:image: https://api.daily.dev/og/posts/8gWYDJBlA.png
og:image:alt: Our approval gate refused a valid approval, then took the identical one on retry.
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Our approval gate refused a valid approval, then took the identical one on retry.

**[AlphAI](https://daily.dev/sources/alphai)** · [@mikhailmakeev](https://daily.dev/mikhailmakeev) · 2 min read · 0 upvotes · 0 comments

## Summary

An engineer describes a subtle race condition in an approval gate designed to let a human authorize an AI agent's actions (sending email or pushing to prod) from their phone. The gate checked an archive file written only by bash (never the model) for an affirmative approval, but the archive was only updated after a run exited cleanly, so a valid approval issued during that same run wasn't yet recorded when checked, causing a false rejection that succeeded on retry. The fix was to read both the archive and the in-flight file rather than archiving before running the model, since the real invariant needed was who writes the file, not which file it lives in. Seven new test fixtures were added, bringing the self-test suite to 39 cases.

## Content

Four checks, every one of them mechanical, and all four passed. The gate still said no.

What it guards is an agent that can send email or push to prod, but only once I approve the exact payload from my phone. A model can talk itself into believing it was approved, so the gate never asks the model anything. It reads an archive of incoming Telegram messages that only bash writes, and it wants an affirmative that postdates the payload. The model's hand never touches that file. That's the whole design.

My approval was in the right place. It just hadn't got there yet. The handler appends a run's inbox to the archive only after the model exits cleanly, and my approval was being processed by the very run that would later archive it. At the moment of the check the fact genuinely wasn't recorded. The gate was right about the file and wrong about the world.

It cost a round trip, not a hole. My next message found it archived and everything passed. But the class is worth more than the bug: a condition meant to verify "this happened" was verifying "this was written down", and written-down lags happened by one cycle.

Two ways out. Archive the inbox before running the model, which closes the race and quietly deletes the retry path, since a crashed run's unprocessed queue is exactly what the next run picks up. Or read both the archive and the in-flight file, which is what I took. The property I needed was never which file the message sits in. It's whose hand writes the file, and bash writes both of them.

Seven new fixtures cover this race, 39 in the selftest now. The one I care about is the case where the archive is empty and the approval exists only in flight.

If you've built an approval gate for an agent: what's your anchor, and can the agent reach it?

## Similar posts on daily.dev

- [I Replaced a Gate That Accepted Everyone With a Gate That Accepted No One. My Tests Couldn't Tell the Difference.](https://daily.dev/posts/i-replaced-a-gate-that-accepted-everyone-with-a-gate-that-accepted-no-one-my-tests-couldn-t-tell-th-edgsbh2jp) · DEV · 0 upvotes · 0 comments
- [The Night My Coding Agents Waited for Me](https://daily.dev/posts/the-night-my-coding-agents-waited-for-me-xmem5ecsm) · Callstack Blog · 2 upvotes · 0 comments
- [Build an agent approval flow that survives a restart](https://daily.dev/posts/build-an-agent-approval-flow-that-survives-a-restart-vobmkr0vl) · Flavio Copes · 1 upvotes · 0 comments
- [I Audited My AI Agent's Guardrails. Most of Them Weren't Running.](https://daily.dev/posts/i-audited-my-ai-agent-s-guardrails-most-of-them-weren-t-running--iejklp8mp) · The Infinity · 2 upvotes · 0 comments
- [Our PR gate has just 17 tests, and here's why](https://daily.dev/posts/our-pr-gate-has-just-17-tests-and-here-s-why-71xuiiwf7) · Mabl Engineering Blog · 0 upvotes · 0 comments

---

Tags: [#testing](https://daily.dev/tags/testing), [#ai-agents](https://daily.dev/tags/ai-agents), [#telegram](https://daily.dev/tags/telegram)

[View this post on daily.dev](https://daily.dev/posts/our-approval-gate-refused-a-valid-approval-then-took-the-identical-one-on-retry--8gwydjbla)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"DiscussionForumPosting","mainEntityOfPage":"https://daily.dev/posts/our-approval-gate-refused-a-valid-approval-then-took-the-identical-one-on-retry--8gwydjbla","headline":"Our approval gate refused a valid approval, then took the identical one on retry.","text":"An engineer describes a subtle race condition in an approval gate designed to let a human authorize an AI agent's actions (sending email or pushing to prod) from their phone. The gate checked an archive file written only by bash (never the model) for an affirmative approval, but the archive was only updated after a run exited cleanly, so a valid approval issued during that same run wasn't yet recorded when checked, causing a false rejection that succeeded on retry. The fix was to read both the archive and the in-flight file rather than archiving before running the model, since the real invariant needed was who writes the file, not which file it lives in. Seven new test fixtures were added, bringing the self-test suite to 39 cases.","url":"https://daily.dev/posts/our-approval-gate-refused-a-valid-approval-then-took-the-identical-one-on-retry--8gwydjbla","datePublished":"2026-09-15T11:37:50.601Z","dateModified":"2026-09-15T11:38:07.294Z","author":{"@type":"Person","name":"Mikhail Makeev","url":"https://daily.dev/mikhailmakeev","image":"https://lh3.googleusercontent.com/a/ACg8ocIjcvDU1gmJ9-KJDeTYqY2rMdl5QxcWYtLTGSXrj8ubF4nwar_w=s96-c","description":"Owner of alphai.io","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":5400}},"image":"https://media.daily.dev/image/upload/s--wvb1yvF3--/f_auto/v1789472270/posts/8gWYDJBlA?_a=BAMAMicg0","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"isPartOf":{"@type":"WebPage","url":"https://daily.dev/squads/alphai","name":"AlphAI"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"AlphAI","item":"https://daily.dev/squads/alphai"},{"@type":"ListItem","position":3,"name":"Our approval gate refused a valid approval, then took the identical one on retry."}]}
```

