Skip to content

Commit 5ef8825

Browse files
committed
fix(proxy): handle POST /v1/responses/compact with no-op stub (Codex Desktop 404 fix)
Codex Desktop calls this endpoint in the background to compact long conversation history. DeepSeek has no equivalent, so return a minimal valid Response object (200 + empty output) to suppress the repeated 404 errors in the log.
1 parent fd81012 commit 5ef8825

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

electron/proxy/server.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,34 @@ export class DeepSeekProxy extends EventEmitter {
551551
return;
552552
}
553553

554+
// ─── Context compaction (Codex Desktop background task) ───────────────
555+
// Codex Desktop periodically calls POST /v1/responses/compact to compress
556+
// long conversation history. DeepSeek has no equivalent endpoint, so we
557+
// return a minimal valid Response object (no-op) so Codex Desktop doesn't
558+
// log a 404 error and retains its normal flow.
559+
if (req.method === 'POST' && url.pathname === '/v1/responses/compact') {
560+
req.resume(); // drain body
561+
const compactId = `resp_compact_${randomBytes(6).toString('hex')}`;
562+
this.log({
563+
level: 'info',
564+
source: 'http',
565+
message: '↩ /v1/responses/compact (no-op stub — DeepSeek 不支持原生压缩)',
566+
});
567+
res.writeHead(200, { 'Content-Type': 'application/json' });
568+
res.end(
569+
JSON.stringify({
570+
id: compactId,
571+
object: 'response',
572+
created_at: Math.floor(Date.now() / 1000),
573+
status: 'completed',
574+
model: this.opts.defaultModel ?? 'deepseek-v4-flash',
575+
output: [],
576+
usage: { input_tokens: 0, output_tokens: 0, total_tokens: 0 },
577+
}),
578+
);
579+
return;
580+
}
581+
554582
// ─── Anthropic routes (v1.3.0 — Claude Desktop) ───────────────────────
555583
if (req.method === 'GET' && url.pathname === '/anthropic/v1/models') {
556584
handleAnthropicModels(res, this.anthropicRelayOpts());

0 commit comments

Comments
 (0)