You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(hive): inject standing goals only when changed - #367
Standing goals were re-injected as additionalContext on every UserPromptSubmit, even when the briefing had not changed. Long sessions therefore paid for and stored the same multi-kilobyte goal hundreds of times.
Track the last delivered goal per agent session: inject at SessionStart, on the first prompt if start was missed, and on actual edits. Clearing a goal explicitly revokes the previous briefing instead of leaving stale instructions alive.
Reviewed by an agent on the Munder Difflin hive floor, posted from @chaitanyagiri. First person statements below are the agent's, including the scope limits. Replies here are read. Questions in this comment are real questions. Base: origin/main at 956bfb4.
Closes #359. The explicit revocation is the part I would not have thought of and it is right:
// Silence would leave the old briefing alive in the model's context.
Clearing a durable field and saying nothing would leave the agent following a goal the operator
deleted, which is a worse bug than the one being fixed. Good.
The one to check before merge is session_id. The whole mechanism keys on it:
If any provider's UserPromptSubmit payload omits session_id while its SessionStart carries
one, then p.session_id ?? null makes every prompt look like a new session, the goal is injected
on every prompt, and #359 is silently back for that provider only. The tests always pass an
explicit session_id, so they cannot catch it. This hive runs claude, codex, agy, gemini and
others through the same HookServer, and the codex comment elsewhere in the tree says its hook
payload is Claude-shaped, which implies the others may not be. Do you know that every provider
that reaches handle() sends session_id on UserPromptSubmit? If yes, say so in the PR. If
not, the safe read is to treat a missing session id as "same session" rather than as a new one.
Minor: deliveredGoalByAgent has no removal path. It is one small entry per agent ever seen, so
it does not matter in practice, but forget-style cleanup exists elsewhere in this codebase for
the same kind of map.
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
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 & why
Standing goals were re-injected as
additionalContexton everyUserPromptSubmit, even when the briefing had not changed. Long sessions therefore paid for and stored the same multi-kilobyte goal hundreds of times.Track the last delivered goal per agent session: inject at
SessionStart, on the first prompt if start was missed, and on actual edits. Clearing a goal explicitly revokes the previous briefing instead of leaving stale instructions alive.Closes #359
Type of change
Evidence
Before
After
How I tested it
node --test test/standing-goal-injection.test.cjs— 6/6 passnpm run test:focused— 751/751 passnpm run typecheck— node and web passnpm run build— production build succeedsgit diff --check— cleanChecklist
npm run typecheckpasses.npm run test:focusedpasses.npm run buildsucceeds.