Skip to content

Add the BFCL chat regimes: native function calling and prompting - #429

Merged
pdasigi merged 9 commits into
mainfrom
pd_bfcl_instruct
Oct 8, 2026
Merged

pdasigi merged 9 commits into
mainfrom
pd_bfcl_instruct

Conversation

@pdasigi

@pdasigi pdasigi commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #387, which registered the BFCL v3 single-turn categories as a completion
task. This adds the two regimes BFCL actually defines, for instruction-tuned models.

Three regimes

They differ only in how the functions reach the model and how its calls are read back.
Everything downstream — the checker, the scorer, the suites — is shared.

Spec Regime For
bfcl_simple Native function calling — schemas out, tool_calls back An instruction-tuned model behind an OpenAI-compatible endpoint
bfcl_simple:prompt BFCL's prompting mode — functions in a system prompt, [func(arg=value)] text back Any chat endpoint, no server-side tool parsing
bfcl_simple:base Plain completion with curated exemplars A pretrained model with no chat template

Suites exist per regime: bfcl, bfcl:prompt, bfcl:base, and the same for the
non_live family.

⚠️ Breaking: the bare spec changes meaning

Native function calling is what BFCL means by its headline numbers, so it takes the
bare name and the completion regime moves to :base:

Before this PR After
bfcl_simple → completion bfcl_simple:base → completion
— bfcl_simple → native function calling

-t bfcl_simple will not fail, it will run a different regime. Results recorded
against a bare spec since #387 merged (2026-09-18) are not comparable with results
recorded after this lands. Task hashes for bare specs change too, from the regime, the
fewshot_source change and the sampling change below. :base specs are unaffected in
meaning; their hashes are unchanged.

Server flags for native function calling

None are needed:

uv run olmo-eval run -m my-model -t bfcl

vLLM only emits tool_calls when started with --enable-auto-tool-choice. The worker
already passed that flag when the harness carried tools. The runner now also passes
it when any task request carries tool schemas, which is how BFCL sends its
functions. An explicit provider.kwargs.enable_auto_tool_choice is left as given, and
an external base_url server is not reconfigured.

Misconfiguration fails the run instead of scoring zero:

  • A provider that would drop the schemas. Providers now declare supports_tools
    alongside the existing supports_images. The harness refuses a request that
    carries tools and goes to a provider without that support with no scaffold in
    between; vllm (in-process) and litellm both ignore LMRequest.tools.
    Scaffolded harnesses are exempt, because the scaffold sends its tools over its own
    client. The agentic presets on an API model depend on that.
  • A vLLM server that won't parse tool calls, which can now only happen with an
    explicit enable_auto_tool_choice=false. vllm_server refuses the whole batch
    before dispatch, so each instance is recorded as a hard failure. An external
    base_url is given the benefit of the doubt, since its flags can't be checked.

Exemplar identity

fewshot_source is now set only on the regimes that can show exemplars. Native
function calling cannot, so naming a set there would make every such task's hash follow
exemplars it never prompts with.

bfcl_simple         BFCLToolFormatter        nfewshot=0  src=None
bfcl_simple:prompt  BFCLPromptFormatter      nfewshot=0  src=bfcl_fixed_python@0f328790
bfcl_simple:base    BFCLCompletionFormatter  nfewshot=5  src=bfcl_fixed_python@0f328790

Sampling

The chat regimes sample the way the leaderboard does: up to 4096 tokens at temperature
0.001. max_tokens is cut back to whatever room the prompt leaves in the context
window, using the same arithmetic as BFCL's base_oss_handler:
min(4096, context − prompt − 2).

bfcl_simple         max_tokens=4096  temperature=0.001  fit_max_tokens_to_context=True
bfcl_simple:prompt  max_tokens=4096  temperature=0.001  fit_max_tokens_to_context=True
bfcl_simple:base    max_tokens=512   temperature=0.0    stop=("\n###", "\n\n")

The cut-back is a new SamplingParams.fit_max_tokens_to_context flag. When it is set,
vllm_server counts the prompt with the server's /tokenize endpoint, using the real
messages, tools and chat_template_kwargs. If the context window or the prompt length
can't be established, max_tokens is sent unchanged, so other providers behave as they
did. Without the cut-back, a prompt that leaves less room than max_tokens makes vLLM
reject the whole request. The completion regime has no upstream counterpart, so it keeps
its own budget, and :base task hashes don't change.

Results

allenai/Olmo-3-7B-Instruct, native function calling

Full suite, 3641 instances, stock vLLM olmo3 parser (no patch_olmo3_tool_parser).
None of the replies hit the token cap; the median reply is 31 tokens.

Category n Accuracy
simple 400 0.8325
multiple 200 0.8100
parallel 200 0.6800
parallel_multiple 200 0.3750
java 100 0.5000
javascript 50 0.4800
irrelevance 240 0.9250
live (pooled) 2251 0.7166
non-live 0.6788
overall 0.6977

Two observations from the predictions. Both are about the model and the stock parser,
not this code:

  • parallel_multiple at 0.375 is mostly a call-count problem. 116 of the 125
    failures had the wrong number of calls, and 95 of them returned exactly one call where
    several were needed. Those replies are 10–112 tokens (median 23) with no leftover text,
    so the model emitted one call; the parser wasn't dropping any.
  • javascript at 0.48: 12 of the 26 failures produced no call. Some of those are
    genuine prose refusals, but one emitted <function_calls>…</function_calls> as text
    that the stock olmo3 parser didn't extract. patch_olmo3_tool_parser=true targets
    exactly this.

The same model's base-regime numbers, and the two base models, are in #387.

Qwen/Qwen3-8B, native function calling

Qwen3 enables thinking by default, so the suite was run both ways. Thinking is turned
off with -o 'provider.kwargs.chat_template_kwargs={"enable_thinking":false}'.

Category n thinking on thinking off
simple 400 0.9550 0.9425
multiple 200 0.9500 0.9400
parallel 200 0.8950 0.8850
parallel_multiple 200 0.8400 0.8800
java 100 0.6000 0.6500
javascript 50 0.6800 0.6600
irrelevance 240 0.8250 0.8625
live (pooled) 2251 0.7934 0.7712
non-live 0.8510 0.8637
overall 0.8222 0.8174

With thinking on, the median reply is 303 tokens and 43 of 3641 replies hit the 4096
cap. With thinking off, the median is 42 tokens and 2 replies hit the cap. A truncated
reply never reaches a call, so it scores 0 on the AST categories. On irrelevance it
scores 1, because calling nothing is the right answer there. At 43 replies the effect
is small. With the earlier fixed 1024-token budget, 285 replies were truncated, and that
made thinking look worse than it is.

Overall, the two settings are within half a point of each other, but they don't trade
evenly across categories. Thinking helps on live (0.7934 against 0.7712) and costs a
little on non-live, mostly java, parallel_multiple and irrelevance.

Agreement with the original BFCL implementation

The thinking-off run uses the same model and settings as a reference run of
Qwen/Qwen3-8B-FC with USE_THINKING: 0, produced by the original BFCL implementation
in ai2/general-tool-use:

Category this implementation original BFCL
simple 0.9425 0.9550
java 0.6500 0.6500
javascript 0.6600 0.6200
multiple 0.9400 0.9600
parallel 0.8850 0.9150
parallel_multiple 0.8800 0.8950
irrelevance 0.8625 0.8542
non-live 0.8637 0.8732
live (pooled) 0.7712 (n=2251) 0.7689 (n=2250)

live agrees to 0.2 points over 2251 instances, and non-live to 1 point. The aggregation
used here also reproduces that run's published Non_Live Overall Acc of 87.32% exactly
from its per-category numbers, which is what makes the two columns comparable. The two
implementations send the functions differently. For local models, BFCL's -FC handler
renders the tools through the model's chat template and extracts <tool_call> tags from
the reply text. This PR sends tools= and lets vLLM's hermes parser extract the calls.
The scores agree all the same.

Known issues, not introduced here

Not implemented

Multi-turn (needs BFCL's stateful API backend) and the executable/REST categories (they
grade by running predicted calls against live third-party APIs).

🤖 Generated with Claude Code

https://claude.ai/code/session_01P9Qzbda9kPQePRC7MKJxnu

pdasigi and others added 2 commits September 29, 2026 16:19
Only vllm_server reads LMRequest.tools; vllm, litellm, huggingface and
olmo_core ignore the field. Nothing populates it yet, but the BFCL tool calling
regimes will, and a run against one of those providers would show the model a
question with no functions attached, which it answers in prose. The task would
report an accuracy near zero, reading like a weak model rather than a
misconfigured run.

Providers declare whether they carry tool schemas, alongside supports_images,
and the harness stops a request before sending one that would be dropped.
vllm_server also refuses when it started its own server without
--enable-auto-tool-choice, since the server then answers in plain text and
parses no tool calls; an external server is given the benefit of the doubt,
its flags not being knowable from here. Mock accepts tools so a tool calling
task stays previewable.

The check runs from _apply_config rather than from the harness methods that
carry the image check, because the async runner reaches the provider through a
scaffold or directly and those methods are not on its path.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01P9Qzbda9kPQePRC7MKJxnu
BFCL addresses an instruction-tuned model, through a tool calling API or a
chat template. Only the completion reformulation was registered; this adds the
two regimes the benchmark defines, which differ from it and from each other
only in how the functions reach the model and how its calls are read back.

Native function calling sends the function documents as tool schemas and reads
the calls back from tool_calls. It is what BFCL means by its headline numbers,
so it takes the bare task name, and the completion regime moves to :base. A
spec that named the completion regime before now names this one rather than
failing, so results recorded under a bare spec are not comparable across this
change.

The prompting regime writes the functions into a system prompt and reads
[func(arg=value)] text back, which needs no server-side tool parsing and so
runs against any chat endpoint.

Tool names reach the endpoint sanitized, since many BFCL function names do not
match what a tool name may be, and the instance carries the map that restores
the dataset's spelling before the checker sees a call.

fewshot_source now names the exemplar set only for the regimes that can show
exemplars. Naming it for native function calling, which cannot, would make
every such task's hash follow exemplars it never prompts with.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01P9Qzbda9kPQePRC7MKJxnu
@pdasigi
pdasigi requested a review from a team as a code owner September 30, 2026 20:06

@gregorybchris gregorybchris left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review was generated by an agent following REVIEW_GUIDE.md. It is not from a human reviewer. Reply in the PR thread and a maintainer will follow up.

Looks good overall! The parity table against the original BFCL run is good evidence, and the hash bookkeeping is careful. A few things we should address before merging.

I found two blocking issues. Both are in the new tool-support guard. The first breaks existing agentic harnesses on API models. The second means the most likely misconfiguration still scores zero silently, which is the outcome the guard exists to prevent. The non-blocking items are about variant composition, the extraction interface, and process.

I ran lint, format, ty, and the unit suite locally on the PR head. All pass (2883 passed). CI is green.

Blocking

  1. src/olmo_eval/harness/harness.py:373
    The check fires for harness-level tools as well as request-level ones, so every tool-carrying harness preset now fails on a litellm provider. Harness presets yield their provider kind to the model preset (merge_model_provider), so -m gpt-4o --harness web_search_agent resolves to LiteLLMProvider. Before this PR that ran: the openai_agents and openhands scaffolds send the tools through provider.get_openai_client(), and openhands has an explicit LiteLLMProvider branch. Nothing was being dropped on that path. I reproduced it by building each preset with has_tools (codex_agent, codex_completion, dr_tulu, dr_tulu_crawl4ai, paper_search_agent, web_search_agent, web_search_agent_crawl4ai) with a LiteLLMProvider instance and calling _apply_config. All seven raise ValueError: LiteLLMProvider does not support tool requests. In the async runner, _apply_config is called outside the try at src/olmo_eval/runners/asynq/processing.py:109, so this takes down the worker.
    Please scope the guard to the path that actually drops tools: request-level tools sent through the provider's own generate/agenerate, with no scaffold. Please also add a test that a tool-carrying harness with a scaffold and a provider that has supports_tools = False still gets through _apply_config.

    tools = self.config.tool_schemas if self.config.has_tools else request.tools
    if request.tools and not self.config.scaffold:
        self._check_tools_supported()
  2. src/olmo_eval/inference/providers/vllm_server.py:913
    With a managed server and no enable_auto_tool_choice override, every instance scores 0.0 and nothing is recorded as failed. That is the misconfiguration the README and PR description say "fails loudly". The ValueError raised in _generate_chat does not reach the runner:

    • dispatch_concurrent catches it per request and returns None.
    • agenerate turns None into [] (vllm_server.py:1052).
    • request_error([]) returns None because the output list is empty (src/olmo_eval/inference/errors.py:49).
    • process_batch puts a ResultItem with outputs=[] and error=None. is_hard_failure is False, so the instance is scored.
    • AccuracyMetric.compute reads a missing score as 0.0 (src/olmo_eval/common/metrics/base.py:133).

    I reproduced the provider half by calling agenerate on a VLLMServerProvider with _tool_calls_parsed = False. It logs the warning and returns [[], []], and request_error on that is None. The new test at tests/harness/test_tool_support.py calls _generate_chat directly, which is why it does not catch this.
    Part of this is a deficiency in the framework. A provider exception becomes an empty output list with no error attached, and an empty output list scores as zero. That deserves its own fix and an issue. For this PR, could we fail before dispatch? Two options:

    • (a) Expose the parsed-tool-calls state as a public property and check it in the harness guard, next to supports_tools. The guard then raises before any request goes out.
    • (b, preferred) Remove the need for the flag. src/olmo_eval/runners/asynq/workers.py:91 already sets enable_auto_tool_choice automatically when the harness has tools. Extending that to tasks whose formatter emits tools makes -t bfcl work with no override. It also drops the --harness default -o provider.kwargs.enable_auto_tool_choice=true step from the README and docstring.

    Either way, please add a regression test that goes through agenerate (or process_batch) and asserts that the run fails or the instance is recorded as a hard failure. It should not come back as an empty output.

Non-blocking

  1. src/olmo_eval/evals/tasks/bfcl/__init__.py:1138
    The :Nshot variants are still registered on the bare (native function calling) task, where they change the hash and nothing else. bfcl_simple:2shot hashes to 51f77712…, while bfcl_simple hashes to c93287ca…. With fewshot_source=None, get_fewshot() falls back to the main data source and returns 2 instances, which BFCLToolFormatter.format ignores. So two different hashes produce identical requests. Should BFCLToolFormatter reject num_fewshot > 0, or should the shot variants only compose with :prompt and :base?

  2. src/olmo_eval/evals/tasks/bfcl/__init__.py:1134
    Variant order silently changes the shot count. bfcl_simple:2shot:base resolves to 5 shots and has the same hash as bfcl_simple:base (9f481407…), because :base sets num_fewshot=5 after :2shot has applied. The README documents bfcl_simple:base:2shot, but the reversed spelling is an easy mistake and gives no error. Could :base leave num_fewshot alone when an earlier variant set it, or could registration reject the reversed order?

  3. src/olmo_eval/evals/tasks/bfcl/__init__.py:310 and :1025
    Extraction reads call_source and lenient off type(formatter) with getattr defaults. That couples the task to formatter class attributes that no interface declares. A new formatter that forgets them silently gets strict text decoding. Could the three formatters share a small BFCLFormatter base that declares decode(output, language, name_map), with each regime implementing it? CallSource would then go away. If it stays, it should be a StrEnum or Literal.

  4. src/olmo_eval/evals/tasks/bfcl/__init__.py:1040
    Against an external base_url server that does not parse tool calls, the guard gives the benefit of the doubt. Every AST instance then scores 0 and every irrelevance instance scores 1.0, and the only trace is bfcl_no_tool_calls_with_text on each prediction. Could we log one warning per task when most outputs carry that flag, so the run log shows it without opening predictions?

  5. Breaking change to the bare spec. I confirmed the description's claim: bfcl_simple:base, bfcl_java:base, bfcl_live:base and bfcl_simple:base:2shot hash identically to the old bare specs. That means rows stored since 2026-09-18 under the name bfcl_simple share a hash with the new bfcl_simple:base, while the name bfcl_simple now means native function calling. Anything that groups by task name will mix the two regimes. Do we know whether such rows exist in the shared store? If they do, could we note in the PR how to tell them apart (by hash)?

  6. Process. The nested-suite flattening in _compute_child_average makes the bfcl suite report 0.6865 where the correct figure is 0.6962. That is a persisted-result error in a suite this PR now registers three times. I could not find an open issue for it. Could you file one and link it here? Also, #340 and #341 add BFCL v4 as external evaluations. Is there a plan for how those relate to these native-FC tasks, so we do not end up with two BFCL implementations that score differently?

Nits

  • Nit: src/olmo_eval/evals/tasks/bfcl/__init__.py:1123 — :prompt keeps fewshot_source with num_fewshot=0. Its hash therefore follows an exemplar set it does not show, which is the situation the description gives as the reason for dropping it from the bare regime. This is fine if it is deliberate so that :prompt:Nshot works. A one-line comment would help.
  • Nit: src/olmo_eval/evals/tasks/bfcl/__init__.py:233 — BFCL's _cast_to_openai_type raises KeyError on an unknown item type; this version maps it to "string". That is harmless on the v3 data, but it is an unnamed divergence. Please add a comment or match upstream.
  • Nit: src/olmo_eval/harness/harness.py:105 — the docstring's reasoning about the async runner path would be stale once item 1 changes where the check runs. Please keep it general.

Before merge

Please fix blocking items 1 and 2, each with the regression test described. Please also file the suite-flattening issue from non-blocking item 6. After that, you may merge once CI is green. The other non-blocking items can be follow-ups if you prefer. If you defer them, please file issues for items 1 and 3.

Comment thread src/olmo_eval/harness/harness.py Resolved
pdasigi and others added 3 commits October 3, 2026 06:22
The chat regimes asked for a flat 1024 tokens at temperature 0. BFCL asks
for up to 4096, shrunk to the room the prompt leaves in the context
window, and samples at 0.001.

The fixed budget cost accuracy on replies that reason before calling, and
a prompt that left less than 1024 tokens made the server reject the whole
request rather than answer in the space available.

Providers that cannot establish the window or the prompt length generate
as they did before. The completion regime has no counterpart upstream and
keeps its own budget.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01P9Qzbda9kPQePRC7MKJxnu
The guard refused any request whose harness carried tools, including the
agentic presets, whose scaffolds send their tools over their own client.
On an API model each of those presets raised from the worker. The guard
now checks only requests that carry tools and go to the provider without
a scaffold.

A vLLM server started without tool-call parsing refused tool requests
one at a time. Dispatch caught each refusal and handed back an empty
output with no error, so every instance scored zero and none failed. The
refusal now covers the whole batch before dispatch, which the runner
records as a failure of each instance.

The runner now also starts the server with tool-call parsing whenever a
task sends tool schemas, as the worker already does for a harness with
its own tools, so native function calling needs no provider override.
An explicit setting and an external server are left as given.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01P9Qzbda9kPQePRC7MKJxnu
@pdasigi

pdasigi commented Oct 4, 2026

Copy link
Copy Markdown
Member Author

Thanks for the review. Both blocking items are fixed in ae42382, and CI is green on it.

Blocking 1: the guard refused scaffolded harnesses. The check in _apply_config now runs only for a request that carries its own tools and has no scaffold:

if request.tools and not self.config.scaffold:
    self._check_tools_supported()

tests/harness/test_tool_support.py builds every preset that has tools (the seven you listed) on a provider with supports_tools = False and checks that _apply_config lets each one through. All seven failed on the previous head, which matches your reproduction. A further test checks that every tool-carrying preset has a scaffold, since the exemption relies on that. The _check_tools_supported docstring no longer describes the runner path.

Blocking 2: a server that doesn't parse tool calls scored zero silently. I went with option (b), plus a fix for the path that's still left:

  • AsyncEvalRunner._enable_tool_parsing_for_tool_requests runs after _prepare_tasks. If any request carries tool schemas, it sets enable_auto_tool_choice on a vLLM server the run starts itself. An explicit setting, an external base_url server, and providers other than vllm_server are left alone. -t bfcl now runs with no override. I removed the override from the task docstring, both READMEs and the PR description.
  • The only way left to hit the misconfiguration is to pass enable_auto_tool_choice=false explicitly. For that case, vllm_server.agenerate now refuses the whole batch before dispatch rather than refusing each request, so the error reaches process_batch and every instance becomes a hard failure.
  • New regression test: the real VLLMServerProvider.agenerate with tool parsing off, driven through the real process_batch, asserts that each instance is a hard failure and that the error names --enable-auto-tool-choice. It fails if the refusal goes back to the per-request path. tests/runners/test_tool_parsing_auto_enable.py covers the auto-enable cases.

You're right that the underlying cause is a framework one: a provider exception swallowed by dispatch turns into an empty output with no error attached, and that scores zero. This PR doesn't change that general path.

Non-blocking 6. The suite flattening is filed as #448. It includes a reproduction on main and the full list of affected suites. A scan of all 299 registered suites found bfcl, olmobase:easy:qa:rc, science:all and science:nojudge. The figures quoted in the PR description now come from the latest run: bfcl reports 0.6870, and the correct value is 0.6977.

Non-blocking items 1–5, the question about BFCL v4 (#340, #341), and the two remaining nits (:prompt keeping fewshot_source, and the _cast_to_openai_type divergence) aren't addressed in this push.

pdasigi and others added 2 commits October 6, 2026 15:52
TaskConfig.to_dict serialized every SamplingParams field, so adding
fit_max_tokens_to_context changed the task hash of every registered
task, not only the BFCL chat regimes that set it. The field is now
emitted only when set, as the config already does for its own newer
fields, and every task that doesn't use it hashes as it did on main.

A test fails if a SamplingParams field is added without the same
treatment.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01P9Qzbda9kPQePRC7MKJxnu
@pdasigi
pdasigi merged commit cfdb35f into main Oct 8, 2026
8 checks passed
@pdasigi
pdasigi deleted the pd_bfcl_instruct branch October 8, 2026 16:49
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.

2 participants