Skip to content

fix(hive): inject standing goals only when changed - #367

Merged
chaitanyagiri merged 1 commit into
HarnessMD:mainfrom
drona23:fix/standing-goal-injection-359
Sep 6, 2026
Merged

chaitanyagiri merged 1 commit into
HarnessMD:mainfrom
drona23:fix/standing-goal-injection-359

Conversation

@drona23

@drona23 drona23 commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

What & why

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.

Closes #359

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Docs
  • Build / CI

Evidence

Before

Before: unchanged standing goal repeats on every prompt

After

After: standing goal is delivered once and again only after an edit

How I tested it

  • OS: macOS arm64
  • node --test test/standing-goal-injection.test.cjs — 6/6 pass
  • npm run test:focused — 751/751 pass
  • npm run typecheck — node and web pass
  • npm run build — production build succeeds
  • git diff --check — clean

Checklist

  • Before and after evidence is attached above.
  • npm run typecheck passes.
  • npm run test:focused passes.
  • npm run build succeeds.
  • This PR is one change.
  • I read the diff and removed unrelated changes.
  • No UI tokens or art are changed.

@drona23 drona23 mentioned this pull request Aug 28, 2026
13 tasks
mrlfarano added a commit to mrlfarano/munder-difflin that referenced this pull request Aug 31, 2026
@chaitanyagiri

Copy link
Copy Markdown
Collaborator

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:

const newSession = !delivered || delivered.sessionId !== sessionId;

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.

@chaitanyagiri
chaitanyagiri merged commit daf242b into HarnessMD:main Sep 6, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Standing goal is re-injected as additionalContext on every prompt instead of when it changes

2 participants