fix provider switch not presistingin session (#903)
* fix provider switch not presistingin session * fix broken tests
This commit is contained in:
@@ -11,6 +11,7 @@ import { afterEach, expect, test } from 'bun:test'
|
||||
NATIVE_PACKAGE_URL: undefined,
|
||||
}
|
||||
|
||||
import { clearSystemPromptSections } from './systemPromptSections.js'
|
||||
import { getSystemPrompt, DEFAULT_AGENT_PROMPT } from './prompts.js'
|
||||
import { CLI_SYSPROMPT_PREFIXES, getCLISyspromptPrefix } from './system.js'
|
||||
import { CLAUDE_CODE_GUIDE_AGENT } from '../tools/AgentTool/built-in/claudeCodeGuideAgent.js'
|
||||
@@ -23,6 +24,7 @@ const originalSimpleEnv = process.env.CLAUDE_CODE_SIMPLE
|
||||
|
||||
afterEach(() => {
|
||||
process.env.CLAUDE_CODE_SIMPLE = originalSimpleEnv
|
||||
clearSystemPromptSections()
|
||||
})
|
||||
|
||||
test('CLI identity prefixes describe OpenClaude instead of Claude Code', () => {
|
||||
@@ -47,6 +49,21 @@ test('simple mode identity describes OpenClaude instead of Claude Code', async (
|
||||
expect(prompt[0]).not.toContain("Anthropic's official CLI for Claude")
|
||||
})
|
||||
|
||||
test('system prompt model identity updates when model changes mid-session', async () => {
|
||||
delete process.env.CLAUDE_CODE_SIMPLE
|
||||
clearSystemPromptSections()
|
||||
|
||||
const firstPrompt = await getSystemPrompt([], 'old-test-model')
|
||||
const secondPrompt = await getSystemPrompt([], 'new-test-model')
|
||||
|
||||
const firstText = firstPrompt.join('\n')
|
||||
const secondText = secondPrompt.join('\n')
|
||||
|
||||
expect(firstText).toContain('You are powered by the model old-test-model.')
|
||||
expect(secondText).toContain('You are powered by the model new-test-model.')
|
||||
expect(secondText).not.toContain('You are powered by the model old-test-model.')
|
||||
})
|
||||
|
||||
test('built-in agent prompts describe OpenClaude instead of Claude Code', () => {
|
||||
expect(DEFAULT_AGENT_PROMPT).toContain('OpenClaude')
|
||||
expect(DEFAULT_AGENT_PROMPT).not.toContain('Claude Code')
|
||||
|
||||
@@ -496,7 +496,7 @@ ${CYBER_RISK_INSTRUCTION}`,
|
||||
systemPromptSection('ant_model_override', () =>
|
||||
getAntModelOverrideSection(),
|
||||
),
|
||||
systemPromptSection('env_info_simple', () =>
|
||||
systemPromptSection(`env_info_simple:${model}`, () =>
|
||||
computeSimpleEnvInfo(model, additionalWorkingDirectories),
|
||||
),
|
||||
systemPromptSection('language', () =>
|
||||
@@ -519,7 +519,7 @@ ${CYBER_RISK_INSTRUCTION}`,
|
||||
'MCP servers connect/disconnect between turns',
|
||||
),
|
||||
systemPromptSection('scratchpad', () => getScratchpadInstructions()),
|
||||
systemPromptSection('frc', () => getFunctionResultClearingSection(model)),
|
||||
systemPromptSection(`frc:${model}`, () => getFunctionResultClearingSection(model)),
|
||||
systemPromptSection(
|
||||
'summarize_tool_results',
|
||||
() => SUMMARIZE_TOOL_RESULTS_SECTION,
|
||||
|
||||
Reference in New Issue
Block a user