Merge pull request #2400 from QwenLM/feat/system-prompt-sdk

feat: add system prompt customization options in SDK and CLI
This commit is contained in:
tanzhenxin 2026-03-18 11:29:21 +08:00 committed by GitHub
commit 080271031d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 799 additions and 67 deletions

View file

@ -248,6 +248,26 @@ describe('Server Config (config.ts)', () => {
);
});
it('should store a system prompt override', () => {
const config = new Config({
...baseParams,
systemPrompt: 'You are a custom system prompt.',
});
expect(config.getSystemPrompt()).toBe('You are a custom system prompt.');
expect(config.getAppendSystemPrompt()).toBeUndefined();
});
it('should store an appended system prompt', () => {
const config = new Config({
...baseParams,
appendSystemPrompt: 'Be extra concise.',
});
expect(config.getAppendSystemPrompt()).toBe('Be extra concise.');
expect(config.getSystemPrompt()).toBeUndefined();
});
describe('initialize', () => {
it('should throw an error if checkpointing is enabled and GitService fails', async () => {
const gitError = new Error('Git is not installed');

View file

@ -293,6 +293,8 @@ export interface ConfigParameters {
debugMode: boolean;
includePartialMessages?: boolean;
question?: string;
systemPrompt?: string;
appendSystemPrompt?: string;
coreTools?: string[];
allowedTools?: string[];
excludeTools?: string[];
@ -444,6 +446,8 @@ export class Config {
private readonly outputFormat: OutputFormat;
private readonly includePartialMessages: boolean;
private readonly question: string | undefined;
private readonly systemPrompt: string | undefined;
private readonly appendSystemPrompt: string | undefined;
private readonly coreTools: string[] | undefined;
private readonly allowedTools: string[] | undefined;
private readonly excludeTools: string[] | undefined;
@ -550,6 +554,8 @@ export class Config {
this.outputFormat = normalizedOutputFormat ?? OutputFormat.TEXT;
this.includePartialMessages = params.includePartialMessages ?? false;
this.question = params.question;
this.systemPrompt = params.systemPrompt;
this.appendSystemPrompt = params.appendSystemPrompt;
this.coreTools = params.coreTools;
this.allowedTools = params.allowedTools;
this.excludeTools = params.excludeTools;
@ -1195,6 +1201,14 @@ export class Config {
return this.question;
}
getSystemPrompt(): string | undefined {
return this.systemPrompt;
}
getAppendSystemPrompt(): string | undefined {
return this.appendSystemPrompt;
}
getCoreTools(): string[] | undefined {
return this.coreTools;
}