Repository navigation
fix(loop): consumed steers no longer re-inject into a new run's first turn - #467
Merged
Merged
Conversation
… turn Found auditing the actual run history for steering behavior. The run loop's injection cursor (last_steer_ts) was per-run in-memory state, but the ledger replay keeps pending_steer forever (latest-wins) — so a NEW run client (cursor reset to 0) re-injected the stale instruction into its first turn. Fix: after draining a steer into a turn envelope, the run client appends a SteerConsumed event (before the turn runs, so a mid-turn death still leaves the consumption durable); replay clears pending_steer only for the SAME episode (ts + agent_id match), latest-wins preserved for newer steers. Also: the live tee now carries tool_start 'phase' (input vs execution — one tool call emits both; observed 10 starts vs 5 session tool_calls in a real run), enabling correct start-counting in tail/idle detection. Tests: steer_consumed.rs (clear-on-consume, episode-match guard). 67 future-loop suites green; clippy --all-targets -D warnings; fmt.
huichen
enabled auto-merge (squash)
September 2, 2026 14:02
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.
Found while auditing the actual run history from the loop-driven sessions.
Bug: the steer injection cursor (
last_steer_ts) was per-run in-memory state, but ledger replay keepspending_steerforever (latest-wins). A NEWrunclient resets its cursor to 0 → the stale supervisor instruction re-injects into the first turn of the next run, even though the previous run already consumed it.Fix: after draining a steer into a turn envelope, the run client appends a new
SteerConsumedledger event BEFORE the turn executes (a mid-turn death still leaves the consumption durable). Replay clearspending_steeronly for the same episode (ts + agent_id match), preserving latest-wins for newer steers.Bonus (same audit): the live tee now carries the
tool_startphasefield — the agent emits TWO starts per tool call (phase=input when the provider stream opens, phase=execution when it actually runs); a real run showed 10 starts vs 5 session tool_calls. Consumers (tail rendering, idle detection) can now dedup correctly.Tests:
steer_consumed.rs(consumption clears pending; episode-match guard keeps newer steers). 67 future-loop suites green, clippy --all-targets -D warnings, fmt.