mirror of
https://github.com/wu736139669/hapi.git
synced 2026-11-08 01:43:07 +00:00
fix(runner) preserve native instructions (#1557)
* fix(codex): preserve native instructions Keep HAPI guidance in the developer layer so app-server retains Codex persistence rules. Align long-running goal states with the Codex 0.147 protocol. * fix(codex): filter new goal statuses
This commit is contained in:
@@ -15,6 +15,29 @@ describe('appServerConfig', () => {
|
||||
return `${developerInstructions}\n\n${codexCollaborationSpawnAgentInstructions}`;
|
||||
};
|
||||
|
||||
it('preserves Codex built-in base instructions by omitting the default override', () => {
|
||||
const params = buildThreadStartParams({
|
||||
cwd: '/workspace/project',
|
||||
mode: { permissionMode: 'default', collaborationMode: 'default' },
|
||||
mcpServers
|
||||
});
|
||||
|
||||
expect(params).not.toHaveProperty('baseInstructions');
|
||||
expect(params.developerInstructions).toBe(codexSystemPrompt);
|
||||
});
|
||||
|
||||
it('keeps an explicit base instruction override separate from HAPI developer instructions', () => {
|
||||
const params = buildThreadStartParams({
|
||||
cwd: '/workspace/project',
|
||||
mode: { permissionMode: 'default', collaborationMode: 'default' },
|
||||
mcpServers,
|
||||
baseInstructions: 'Custom base instructions.'
|
||||
});
|
||||
|
||||
expect(params.baseInstructions).toBe('Custom base instructions.');
|
||||
expect(params.developerInstructions).toBe(codexSystemPrompt);
|
||||
});
|
||||
|
||||
it('applies CLI overrides when permission mode is default', () => {
|
||||
const params = buildThreadStartParams({
|
||||
cwd: '/workspace/project',
|
||||
@@ -26,7 +49,7 @@ describe('appServerConfig', () => {
|
||||
expect(params.cwd).toBe('/workspace/project');
|
||||
expect(params.sandbox).toBe('danger-full-access');
|
||||
expect(params.approvalPolicy).toBe('never');
|
||||
expect(params.baseInstructions).toBe(codexSystemPrompt);
|
||||
expect(params.baseInstructions).toBeUndefined();
|
||||
expect(params.developerInstructions).toBe(codexSystemPrompt);
|
||||
expect(params.config).toEqual({
|
||||
'mcp_servers.hapi': {
|
||||
@@ -129,7 +152,7 @@ describe('appServerConfig', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('concatenates custom developer instructions after base instructions', () => {
|
||||
it('concatenates custom developer instructions after HAPI instructions without overriding base instructions', () => {
|
||||
const params = buildThreadStartParams({
|
||||
cwd: '/workspace/project',
|
||||
mode: { permissionMode: 'default', collaborationMode: 'default' },
|
||||
@@ -137,7 +160,7 @@ describe('appServerConfig', () => {
|
||||
developerInstructions: 'Only respond in Chinese.'
|
||||
});
|
||||
|
||||
expect(params.baseInstructions).toBe(codexSystemPrompt);
|
||||
expect(params.baseInstructions).toBeUndefined();
|
||||
expect(params.developerInstructions).toBe(`${codexSystemPrompt}\n\nOnly respond in Chinese.`);
|
||||
expect(params.config).toEqual({
|
||||
'mcp_servers.hapi': {
|
||||
|
||||
@@ -114,11 +114,12 @@ function buildMcpServerConfig(mcpServers: McpServersConfig): Record<string, unkn
|
||||
function resolveInstructions(args: {
|
||||
baseInstructions?: string;
|
||||
developerInstructions?: string;
|
||||
}): { baseInstructions: string; developerInstructions: string } {
|
||||
const baseInstructions = args.baseInstructions ?? getCodexSystemPrompt();
|
||||
}): { baseInstructions: string | undefined; developerInstructions: string } {
|
||||
const baseInstructions = args.baseInstructions;
|
||||
const hapiDeveloperInstructions = getCodexSystemPrompt();
|
||||
const developerInstructions = args.developerInstructions
|
||||
? `${baseInstructions}\n\n${args.developerInstructions}`
|
||||
: baseInstructions;
|
||||
? `${hapiDeveloperInstructions}\n\n${args.developerInstructions}`
|
||||
: hapiDeveloperInstructions;
|
||||
return {
|
||||
baseInstructions,
|
||||
developerInstructions
|
||||
@@ -218,7 +219,7 @@ export function buildThreadStartParams(args: {
|
||||
cwd: args.cwd,
|
||||
approvalPolicy: resolvedApprovalPolicy,
|
||||
sandbox: resolvedSandbox,
|
||||
baseInstructions,
|
||||
...(baseInstructions !== undefined ? { baseInstructions } : {}),
|
||||
developerInstructions: resolvedDeveloperInstructions,
|
||||
...(Object.keys(configWithInstructions).length > 0 ? { config: configWithInstructions } : {})
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user