hindsight icon indicating copy to clipboard operation
hindsight copied to clipboard

coding-agents: turn 1 injects the tool guide twice (page preamble + page refresh) with the default pageRefreshEveryTurns=1

Open jervaise opened this issue 2 weeks ago • 1 comments

Package: @vectorize-io/hindsight-coding-agents 0.8.7 (seen in dist/pi.js; the hook hosts share buildHookOutput).

What happens: with the default pageRefreshEveryTurns: 1, the first user turn of every session gets the page preamble and the page refresh, so the tool guide and any toolGuideExtra are sent twice in the same injection.

  • buildHookOutput (dist/pi.js ~18736) checks if (cadence > 0 && turns % cadence === 0). With cadence === 1, 1 % 1 === 0 holds on turn 1.
  • On turn 1, RuntimeCore.onPrompt (~18885) already prepends buildPagesPreamble(...) (<hindsight_pages>, which includes toolGuide(opts)), then appends output.context, which now also holds buildRosterRefresh(...) (<hindsight_page_refresh>, which includes toolGuide(opts) again).
  • Measured over 343 turn-1 injections in 315 real sessions (12-15 Nov): 343/343 carried the second copy, about 5.5k duplicated chars each with a ~2k-char toolGuideExtra.

Suggested fix:

  1. Guard the refresh on turn 1: if (turns > 1 && cadence > 0 && turns % cadence === 0).
  2. Optionally, when the rendered roster equals the session-cached one (sessionCacheFile already persists pages), skip the refresh or send a one-line delta. The only part that changes in the ~5.5k-char block is the page count.

We are keeping the every-turn cadence: the comment at pi.js ~16216 (searches 15% → 32.5% of turns) is convincing. This is only about the turn-1 duplicate and unchanged re-sends.

jervaise avatar Nov 15 '26 12:11 jervaise

Same bug as #5977: on turn 1 the tool guide is sent twice (session-start/preamble + the roster refresh, since turns % cadence === 0 is true on turn 1). Tracking there.

nicoloboschi avatar Nov 19 '26 09:11 nicoloboschi