fix: make vllm tool-calling turns tool-first

This commit is contained in:
lingyuzeng
2026-03-22 20:49:44 +08:00
parent 649958677e
commit b0c034f5ce
4 changed files with 72 additions and 31 deletions

View File

@@ -28,12 +28,13 @@ describe('vLLM Response Rewriter', () => {
expect(argsObject).toEqual({ path: '/tmp/test.txt' });
});
it('does not touch response that already has tool_calls', () => {
it('normalizes response that already has tool_calls into a tool-first shape', () => {
const inputResponse = {
choices: [{
message: {
role: "assistant",
content: "Here are the calls",
thinking: "<think>internal</think>",
tool_calls: [
{
id: "123",
@@ -47,7 +48,8 @@ describe('vLLM Response Rewriter', () => {
const result = rewriteVllmResponse(inputResponse);
expect(result.choices[0].message.content).toBe("Here are the calls");
expect(result.choices[0].message.content).toBe("");
expect(result.choices[0].message.thinking).toBe("");
expect(result.choices[0].message.tool_calls).toHaveLength(1);
});