Repository navigation
fix(bots): apply edited standing instructions on the next turn - #275
Merged
Merged
Conversation
This was referenced Nov 13, 2026
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.
Change
Changing a bot's standing instructions now starts its next turn in a fresh hidden harness session, with the current instructions, the existing Canopy conversation history and the latest stored handoff note. The user keeps the same bot and chat. Clearing instructions works too; an already-running turn keeps its original snapshot.
Cause and provider behavior
The UI saves
BotConfiguration.instructionsthroughUpdateBotintobots.configurationin Postgres. The gateway reads that configuration for each new turn and sends the current instructions in its durableRunBotTurncommand. The missing boundary was the worker's persistedsession.jsonfingerprint: it included model, tools and isolation version, but omitted standing instructions and name. Restarting an app, gateway or worker kept selecting that same provider session.systemPrompt, including withresume; the saved session retains earlier conversation context.sessionIdafter relevant settings change, supplying the current system prompt and gateway history.baseInstructionson boththread/startandthread/resume; resume restores the old thread context.thread/startafter a change rather than relying on an override to replace all earlier instruction context.session/loadrestores its session.session/newwith the current profile and rebuilt history after a change.This confirms the missing invalidation and provider input paths. It does not claim that every CLI version ignores instruction overrides on resume; the fix deliberately avoids that dependency. Rebuilt prompts explicitly give current standing instructions precedence over conflicting historical instructions/preferences.
Scope and compatibility
RunBotTurn.configuration_key = 11: a stable SHA-256 of name, standing instructions and approval policy, excluding per-turn time/hops/context. The worker includes this key and effort alongside the existing model/tool fingerprint. Name, persona, policy, effort, model and connector catalog edits therefore refresh the hidden session. Appearance-only/no-op saves resume normally.WORKER_LINK_PROTOCOLremains 1, frozen UpdateService unchanged, no DB migration. Older workers ignore the new field and keep existing behavior; upgrade workers to get the fix. New workers safely handle old gateway commands by fingerprinting the full instructions, which may cause more frequent session rebuilds.Verification
Gateway/worker regression coverage uses real Postgres, WorkerLink, WorkerHost and the official Claude SDK with controlled provider CLI fixtures. All three providers cover resumed sessions, editing/clearing instructions, worker and gateway restarts, an edit during an active turn, unchanged saves, appearance, name, policy, effort/model changes, preserved chat history and a durable handoff note. Fixtures read the actual SDK initialization system prompt, app-server
baseInstructions, or Grok profile; their answers derive from those instructions. Legacy session fingerprints and commands without the additive field are covered by the harness isolation test.bun install— passed, lockfile unchanged.bun run gen:check,bun run typecheck,bun run lint,bun run format:check— passed.bun run check:tmp— 1,490 passed, 158 skipped, 0 failed across 265 files; temp cleanup passed. All nine new refresh regression cases passed in this full run.bun run --filter @canopy/web build— passed.Paid/live inference and manual UI/browser checks were not run. No UI code or copy changed; the shared UI API is covered through gateway integration. Polish bot documentation is updated.
Fixes: #97