fix(headless): stop misfiling graded competitor cells as infrastructure failures - #2090
Merged
Merged
Conversation
cleanup_process_scope only ever runs from an adapter's finally while the agent's own exception is in flight, so the exception it raised replaced the one being propagated. An AgentTimeoutError reached Harbor as NonZeroAgentExitCodeError, and the runner read that as an infrastructure failure rather than a graded timeout. In the #1970 three-arm run this cost 10 Claude Code cells, every one of them carrying errorClass=budget_exhausted in its own cell output — the true cause was already on disk while the WAL recorded infra_failed. The maka adapter never calls this teardown, so the failure mode could only land on competitor arms. Teardown is best effort: log and continue. Cancellation still propagates.
incompleteTerminalProviderRequest exempts an `aborted` tail request when the agent phase settled, but the caller only computed agentPhaseSettled inside the abnormal-termination branch. A trial that raised nothing never reached it, so the exemption could not fire on the most ordinary shape of all: an agent that finishes its work and exits while a stream is still open. Three codex cells in the #1970 run were discarded this way with verifier reward 1.0 and no trial exception — passing cells recorded as infrastructure failures. maka produced no aborted tail request in the whole run, so this too could only land on competitor arms. A trial with no exception settled its own agent phase; say so at both call sites.
Astro-Han
force-pushed
the
fix/headless-infra-failed-misclassification
branch
from
August 4, 2026 06:16
fe4d35b to
e73de9e
Compare
Three gaps an external review surfaced, all of which let a revert of the fixes ship green: - The pier runner's half of the aborted-tail change had no test at all; the existing terminal-request case only covered `interrupted` (infra either way) and `completed` (graded either way), neither of which distinguishes the hunk. - The Python teardown contract ran nowhere. The claim that this directory is hand-run does not survive contact: `test_harness_compat.py` stays out of CI because it needs Harbor or Pier installed, while `test_process_scope.py` imports only the stdlib, and the headless lane already installs Harbor. - `agent.logger.warning` sat unguarded inside the except handler, so a caller without a logger — or a logging handler that raises — would escape the same `finally` and rewrite the same agent failure the fix exists to preserve. The test double always carried a logger, so nothing could catch it. Both new tests were confirmed red against their unfixed code.
Astro-Han
marked this pull request as ready for review
August 4, 2026 06:34
This was referenced Aug 4, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two independent defects in the Harbor cell path recorded graded cells as
infra_failed, which drops them from the denominator entirely. Both are structurally unreachable on the maka arm, so every cell they cost belonged to a competitor.Found while tracking the three-arm run for #1970. Of that run's 14
infra_failedcells, 13 were these two bugs and 1 was a real infrastructure failure.Teardown rewrote the agent's failure.
cleanup_process_scopeonly ever runs from an adapter'sfinallywhile the agent's own exception is in flight (claude_code_agent.py,codex_agent.py,kimi_code_agent.pyall guard it withif abnormal_exit). Raising there replaces the exception being propagated, so anAgentTimeoutErrorreached Harbor asNonZeroAgentExitCodeErrorand the runner read it as infrastructure rather than a graded timeout. Teardown after a failure is best effort by nature — no caller can act on its error — so it now logs and continues. Cancellation still propagates. Cost: 10 Claude Code cells, each already carryingerrorClass=budget_exhaustedin its own cell output while the WAL saidinfra_failed.maka_agent.pynever calls this teardown.The
abortedtail exemption could not fire on a clean exit.incompleteTerminalProviderRequestexempts anabortedlast request when the agent phase settled, but the caller computedagentPhaseSettledonly inside the abnormal-termination branch. A trial that raised nothing never reached it — so the exemption missed the most ordinary shape there is: an agent that finishes and exits while a stream is open. Cost: 3 codex cells withverifier reward 1.0and no trial exception, discarded as infrastructure failures. maka produced no aborted tail request anywhere in the run.Refs #1970.
Verification
npm run --workspace @maka/headless test— 97/97 inharbor-task-runner.test.ts, including the new case. One pre-existing failure remains incli.test.js(components[0].sourceRefs[2].path: source ref "apps/desktop/src/main/workspace-instructions.ts" does not exist under repo root); it reproduces on unmodifiedorigin/mainand is unrelated to this change.python3 packages/headless/harbor/tests/test_process_scope.py— 3 passed. This directory is run by hand, astest_harness_compat.pyalready is; it is not wired into CI.npm run format/npm run lint— clean.Both tests were confirmed red against the unfixed code, and the TS one fails with the exact production error:
Review focus
The fix stops the misfiling going forward; it does not repair WALs already written. The #1970 run's own numbers still need a re-scoring pass from the on-disk artifacts, which will land with that report rather than here.