[gh-aw] Write session frames larger than the capture pipe whole instead of failing the run with `Errno 11`
This pull request was posted by Claude Code using claude-opus-5-5 on behalf of David.
Why we make these changes
The engine's session recorder wrote each signed frame to the protected capture descriptor with a buffered print(..., flush=True). In CI that descriptor is non-blocking, so a frame larger than the 64 KiB pipe raised BlockingIOError: [Errno 11] write could not complete without blocking out of the event hook. The frame was cut off, the next frame reused its sequence number, and AWF rejected the capture. This is #13878: it failed the Community Demand recovery runs for incident #13809, which a later run recovered by landing 1.5 KB under the limit.
Over 14 days, 3 of 84 pydantic-ai engine runs wrote a frame over 64 KiB, and all 3 failed this way. Two were reasoning at the 16,384-output-token cap, in Community Demand runs 44341327034 and 44335212137. One was a grep result at the 64,000-character tool output cap, in CI Review run 42914239491.
The recorder now writes each line with a loop that takes partial writes and, when the pipe is full, waits with poll until the reader makes room. The descriptor's O_NONBLOCK flag is left as it is, because its open file description is shared with the processes that started the engine.
New public surface
None.
User-visible behavior
A reasoning part or tool result larger than the capture pipe, on a workflow compiled from this revision:
before: [Errno 11] write could not complete without blocking
ERR_VALIDATION: AWF protected session capture could not be verified or published
after: the frame reaches the capture whole and in sequence, and the run completes
Verification
test_frames_larger_than_a_full_non_blocking_capture_pipe_are_written_wholefills a non-blocking capture pipe, then writes a 100,000-character reasoning frame and a tool-result frame of 120 KB escaped JSON while the reader starts late. It fails onmainwith theErrno 11error and passes here.- A manual run through the real harness script and generated recorder on Python 3.12, with a 75 KB frame and a reader 1 s late, raises the
Errno 11error onmainand writes the frame whole here.
What changes for existing users
Nothing, except that runs which hit this failure now complete.
[!NOTE]
Follow-up pin step. This repository's locks compile the engine from the revision .github/workflows/shared/engine-zai.md imports (pydantic.md@c9c896e9), so their runs still fail this way until that import moves. After this PR merges, a follow-up PR moves the import to this PR's merge commit, recompiles the 12 locks, carries a live Community Demand run as proof, and closes #13878, as #12960 did for #12818. Workflows that import pydantic.md@main get the fix on their next recompile.
Telemetry gap. Logfire scrubs the content of a run's final tool result, which is the frame that failed, so its size could not be read back for run 42914239491 and was estimated by re-running the grep.
PR decisions
2026-11-18 · Take #13878 now · iter -
- Decision: Fix #13878 now as the root cause blocking recovery of #13809
- Why: #13809 is in the ci-health lane's github-actions set; manager dispatch /home/agent/pydantic/ai/manager/local-notes/dispatch-20261118T192747Z.md
- Source: https://github.com/pydantic/pydantic-ai/issues/13878
- Session: 79ca73a8-3725-41b7-a089-8e355358d49a
2026-11-18 · One PR closes both issues · iter -
- Decision: One PR with Closes #13878 and Closes #13809
- Why: Manager decision, dispatch /home/agent/pydantic/ai/manager/local-notes/dispatch-20261118T192747Z.md
- Source: https://github.com/pydantic/pydantic-ai/issues/13809
- Session: 79ca73a8-3725-41b7-a089-8e355358d49a
2026-11-18 · Close #13809 on the recovery run · iter -
- Decision: Closed #13809 on recovery run 44381219487; PR says Closes #13878 and Refs #13809
- Why: Recovery passed on 0.70.0, so the one-PR-closes-both premise changed; manager answer in /home/agent/pydantic/ai/fix-gh-aw-engine-eagain-13878/local-notes/dispatch-20261118T200509Z.md
- Source: https://github.com/pydantic/pydantic-ai/issues/13809#issuecomment-6990118951
- Session: 79ca73a8-3725-41b7-a089-8e355358d49a
- Supersedes: One PR closes both issues
2026-11-18 · Fix every frame type · iter -
- Decision: Fix #13878 for reasoning and tool-result frames so a frame of any size is written whole
- Why: Logfire: 3/84 runs had a >64 KiB root frame, all failed, one from a tool result; manager answer in /home/agent/pydantic/ai/fix-gh-aw-engine-eagain-13878/local-notes/dispatch-20261118T200509Z.md
- Source: https://github.com/pydantic/pydantic-ai/issues/13878
- Session: 79ca73a8-3725-41b7-a089-8e355358d49a
2026-11-18 · Skip the O_NONBLOCK setter hunt · iter -
- Decision: Make the write path correct in any descriptor mode: handle partial writes and EAGAIN by waiting until writable, without flipping O_NONBLOCK on a shared file description
- Why: Manager answer in /home/agent/pydantic/ai/fix-gh-aw-engine-eagain-13878/local-notes/dispatch-20261118T200509Z.md
- Source: https://github.com/pydantic/pydantic-ai/issues/13878
- Session: 79ca73a8-3725-41b7-a089-8e355358d49a
2026-11-18 · Pin move only to a released harness version · iter -
- Decision: Report where the fixed write path runs in CI and how CI picks it up before changing shared/engine-zai.md; 'A pin can only move to a released harness version'
- Why: Manager answer in /home/agent/pydantic/ai/fix-gh-aw-engine-eagain-13878/local-notes/dispatch-20261118T200509Z.md
- Source: https://github.com/pydantic/pydantic-ai/issues/13878
- Session: 79ca73a8-3725-41b7-a089-8e355358d49a
2026-11-18 · Telemetry gap is a PR-body note · iter -
- Decision: State in the PR body that the failing frame size is unreadable because Logfire scrubs it; no follow-up issue
- Why: Manager answer in /home/agent/pydantic/ai/fix-gh-aw-engine-eagain-13878/local-notes/dispatch-20261118T200509Z.md
- Source: https://github.com/pydantic/pydantic-ai/issues/13878
- Session: 79ca73a8-3725-41b7-a089-8e355358d49a
2026-11-18 · pre-push review 1 of 3 at d1dcff4bd7954342a5f696c5f7555a39eafd3bd5 · iter -
- Decision: reserved: dispatching (haiku, effort high, claude -p from detached policy-base checkout 1ac982978a, read-only tools, no fan-out)
- Why: tree 07446195e458c675c90871c650dfb3170711793c; scope full branch 9ced068002..d1dcff4bd7; first review
- Source: https://github.com/pydantic/pydantic-ai/tree/fix-gh-aw-engine-eagain-13878
- Session: 79ca73a8-3725-41b7-a089-8e355358d49a
2026-11-18 · Engine import pin in a follow-up PR · iter -
- Decision: This PR: recorder fix and tests, shared/engine-zai.md untouched, body says Refs #13878 and Refs #13809; a follow-up PR moves the import to this PR's merge commit, recompiles the 12 locks, carries the live Community Demand run, and closes #13878
- Why: A squash merge orphans this branch's commits, so an import pinned to one points at a SHA main never contains; #12960 precedent. Manager dispatch local-notes/dispatch-20261118T201801Z.md
- Source: https://github.com/pydantic/pydantic-ai/pull/12960
- Session: 79ca73a8-3725-41b7-a089-8e355358d49a
- Supersedes: Close #13809 on the recovery run
2026-11-18 · pre-push review 1 of 3 at d1dcff4bd7954342a5f696c5f7555a39eafd3bd5 · iter -
- Decision: remediated: test frames shrunk to 100,000 chars and 20,000 escaped chars (Test cost rule), poll object renamed capture_poller, test docstring no longer claims each write finds no room
- Why: reviewed tree 07446195e458c675c90871c650dfb3170711793c; scope 9ced068002..d1dcff4bd7 (full branch); light tier (haiku). Rename changes code, so review 2 of 3 follows
- Source: https://github.com/pydantic/pydantic-ai/tree/fix-gh-aw-engine-eagain-13878
- Session: 79ca73a8-3725-41b7-a089-8e355358d49a
2026-11-18 · pre-push review 2 of 3 at 93d0e6a46eaf96c7f78ebbef7c1bb76053c309ed · iter -
- Decision: reserved: dispatching (haiku, effort high, claude -p from detached policy-base checkout f41f7fd216, read-only tools, no fan-out)
- Why: tree 4f5d2198a3f15bdb161ecb6fa0bf99cb3539beb6; follow-up scope d1dcff4bd7..93d0e6a46e (last reviewed tree 07446195e4) plus review 1 findings to verify
- Source: https://github.com/pydantic/pydantic-ai/tree/fix-gh-aw-engine-eagain-13878
- Session: 79ca73a8-3725-41b7-a089-8e355358d49a
2026-11-18 · pre-push review 2 of 3 at 93d0e6a46eaf96c7f78ebbef7c1bb76053c309ed · iter -
- Decision: remediated: engine comment states the rule without undefined caps (5e4f0bb163, comment-only, exempt). Skipped: dropping the Claude-Session commit trailer, which is not a co-author trailer, is requested by the harness attribution instruction, and never reaches main because squash merges keep only the PR title
- Why: reviewed tree 4f5d2198a3f15bdb161ecb6fa0bf99cb3539beb6; follow-up scope d1dcff4bd7..93d0e6a46e; prior findings 1-3 verified fixed; exempt delta chains from 93d0e6a46e
- Source: https://github.com/pydantic/pydantic-ai/tree/fix-gh-aw-engine-eagain-13878
- Session: 79ca73a8-3725-41b7-a089-8e355358d49a
2026-11-18 · Step 7 second opinion: none · iter -
- Decision: No additional review surface for PR 13915
- Why: Overmanager's pick via /home/agent/pydantic/ai/manager/local-notes/dispatch-20261118T205431Z.md: gh-aw engine recorder only, with a test that fails on main
- Source: https://github.com/pydantic/pydantic-ai/pull/13915
- Session: 79ca73a8-3725-41b7-a089-8e355358d49a
Checklist
- No breaking changes in accordance with the version policy.
- Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
- PR title is fit for the release changelog.
https://claude.ai/code/session_01HhQjZ9HJ1LmMnVuKkMGHVp
Summary by cubic
Fixes gh-aw engine runs failing with BlockingIOError: [Errno 11] when a session frame is larger than the non-blocking capture pipe. The recorder now writes each line with a loop that handles partial writes and waits for the reader to make room, so frames reach the capture whole and in sequence.
- Leaves the descriptor's
O_NONBLOCKflag untouched since its open file description is shared with the processes that started the engine. - Adds a test that fills a non-blocking pipe and writes reasoning and tool-result frames larger than the pipe while the reader starts late.