Skip to content

Commit d162f0c

Browse files
committed
fix(sglang): preserve reasoning replay history
1 parent ea7f74f commit d162f0c

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

extensions/sglang/index.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { registerSingleProviderPlugin } from "openclaw/plugin-sdk/plugin-test-runtime";
2+
import { describe, expect, it } from "vitest";
3+
import plugin from "./index.js";
4+
5+
describe("sglang provider plugin", () => {
6+
it("owns OpenAI-compatible replay without dropping reasoning history", async () => {
7+
const provider = await registerSingleProviderPlugin(plugin);
8+
const policy = provider.buildReplayPolicy?.({
9+
provider: "sglang",
10+
modelApi: "openai-completions",
11+
modelId: "moonshotai/kimi-k2-thinking",
12+
} as never);
13+
14+
expect(policy).toMatchObject({
15+
sanitizeToolCallIds: true,
16+
toolCallIdMode: "strict",
17+
applyAssistantFirstOrderingFix: true,
18+
validateGeminiTurns: true,
19+
validateAnthropicTurns: true,
20+
});
21+
expect(policy).not.toHaveProperty("dropReasoningFromHistory");
22+
});
23+
24+
it("still drops historical reasoning for Gemma 4 chat-completions models", async () => {
25+
const provider = await registerSingleProviderPlugin(plugin);
26+
const policy = provider.buildReplayPolicy?.({
27+
provider: "sglang",
28+
modelApi: "openai-completions",
29+
modelId: "google/gemma-4-26b-a4b-it",
30+
} as never);
31+
32+
expect(policy).toHaveProperty("dropReasoningFromHistory", true);
33+
});
34+
});

extensions/sglang/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
type OpenClawPluginApi,
44
type ProviderAuthMethodNonInteractiveContext,
55
} from "openclaw/plugin-sdk/plugin-entry";
6+
import { buildProviderReplayFamilyHooks } from "openclaw/plugin-sdk/provider-model-shared";
67
import {
78
SGLANG_DEFAULT_API_KEY_ENV_VAR,
89
SGLANG_DEFAULT_BASE_URL,
@@ -69,6 +70,10 @@ export default definePluginEntry({
6970
});
7071
},
7172
},
73+
...buildProviderReplayFamilyHooks({
74+
family: "openai-compatible",
75+
dropReasoningFromHistory: false,
76+
}),
7277
wizard: {
7378
setup: {
7479
choiceId: "sglang",

0 commit comments

Comments
 (0)