My Spec Said Fail-Closed. My Agent Read the Code and Said Otherwise
I asked my agent fleet to gate tasks on GitHub's native blocked-by links and to fail closed like the old marker. The marker fails open on purpose. The executor read the code, flagged my wrong spec, and shipped a gate that costs zero extra API calls.

Executive Summary
I asked my agent fleet to gate task claims on GitHub's native "blocked by" links, and I wrote in the issue that the new gate "must fail closed, mirroring the marker." The existing marker gate does not fail closed. It fails open, on purpose, and the executor that picked up the issue read the code, saw the contradiction, and wrote it down under "Deviations & decisions" instead of building what I had asked for.

The feature itself shipped on 2026-11-09. The native dependency count rides the board snapshot the daemon already fetches, it is checked first, and it can only hold a task, never release one. The old HTML marker stays as the fallback. This article covers how the gate works, why one GraphQL field was enough, and why the most useful line in the pull request was the one that said my spec was wrong.
The Gate Before the Change
agent-corp is my autonomous agent fleet. A daemon polls a GitHub Projects board, claims issues, and runs each one as headless Claude Code in a Docker container. Some issues depend on others: a sub-issue should not start until its foundation issue is merged, so that its branch is cut from the foundation's merged state.
For months, that dependency lived in the issue body as an invisible HTML comment:
The number is the foundation issue, not a count. On every poll, the daemon reads the marker off the body it already has from the board snapshot, looks up the state of each listed foundation issue, and holds the task until every one of them is closed. The state lookups are memoized per poll cycle, so several dependents on one foundation share a single read. A held task does not burn a launch slot, so a blocked task at the head of the queue cannot starve the launchable tasks behind it.
The error path is the part that matters here. If a state read hits GitHub's rate limit, the exception propagates and the poll loop backs off. Any other error on a state read is treated as "this foundation is satisfied." The docstring explains the reasoning: the worst case of failing open is one premature launch on a transient error, while failing closed could strand a dependent task forever. I had decided that tradeoff months earlier and then forgot it.
Security terminology versus queueing behavior
"Fail-closed" comes from security: if a firewall cannot evaluate its policy, it drops the connection. A task scheduler has a different failure domain. If every metadata hiccup blocks execution, one flaky API call can freeze a dependent task indefinitely. If every hiccup permits execution, a dependency can occasionally be violated.

| Failure mode | Result | Primary risk |
|---|---|---|
| False blocked | Eligible task is not claimed | Stranded task, queue delay |
| False unblocked | Task runs before its foundation merges | Branch cut from the wrong base, wasted run |
| Unknown state | A foundation's state cannot be read | Needs an explicit policy, not an accident |
My marker gate had picked availability for the unknown-state row. My issue described it as the opposite.
What the Executor Found
My issue asked for two things: gate the claim on native "blocked by" relationships, and make that gate fail closed "mirroring the marker." The executor read _foundation_blocked, found the fail-open branch and its docstring, and recorded this under "Deviations & decisions" in the pull request:
The marker actually fails open on a read error (a flaky read must never strand a queued task). The native path has no read to fail — it is a snapshot field. When the field is absent, it defers to the marker, i.e. the behaviour before this change. No fail-closed branch added; the issue text was wrong about the marker.
That is the behaviour I want from an agent. It did not quietly add a fail-closed branch that would have changed queue semantics, and it did not quietly ignore the requirement. It named the contradiction, explained why the requirement no longer applied to the new design, and left the decision visible in the place I review.
Why One GraphQL Field Was Enough
GitHub exposes issue dependencies in several shapes: REST endpoints that list blockers, GraphQL connections, and issueDependenciesSummary, an object with aggregate counts. The executor probed the counts live on the issue it was working on, with temporary links and removed it afterwards:
| Link state | blockedBy | totalBlockedBy |
|---|---|---|
| Blocked by one closed issue | 0 | 1 |
| Plus blocked by one open issue | 1 | 2 |
| Both links removed | 0 | 0 |
blockedBy counts only open blockers; totalBlockedBy counts open and closed. So "every blocker is closed" is exactly blockedBy == 0, and the gate needs no per-blocker state reads at all.Because the summary is an object, not a connection, adding it to the board query costs nothing extra against the GraphQL rate limit. The daemon already fetches the board once per snapshot; the count simply rides along. A test, test_no_extra_call_per_item, pins one fetch for twenty items, and the native-path tests wire the per-issue state lookup to raise, so any accidental extra call fails the suite. Before merge, the new query was run against the real board: the field was present on 100 out of 100 issues on the first page.
The alternative would have looked like this:
fetch board
for each issue:
list its blockers
read each blocker's state
That is request fan-out, more latency, more rate-limit exposure, and more partial-failure cases, all to answer a question one integer already answers.
How the Gate Works Now
The native count is checked first. If it is above zero, the task is held, and that decision needs no read. If it is zero or missing, the marker path runs exactly as before:
def foundation_blocked(task, closed_cache):
# Native count from the board snapshot: no extra call.
if task.deps_blocked_by: # > 0 open native blockers
return True
# Zero or None: the HTML marker decides, unchanged.
for n in parse_blocked_by(task.body):
if (task.repo, n) not in closed_cache:
try:
closed_cache[(task.repo, n)] = issue_state(task.repo, n) == "CLOSED"
except RateLimited:
raise # poll loop backs off
except Exception:
closed_cache[(task.repo, n)] = True # fail open
if not closed_cache[(task.repo, n)]:
return True
return False
Three properties fall out of that order:
None, never a measured 0, and the gate behaves exactly as it did before the change.There is one more half. When the fleet publishes a new idea with a marker, publish_idea now mirrors it as a native addBlockedBy link, so the dependency shows up in GitHub's Relationships panel where I actually look. That mirror is best-effort: the marker alone would still hold those issues, so a failed link never fails the publish.
Testing That the Wire Is Connected
A new field can be parsed, stored, and never consulted. To check that the native count actually drives the decision, the pull request ran two mutants:
if False: makes one test fail.deps_blocked_by= from the snapshot parse makes two tests fail.Both mutants die, so the field reaches the decision and the decision is observable. The targeted suite passed 131 tests locally, and all four CI jobs passed on the reviewed head.
What I Take From It
The bug in this story is not in the code. It is in my issue, which described a design decision I had made months earlier as its opposite. An executor that treats the issue text as ground truth would have shipped a fail-closed branch nobody needed and changed how the queue behaves under GitHub hiccups, and the review would have checked the diff against the same wrong sentence.
What prevented that was a convention, not a model capability: every executor pull request has a "Deviations & decisions" section, and diverging from the issue silently is not allowed. The executor still has to read the code before it can notice anything. The section makes sure that what it notices reaches me.
Actionable Takeaways
blockedBy == 0 replaced a per-blocker state loop.if False:) to prove a newly parsed field actually drives a decision.FAQ
What does fail-closed mean for an automated task queue?
Fail-closed means an unavailable or uncertain check prevents the task from running. In a queue, that protects ordering but can strand a task during a metadata outage, so the choice has to be explicit. My dependency gate deliberately fails open on a non-rate-limit read error.
Should GitHub native blocked-by links replace an HTML dependency marker?
Not in one step. In agent-corp, the native count is checked first and can hold a task, while the marker remains the fallback for issues that carry only the marker. New ideas get both, with the native link mirrored on a best-effort basis.
Why is blockedBy different from totalBlockedBy?
blockedBy counts currently open blockers, while totalBlockedBy counts open and closed ones. If the rule is "every blocker is closed," the condition is blockedBy == 0; totalBlockedBy stays positive after blockers close.
How should an agent handle a specification that contradicts the code?
Read the existing behaviour, name the contradiction, explain the tradeoff, and avoid silently changing failure semantics. In my fleet, that goes into the pull request's "Deviations & decisions" section, which I review before the diff.
How can dependency checks avoid excessive API calls?
Request an aggregate summary inside the board snapshot you already fetch. issueDependenciesSummary is an object rather than a connection, so it adds no per-issue calls and no extra GraphQL rate-limit cost.
Related reading
Sources
Maksym Tytarenko
AI & SaaS Development Expert at Tytarenko AI Agency
Get the next article in your inbox
One email when a new article is published. No spam, unsubscribe in one click.
Related Articles
Flagging Tests That Assert Nothing, When All You Can See Is the Diff
My merge-card scanner caught assertions being removed but never noticed a new test that had none. Closing that gap meant giving up on syntax trees, teaching the scanner to know when it is looking at a cropped view of a file, and measuring the false-positive rate on thirty merged pull requests before the line ever reached a human.
10 min readAutomationFour Merge Presses, One Merge: Fixing the Approval Layer of My AI Agent Fleet
I pressed Merge on four agent pull requests and only one merged. The bug was an ack sitting upstream of the action, a serial update queue I was silently relying on, and a merge digest that could not see two PRs colliding on the same files.
14 min readAutomationThe Sweep Ran Every Hour. Fifty Closed Tasks Still Weren't Done.
My agent fleet's task board had an hourly sweep that moved closed issues to Done, and 50 closed issues still weren't Done. One board read showed why: every stuck card sat in a status the sweep never checked. The fix widened one list, cut the sweep's API cost by 99%, and taught it which cards it must report instead of touching.
9 min readReady to Build Your AI-Powered Solution?
Let's discuss how we can help you leverage AI to transform your business.
Get in Touch