FN-7984: keep chat agents from switching checkout branch unless asked
Add branch-stickiness guardrails to the chat system prompt so agents do not switch the live checkout unless the user explicitly requests it. - Extend CHAT_SYSTEM_PROMPT to forbid git checkout/switch unless asked; allow read-only Git inspection - Add regression coverage for the branch-stickiness clause - Add patch changeset for @runfusion/fusion Files changed: .changeset/fn-7984-chat-branch-guardrail.md | 7 +++++++ packages/dashboard/src/__tests__/chat-system-prompt.test.ts | 9 +++++++++ packages/dashboard/src/chat.ts | 7 +++++-- 3 files changed, 21 insertions(+), 2 deletions(-) Fusion-Task-Id: FN-7984 Fusion-Task-Lineage: b093b1da-f45c-49fc-918b-50b06f99d7f6 Co-authored-by: Fusion (runfusion.ai) <noreply@runfusion.ai>
This commit is contained in:
7
.changeset/fn-7984-chat-branch-guardrail.md
Normal file
7
.changeset/fn-7984-chat-branch-guardrail.md
Normal file
@@ -0,0 +1,7 @@
|
||||
---
|
||||
"@runfusion/fusion": patch
|
||||
---
|
||||
|
||||
summary: Chat agents no longer switch your checked-out branch unless you ask.
|
||||
category: fix
|
||||
dev: Adds a branch-stickiness clause to CHAT_SYSTEM_PROMPT in packages/dashboard/src/chat.ts.
|
||||
@@ -13,6 +13,15 @@ describe("chat system prompt guidance", () => {
|
||||
expect(CHAT_SYSTEM_PROMPT).toContain('to_id: "dashboard"');
|
||||
});
|
||||
|
||||
it("keeps the checked-out branch sticky unless explicitly requested", () => {
|
||||
const lower = CHAT_SYSTEM_PROMPT.toLowerCase();
|
||||
|
||||
expect(lower).toContain("branch");
|
||||
expect(lower).toContain("git checkout");
|
||||
expect(lower).toContain("git switch");
|
||||
expect(lower).toContain("unless the user explicitly asks");
|
||||
});
|
||||
|
||||
it("combined guidance enforces additive mailbox follow-ups, not mirroring", () => {
|
||||
const combined = `${CHAT_SYSTEM_PROMPT}\n\n${CHAT_AGENT_MESSAGE_ROUTING_GUIDANCE}`;
|
||||
|
||||
|
||||
@@ -216,10 +216,13 @@ async function ensureEngineReady(): Promise<void> {
|
||||
|
||||
// ── Constants ───────────────────────────────────────────────────────────────
|
||||
|
||||
/** Chat system prompt for the AI agent */
|
||||
/**
|
||||
* FNXC:DashboardChat 2026-07-15-00:00:
|
||||
* FN-7984 keeps the live checkout's branch sticky because chat commands run in the user's project directory. Agents may inspect Git state, but must not switch branches unless the user explicitly requests it.
|
||||
*/
|
||||
export const CHAT_SYSTEM_PROMPT = `${FUSION_RUNTIME_SELF_AWARENESS}
|
||||
|
||||
You are a helpful AI assistant integrated into the fn task board system. You help users with questions about their project, code, architecture, and tasks. You have access to project files and can read them to provide informed responses, including referencing specific file paths and line numbers when possible. Response length policy: default to a short, crisp reply (a few sentences or a short bulleted list) that directly answers the user; avoid preamble, restating the question, and filler. If a thorough answer genuinely needs long-form content (for example multi-step plans, design proposals, deep analyses, or long file excerpts), keep the chat reply brief with a one- or two-sentence summary and then send the full write-up via \`fn_send_message\` using \`type: "agent-to-user"\` and \`to_id: "dashboard"\`. That mailbox follow-up must add new substantive detail and must not duplicate the chat reply.`;
|
||||
You are a helpful AI assistant integrated into the fn task board system. You help users with questions about their project, code, architecture, and tasks. You have access to project files and can read them to provide informed responses, including referencing specific file paths and line numbers when possible. Do not change the branch the working directory is checked out on: do not run \`git checkout <branch>\` or \`git switch <branch>\` to a different branch unless the user explicitly asks. Read-only Git and branch inspection, such as \`git status\`, \`git branch\`, and \`git log\`, is allowed. Response length policy: default to a short, crisp reply (a few sentences or a short bulleted list) that directly answers the user; avoid preamble, restating the question, and filler. If a thorough answer genuinely needs long-form content (for example multi-step plans, design proposals, deep analyses, or long file excerpts), keep the chat reply brief with a one- or two-sentence summary and then send the full write-up via \`fn_send_message\` using \`type: "agent-to-user"\` and \`to_id: "dashboard"\`. That mailbox follow-up must add new substantive detail and must not duplicate the chat reply.`;
|
||||
|
||||
export const CHAT_AGENT_MESSAGE_ROUTING_GUIDANCE = `## Messaging Semantics\n\nYour chat reply is the primary response to the user. Do not also call \`fn_send_message\` with the same content just to mirror your chat response into mailbox.\n\nUse \`fn_send_message\` only when either (a) the user explicitly asks for mailbox/inbox/notification delivery (for example: "send me this in mail", "ntfy me when…", or "leave me a note in my inbox"), or (b) you are sending a genuinely longer follow-up that did not fit in a short chat reply. In either case, send with \`type: "agent-to-user"\` and target the dashboard user alias (\`to_id: "dashboard"\` is preferred), and ensure the mailbox message is additive rather than a duplicate of the chat reply. Never route that as a user/CLI → agent message.`;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user