🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
🐛 fix(model-runtime): align tool-calling fallback tests & surface missing tool call as error (#15691)
Arvin Xu7d6be512b823
diff --git a/packages/model-runtime/src/core/openaiCompatibleFactory/index.test.ts b/packages/model-runtime/src/core/openaiCompatibleFactory/index.test.tsindex 71a1ead6b45..fc2d724342c 100644--- a/packages/model-runtime/src/core/openaiCompatibleFactory/index.test.ts+++ b/packages/model-runtime/src/core/openaiCompatibleFactory/index.test.ts@@ -3173,9 +3173,9 @@ describe('LobeOpenAICompatibleFactory', () => {{ headers: undefined, signal: undefined },);- expect(result).toEqual([- { arguments: { age: 28, name: 'Alice' }, name: 'person_extractor' },- ]);+ // The fallback returns the parsed schema object, same shape as the+ // json_schema path+ expect(result).toEqual({ age: 28, name: 'Alice' });});it('should not forward internal thinking to generic OpenAI-compatible generateObject requests', async () => {@@ -3255,7 +3255,10 @@ describe('LobeOpenAICompatibleFactory', () => {const result = await instanceWithToolCalling.generateObject(payload);- expect(consoleSpy).toHaveBeenCalledWith('parse tool call arguments error:', undefined);+ expect(consoleSpy).toHaveBeenCalledWith(+ 'no tool call found in structured output response:',+ mockResponse.choices[0].message,+ );expect(result).toBeUndefined();consoleSpy.mockRestore();@@ -3298,7 +3301,7 @@ describe('LobeOpenAICompatibleFactory', () => {expect(consoleSpy).toHaveBeenCalledWith('parse tool call arguments error:',- mockResponse.choices[0].message.tool_calls,+ mockResponse.choices[0].message.tool_calls[0],);expect(result).toBeUndefined();@@ -3350,7 +3353,7 @@ describe('LobeOpenAICompatibleFactory', () => {{ headers: options.headers, signal: options.signal },);- expect(result).toEqual([{ arguments: { data: 'test' }, name: 'data_extractor' }]);+ expect(result).toEqual({ data: 'test' });});});});diff --git a/packages/model-runtime/src/core/openaiCompatibleFactory/index.ts b/packages/model-runtime/src/core/openaiCompatibleFactory/index.tsindex 31d768bef22..5e9aadaf493 100644--- a/packages/model-runtime/src/core/openaiCompatibleFactory/index.ts+++ b/packages/model-runtime/src/core/openaiCompatibleFactory/index.ts@@ -898,7 +898,9 @@ export const createOpenAICompatibleRuntime = <T extends Record<string, any> = antoolCalls?.find((item) => item.function?.name === tool.function.name) ?? toolCalls?.[0];if (!toolCall?.function) {- log('no tool call found in structured output response');+ // tool_choice forces this function, so a missing tool call means the+ // provider misbehaved — surface it instead of silently returning undefined+ console.error('no tool call found in structured output response:', res.choices[0]?.message);return undefined;}