增强各厂商思考与采样参数映射,并统一流式推理字段解析。

避免不同接口字段差异导致思考链丢失或采样参数被忽略。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-14 01:14:09 +08:00
co-authored by Cursor
parent e6d79d6a0c
commit 752eaccefa
12 changed files with 392 additions and 49 deletions
+31
View File
@@ -41,6 +41,37 @@ describe("local LLM driver", () => {
expect(run.stop).toEqual({ kind: "text", content: "done" });
});
it("uses reasoning as the story when tools return no content", async () => {
const llm = {
complete: async () => ({ content: "" }),
completeWithTools: async () => ({
content: null,
toolCalls: [],
reasoning: "门开了。她把耳机摘下,问:「你在干什么?」",
}),
};
const driver = createLocalLlmDriver(llm as never);
const run = await driver.run({
system: "sys",
messages: [{ role: "user", content: "go" }],
tools: [
{
type: "function",
function: {
name: "chance",
description: "roll",
parameters: { type: "object", properties: {} },
},
},
],
handleStep: () => ({ kind: "continue", results: [] }),
});
expect(run.stop).toEqual({
kind: "text",
content: "门开了。她把耳机摘下,问:「你在干什么?」",
});
});
it("stops when handleStep concludes, without another model call", async () => {
const llm = new MockLlmProvider([
createMockToolCall("run_worker", { workerId: "x" }, "t1"),