feat(cli): follow conversation language in status prompt (#1584)

This commit is contained in:
Ananovo
2026-08-16 23:06:06 +08:00
committed by GitHub
parent 76e00f0091
commit d644d4f30f
2 changed files with 36 additions and 0 deletions
@@ -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":"<agent-id>","project":"<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":"<agent-id>","project":"<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.', {})
@@ -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')