Skip to content

fix(bfcl): use message.content when tool_calls is empty (OpenAI-APIs)#1316

Open
pcabriada wants to merge 1 commit intoShishirPatil:mainfrom
pcabriada:fix/openai-fc-empty-tool-calls-fallback
Open

fix(bfcl): use message.content when tool_calls is empty (OpenAI-APIs)#1316
pcabriada wants to merge 1 commit intoShishirPatil:mainfrom
pcabriada:fix/openai-fc-empty-tool-calls-fallback

Conversation

@pcabriada
Copy link
Copy Markdown

Summary

_parse_query_response_FC in OpenAICompletionsHandler used a try/except around iterating message.tool_calls. When tool_calls is None, iteration fails and the code correctly falls back to message.content. When some OpenAI-compatible servers (e.g. vLLM) return tool_calls: [] for text-only assistant turns, the list comprehension succeeds and yields model_responses == [], so content is never read. That breaks multi-step FC flows (e.g. agentic / memory traces collapsing to empty steps).

Change

  • Read tool_calls once.
  • If truthy, parse tool calls and IDs as before.
  • Otherwise set model_responses from message.content and tool_call_ids to [].

Motivation / context

  • OpenAI-style APIs often use tool_calls: null when there are no tool calls; some gateways use an empty list instead.
  • Behavior is unchanged when there is at least one tool call.

How to test

From berkeley-function-call-leaderboard after pip install -e ., with a configured FC model:

bfcl generate --model <MODEL_NAME> --test-category simple_python --num-threads 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant