diff --git a/cli/src/modules/common/sessionSummaryInstruction.test.ts b/cli/src/modules/common/sessionSummaryInstruction.test.ts index 731ebd5a..5c8dd8b5 100644 --- a/cli/src/modules/common/sessionSummaryInstruction.test.ts +++ b/cli/src/modules/common/sessionSummaryInstruction.test.ts @@ -9,6 +9,21 @@ import { withSessionSummaryInstruction } from './sessionSummaryInstruction' +const PREVIOUS_SESSION_SUMMARY_INSTRUCTION = [ + 'Session status summary:', + 'End every response with a single machine-readable status line (no backticks)', + 'so this workspace\'s session tracking can record progress. Put it on its own', + 'final line after all other content:', + 'AGENT_NOTIFY_SUMMARY {"version":1,"agent":"","project":"","status":"done|blocked|needs_review|needs_decision|failed|stalled","action":"<=12 words","summary":"one-line triage"}', + 'Use status "blocked" if unsure. Keep action to 12 words or fewer when status', + 'is "done" and follow-up remains.' +].join('\n') + +const USER_LANGUAGE_INSTRUCTION = [ + 'Use the language used by the user in the current conversation for the', + 'human-readable "action" and "summary" values.' +].join('\n') + describe('sessionSummaryInstruction', () => { afterEach(() => { resetSessionSummaryContractForTests() @@ -51,6 +66,25 @@ describe('sessionSummaryInstruction', () => { expect(body.toLowerCase()).not.toContain('surveillance') }) + it('adds user-language guidance without changing the existing prompt contract', () => { + applyHubSessionSummaryContract(true) + const body = sessionSummaryInstructionOrEmpty({}) + const previousLines = PREVIOUS_SESSION_SUMMARY_INSTRUCTION.split('\n') + const expected = [ + ...previousLines.slice(0, 5), + USER_LANGUAGE_INSTRUCTION, + ...previousLines.slice(5) + ].join('\n') + + expect(body).toBe(expected) + }) + + it('preserves the exact machine-readable footer format', () => { + expect(SESSION_SUMMARY_CONTRACT_LINE).toBe( + 'AGENT_NOTIFY_SUMMARY {"version":1,"agent":"","project":"","status":"done|blocked|needs_review|needs_decision|failed|stalled","action":"<=12 words","summary":"one-line triage"}' + ) + }) + it('appends to an existing base prompt when enabled', () => { applyHubSessionSummaryContract(true) const out = withSessionSummaryInstruction('Be helpful.', {}) diff --git a/cli/src/modules/common/sessionSummaryInstruction.ts b/cli/src/modules/common/sessionSummaryInstruction.ts index 64459ddf..244f53a4 100644 --- a/cli/src/modules/common/sessionSummaryInstruction.ts +++ b/cli/src/modules/common/sessionSummaryInstruction.ts @@ -53,6 +53,8 @@ export function buildSessionSummaryInstruction(): string { 'so this workspace\'s session tracking can record progress. Put it on its own', 'final line after all other content:', SESSION_SUMMARY_CONTRACT_LINE, + 'Use the language used by the user in the current conversation for the', + 'human-readable "action" and "summary" values.', 'Use status "blocked" if unsure. Keep action to 12 words or fewer when status', 'is "done" and follow-up remains.' ].join('\n')