1
0
forked from boos/BoosAPI

fix codex compact non-stream accept header (#439)

This commit is contained in:
Cita
2026-04-06 08:46:27 +08:00
committed by GitHub
parent 38721cb890
commit 3e8d69bed6
5 changed files with 7 additions and 3 deletions
@@ -20,6 +20,7 @@ export const codexProviderProfile: ProviderProfile = {
const headers = buildCodexRuntimeHeaders({ const headers = buildCodexRuntimeHeaders({
baseHeaders: input.baseHeaders, baseHeaders: input.baseHeaders,
providerHeaders: input.providerHeaders, providerHeaders: input.providerHeaders,
stream: input.stream,
explicitSessionId: asTrimmedString(input.codexExplicitSessionId) || null, explicitSessionId: asTrimmedString(input.codexExplicitSessionId) || null,
continuityKey: asTrimmedString(input.codexSessionCacheKey) || null, continuityKey: asTrimmedString(input.codexSessionCacheKey) || null,
userAgentOverride: configuredUserAgent || null, userAgentOverride: configuredUserAgent || null,
@@ -61,6 +61,7 @@ describe('provider header utils', () => {
originator: 'codex_cli_rs', originator: 'codex_cli_rs',
'chatgpt-account-id': 'acct-1', 'chatgpt-account-id': 'acct-1',
}, },
stream: false,
continuityKey: 'cache-key-1', continuityKey: 'cache-key-1',
explicitSessionId: null, explicitSessionId: null,
}); });
@@ -70,7 +71,7 @@ describe('provider header utils', () => {
expect(headers['Chatgpt-Account-Id']).toBe('acct-1'); expect(headers['Chatgpt-Account-Id']).toBe('acct-1');
expect(headers.Session_id).toMatch(/^[0-9a-f-]{36}$/); expect(headers.Session_id).toMatch(/^[0-9a-f-]{36}$/);
expect(headers.Conversation_id).toBe(headers.Session_id); expect(headers.Conversation_id).toBe(headers.Session_id);
expect(headers.Accept).toBe('text/event-stream'); expect(headers.Accept).toBe('application/json');
}); });
it('builds claude runtime headers with merged betas and oauth bearer auth', async () => { it('builds claude runtime headers with merged betas and oauth bearer auth', async () => {
@@ -114,6 +114,7 @@ function asTrimmedString(value: unknown): string {
export function buildCodexRuntimeHeaders(input: { export function buildCodexRuntimeHeaders(input: {
baseHeaders: Record<string, string>; baseHeaders: Record<string, string>;
providerHeaders?: Record<string, string>; providerHeaders?: Record<string, string>;
stream?: boolean;
explicitSessionId?: string | null; explicitSessionId?: string | null;
continuityKey?: string | null; continuityKey?: string | null;
versionDefault?: string; versionDefault?: string;
@@ -177,7 +178,7 @@ export function buildCodexRuntimeHeaders(input: {
Session_id: sessionId, Session_id: sessionId,
...(conversationId ? { Conversation_id: conversationId } : {}), ...(conversationId ? { Conversation_id: conversationId } : {}),
'User-Agent': userAgent, 'User-Agent': userAgent,
Accept: 'text/event-stream', Accept: input.stream === false ? 'application/json' : 'text/event-stream',
Connection: 'Keep-Alive', Connection: 'Keep-Alive',
}; };
} }
@@ -362,6 +362,7 @@ describe('responses proxy compact upstream routing', () => {
expect(forwardedBody.stream_options).toBeUndefined(); expect(forwardedBody.stream_options).toBeUndefined();
expect(forwardedBody.instructions).toBe(''); expect(forwardedBody.instructions).toBe('');
expect(forwardedBody.store).toBe(false); expect(forwardedBody.store).toBe(false);
expect(options.headers.Accept || options.headers.accept).toBe('application/json');
}); });
it('preserves native response.compaction payloads instead of coercing them into object=response', async () => { it('preserves native response.compaction payloads instead of coercing them into object=response', async () => {
@@ -815,7 +815,7 @@ describe('buildUpstreamEndpointRequest', () => {
expect(request.headers.Session_id).toMatch(/^[0-9a-f-]{36}$/i); expect(request.headers.Session_id).toMatch(/^[0-9a-f-]{36}$/i);
expect(request.headers.Conversation_id).toBe(request.headers.Session_id); expect(request.headers.Conversation_id).toBe(request.headers.Session_id);
expect(request.headers['User-Agent']).toBe('codex_cli_rs/0.101.0 (Mac OS 26.0.1; arm64) Apple_Terminal/464'); expect(request.headers['User-Agent']).toBe('codex_cli_rs/0.101.0 (Mac OS 26.0.1; arm64) Apple_Terminal/464');
expect(request.headers.Accept).toBe('text/event-stream'); expect(request.headers.Accept).toBe('application/json');
expect(request.headers.Connection).toBe('Keep-Alive'); expect(request.headers.Connection).toBe('Keep-Alive');
expect(request.body.instructions).toBe(''); expect(request.body.instructions).toBe('');
expect(request.body.prompt_cache_key).toBeUndefined(); expect(request.body.prompt_cache_key).toBeUndefined();