FAILURE MAP
← Case archive

FA-99931 / Agent workflow termination / Open access

Workflow: duplicate result decrements pending count twice · case 01

A repeated result event makes the pending tool count negative.

Verified by executionVariant 1 · 7 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

Every result event decrements the count without checking whether work remains.

THE FAILURE

Every result event decrements the count without checking whether work remains.

Unsuccessful approach: Adding one before clamping still leaves a phantom pending count after the final result.

Case contract

Given aggregate pending and result-event counts, return max(0, pending - result_events); event identity is outside this count-only model.

Why this case matters

This toy decision rule isolates one bounded agent-loop completion contract.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(pending, result_events):
    return pending-result_events
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('one result drains', solve(N,1),N-1)
check('duplicate saturates', solve(1,N+2),0)
check('no events', solve(N,0),N)
check('empty pending', solve(0,0),0)
check('one pending duplicate', solve(1,2),0)
check('all drain', solve(N,N),0)
check('excess events', solve(2,5),0)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
one result drains00Passed
duplicate saturates-20Failed
no events11Passed
empty pending00Passed
one pending duplicate-10Failed
all drain00Passed
excess events-30Failed

SHA-256 / 51aae47c7b76e36f62da7b2be319c55c463c751a5de48a075f171d5979f72827

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(pending, result_events):
    return max(0,pending-result_events+1)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('one result drains', solve(N,1),N-1)
check('duplicate saturates', solve(1,N+2),0)
check('no events', solve(N,0),N)
check('empty pending', solve(0,0),0)
check('one pending duplicate', solve(1,2),0)
check('all drain', solve(N,N),0)
check('excess events', solve(2,5),0)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
one result drains10Failed
duplicate saturates00Passed
no events21Failed
empty pending10Failed
one pending duplicate00Passed
all drain10Failed
excess events00Passed

SHA-256 / 69a19bea87b878c92286740d6d1bc306cd0188dd28d43de06480a3fc140a276c

HELD IN THE MEMBER ARCHIVE

The verified repair and its recorded checks are member-only.

This mechanism has 7 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.

Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.

Member access is invitation-based. Sign in with your invited account to inspect the repair.

Sign in to the archive ↗

Verification & scope

Adding one before clamping avoids a negative count but can leave a phantom pending call. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-30T16:48:29.887650+00:00.

Case digest / 473b045cecb0fa3e7ddd30783f9e2edc90ec46092d808421ed7f27af0bb377d1