Repository navigation
fix(agent-hooks): let the last-status throttle apply to routine hook events - #39826
Conversation
…events Each hook event re-recorded the pane's authority evidence, which bumped the revision counters behind the "urgent persist" fingerprint even when only observedAt moved. Every event then skipped the 5s throttle and rewrote last-status.json. Update the stored evidence without bumping the revision when the authority itself (launch token, connection, tab, worktree) is unchanged.
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
…events (stablyai#39826) * fix(agent-hooks): let the last-status throttle apply to routine hook events Each hook event re-recorded the pane's authority evidence, which bumped the revision counters behind the "urgent persist" fingerprint even when only observedAt moved. Every event then skipped the 5s throttle and rewrote last-status.json. Update the stored evidence without bumping the revision when the authority itself (launch token, connection, tab, worktree) is unchanged. * test(agent-hooks): remove timer-racy persistence count assertions (cherry picked from commit 00d3e44)
ELI5
Orca saves a small file about running agents. It's meant to save at most every 5 seconds while agents are busy, but it was saving after every single tool call. This makes the 5-second limit work as intended.
What Changed
RevisionedMap.setIfChangedstores the new value but bumps the revision only when the value actually differs.recordCurrentAuthorityObservationnow uses it, comparing with the existingauthorityCommitmentsMatch(launch token, connection, tab, worktree).observedAtstill updates in place, so hydration's TTL check sees fresh timestamps.Why
#26822 added a 5s leading-edge throttle for
last-status.json, with an immediate write when pane authority changes. "Authority changed" is detected through a fingerprint built from the revision counters ofpersistedAuthorityCommitmentsByPaneKeyandhydratedLaunchTokenHashByPaneKey. Every hook event re-set both maps, so the revisions moved on every event, every write counted as urgent, and the throttle never applied.In one local profile with many agents running, the file (~186 KB) was being rewritten about twice a second. Real authority changes (new launch, rebind, cleanup) still write immediately.
Linked Issue
N/A (found while profiling disk writes locally)
Visual Proof
N/A: no UI change; only how often a file is written.
Testing
pnpm check:changed: all 20 non-test checks passed. Stopped its overbroad related-test selection after ~3 minutes; focused tests above passed. Full PR CI is required before merge.