Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions open-sse/executors/cliproxyapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,20 @@ export class CliproxyapiExecutor extends BaseExecutor {
// entry inside messages[], not at body level. Accept both string and
// array-of-content-blocks forms (Anthropic supports both per the docs).
if (b.system !== undefined) return true;
// Strong signal: top-level `thinking` field is Anthropic-only. OpenAI
// uses `reasoning` / `reasoning_effort`. Even adaptive/raw Capy shapes
// emit thinking, so this catches minimal Capy bodies (string content,
// no system block) that would otherwise miss the messages[0].content
// array check below.
if (b.thinking !== undefined) return true;
// Strong signal: top-level `metadata.user_id` is the CC wire-image
// identifier; OpenAI request bodies don't carry it.
if (
b.metadata &&
typeof b.metadata === "object" &&
(b.metadata as Record<string, unknown>).user_id !== undefined
)
return true;
// Strong signal: messages[0].content is an array of Anthropic content blocks
const msgs = b.messages;
if (Array.isArray(msgs) && msgs.length > 0) {
Expand Down
15 changes: 11 additions & 4 deletions tests/unit/cliproxyapi-executor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,22 @@ describe("CliproxyapiExecutor", () => {
assert.equal(result.thinking, undefined);
});

it("does not touch thinking on OpenAI-shape bodies", () => {
it("does not strip OpenAI-shape bodies (no thinking, no system, string content)", () => {
const exec = new CliproxyapiExecutor();
const body = {
model: "gpt-5.5",
messages: [{ role: "user", content: "hi" }],
thinking: { type: "adaptive", display: "summarized" },
messages: [
{ role: "system", content: "be brief" },
{ role: "user", content: "hi" },
],
reasoning_effort: "medium",
};
const result = exec.transformRequest("gpt-5.5", body, true, {});
assert.deepEqual(result.thinking, { type: "adaptive", display: "summarized" });
// No Anthropic indicators present, so strips are skipped. Body
// passes through with its OpenAI fields preserved.
assert.equal(result.reasoning_effort, "medium");
assert.equal(result.thinking, undefined);
assert.equal(result.output_config, undefined);
});
});

Expand Down