refactor(agent): group per-turn host flags into an embedded perTurnState - #7795
Merged
Conversation
Eleven fields that are valid for exactly one Agent.Run (delivery expectations, readinessRecovered, recoveryTaskSummary, loop-guard and blocked-streak counters, repeatSuccessCounts) were flat Agent fields reset one by one in beginRunTurn — adding such a field meant remembering to reset it by hand. They now live in an embedded perTurnState value that beginRunTurn zeroes in a single assignment; field promotion keeps every access site unchanged. Cross-turn state (delivery checkpoint/scope, repeat-failure budgets, storm counters) stays directly on Agent.
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.
Continues the agent god-object cleanup (#7786, #7788). Agent had ~99 flat fields; eleven of them are host state valid for exactly one Agent.Run, reset one by one in beginRunTurn — adding such a field meant remembering to reset it by hand.
What
perTurnStatestruct (run_loop.go) embedded in Agent: delivery expectations (deliveryCriteriaEstablished/TaskExpected/MutationExpected/PersistentExpected/ScopeActive),readinessRecovered,recoveryTaskSummary,blockedTurnStreak,loopGuardArmed/loopGuardReceiptMark,repeatSuccessCounts.a.deliveryTaskExpectedetc.) unchanged — the diff is ±60 lines of declarations, no call-graph changes.deliveryScopeID,deliveryCheckpoint,deliveryRecoveryPending,preserveEvidenceOnce,repeatFailureCounts/Scope,stormSig/stormCount,missingReasoning*.Verification
gofmtclean,go vet ./internal/agent/...cleango test -race ./internal/agent/greengo test ./...green (English locale)Cache-impact: none - host-side field grouping; no provider request shaping, cache_control, or usage accounting paths touched.
Cache-guard: existing coverage - cache_shape_test.go and the full agent race suite pass unchanged.
Documentation-impact: none - internal state reorganization with identical behavior; no docs describe these fields.