Repository navigation
refactor(agents): extract before-agent-run gate - #106867
Merged
Merged
Conversation
Contributor
Author
|
Land-ready proof for head
Known proof gap: hosted CI intentionally not awaited. Testbox proof predates the final conflict-free rebase over 14 commits that touched no files in this PR. |
steipete
force-pushed
the
codex/refactor-attempt-prompt-context-phase
branch
from
July 13, 2026 22:40
4e09f66 to
f98266f
Compare
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.
What Problem This Solves
runEmbeddedAttemptstill owned the completebefore_agent_runfail-closed gate: hook dispatch, cloned input assembly, blocked-turn persistence, retry idempotency, and caller state projection. This kept another separable lifecycle phase inside the hot orchestration function.Related: #72072
Why This Change Was Made
The gate now lives in
attempt-before-agent-run.ts. The extracted helper preserves cloned hook messages, fail-closed hook errors, explicit block attribution, redacted transcript persistence, the owned session write lock, and idempotent retry behavior.attempt.tsnow only applies the returned block outcome to orchestration state.Focused tests cover no-hook, passing-hook clone isolation, explicit block persistence across retries, and thrown-hook fail-closed behavior.
User Impact
No intended behavior change. The refactor removes 83 lines from
attempt.ts(2,441 to 2,358 LOC) and makes the security-sensitive gate independently testable.Evidence
tbx_01kxesb7sj1t81j7wfhtzft72k: 219 focused tests passed across the new helper, attempt runner, context-engine attempt path, and hook lifecycle gates.pnpm tsgo:corepassed.pnpm check:test-typespassed.pnpm check:changedpassed, including the TypeScript LOC ratchet, formatting, core/test types, lint, and runtime guards.git diff --checkpassed.