Skip to content

fix(xlam_fc): map compound xlam types and acknowledge tool calls instead of 404 - #5326

Merged
cmunley1 merged 3 commits into
mainfrom
qiaochuz/nvb-6900453-xlam-fc-types-first-turn
Nov 7, 2026
Merged

cmunley1 merged 3 commits into
mainfrom
qiaochuz/nvb-6900453-xlam-fc-types-first-turn

Conversation

@qiaochuz-nv

@qiaochuz-nv qiaochuz-nv commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

xlam_fc gave reward 0 to tool calls that were correct. Two defects in the same environment, found in the r0.7.0 rc1 QA audit (all 5 zero-reward rows of the rc1 sample were caused by them; re-scoring that sample with both fixed gives 1.0 instead of 0.5):

  • Schema types. generate_dataset.py knew only bare type names and mapped every compound xlam annotation ("int, optional", "List[int]", "bool, optional", "Tuple[float, float]") to JSON-schema "string", while expected_answers keep the native values and the verifier compares them strictly. 24.8% of train rows (14,657 / 59,000) and 25.0% of validation rows could only be won by a call that broke the declared schema. The tool schemas now follow the annotation, and an annotation that cannot be typed (Callable[...], Union[int, str]) is left untyped instead of claiming string.
  • 404 tool results. The resources server defined no tool routes, so every tool call came back as {"detail":"Not Found"} (6/6 tool outputs in the shipped example_rollouts.jsonl, 26/26 in the rc1 run); with no turn cap the model retried, and every retry counted against it. The server now acknowledges any POST /{tool_name} with a short JSON body, so the model never sees an error for a tool it was told to use. The acknowledgement does not stop repeated calls: in the 10-row README flow on this branch no row called again after it, but 2 of the 5 regenerated example rows began another <tool_call> inside their final reasoning item (see Rollout evidence). Which calls verify should grade (every turn's, as today, or only the first tool-calling turn's) is left as it is on main: that is a product decision, tracked as a QA discussion with the environment's authors, not taken in this PR.

Fixes NVBug 6900453.

Cause

  • resources_servers/xlam_fc/generate_dataset.py:41 (unchanged since Salesforce xlam-function-calling-60k resources server #262): type_mapping.get(param_type.lower(), "string"). The dataset's 30 distinct annotation strings include int, optional (32,701 parameters), List[int] (7,865), List[float] (7,385), bool, optional (7,377), float, optional (4,143), Tuple[float, float] (1,172); none of them is in the mapping.
  • resources_servers/xlam_fc/app.py: SimpleResourcesServer registers only /seed_session, /close_session, /verify, /aggregate_metrics; the server added no tool route, and simple_agent returns the error body to the model as the tool output. _extract_function_calls_from_response collects function_call items from the whole response.output, and _calculate_reward requires num_correct == len(expected_answers) == len(predicted_calls), so each retry after a 404 cost the row its reward (unchanged here; see the discussion note above).

Fix

  • generate_dataset.py: parameter_schema(annotation) parses the xlam type string (qualifiers after the first top-level comma dropped, Optional[X] → X, List|Tuple|Set|Sequence[...] → array with items when the members agree, Dict|Mapping[...] → object, Union[...] typed only when its members agree, anything else untyped). convert_parameter_type stays as a thin wrapper returning the top-level type. data/example.jsonl is regenerated with the fixed generator: ids, prompts, expected_answers, descriptions, defaults and required are unchanged; the declared types of 9 parameters change (t3ma.{v_factor,outputsize,time_period} and get_animes.{year_greater,year_less,limit,offset,year_equal} → integer, get_animes.sort → boolean). example_metrics.json re-collated: unchanged.
  • app.py: catch-all POST /{tool_name} → {"status": "ok", "message": "<tool> call recorded. xlam_fc grades tool calls against the dataset; tools are not executed."} (precedents: citation_if, nullable_tool_args, fix: register get_weather on example_tool_call_multireward #2270 for NVBug 6533992). The verifier is unchanged.
  • README: a "Scoring" section stating what is graded today, the acknowledgement, and the schema types, and that the registry artifact the config pins (xlam_function_calling_60k 0.0.1) still carries the old schemas until it is republished.
  • Review follow-up (f11b2d210, @yaoyu-33; main 85193811b merged in b2e421ed7 for the nemo_gym.core import move): parameter_schema returns {} for an annotation of only separators or spaces instead of raising IndexError; the generator tests are parametrized over the 30 distinct annotation strings extracted from the 60,000-row source (main types 16 of them, 67,595 parameters, as string) plus 15 spellings outside the dataset; two tests drive the whole flow through the app (/timezone_for_location → acknowledgement → /verify: 1.0, and the same call repeated after the acknowledgement: 0.0 with num_predicted 2); SPDX header on the new test module; the conversion docstring shows "strict": False.

Left open on purpose: grading the first tool-calling turn only (so retries after a tool output never change the grade) would also have fixed rc1 task 6 (first turn exact, then six retries of the 404 reply → 8 predicted / 2 correct / 0.0), but it changes what the environment measures: a model that answers a multi-call row across several turns can score 1.0 only under today's all-turn counting. No doc states which rule is intended, so this PR keeps main's rule and the question is with the environment's authors (QA discussion D3).

Not in this PR: the GitLab registry artifact xlam_function_calling_60k version 0.0.1 (train.jsonl, valid.jsonl) was produced by the old generator and carries the old schemas; it should be regenerated with this generator and published as a new version (the config's gitlab_identifier then bumps). data/example_rollouts.jsonl is regenerated in this PR's second commit (see below). Also not done: emitting a default of the matching JSON type; the generator still copies the xlam default verbatim (v_factor keeps "default": 0.7 under integer, several get_animes parameters keep "default": ""), as the file already did for integer parameters before this change; strict: false schemas tolerate it.

Before the fix

Gym 0b8783981 (main when the branch was cut; the e2e control below ran on main f70bf75c3):

.venv/bin/python -m pytest resources_servers/xlam_fc/tests/test_app.py -q
.venv/bin/python -c "import sys; sys.path.insert(0, 'resources_servers/xlam_fc'); from generate_dataset import convert_parameter_type as c; print({t: c(t) for t in ['int, optional', 'List[int]', 'bool, optional', 'Tuple[float, float]', 'Optional[int]']})"
FAILED resources_servers/xlam_fc/tests/test_app.py::TestToolRoutes::test_any_tool_call_is_acknowledged
E       AssertionError: {"detail":"Not Found"}
E       assert 404 == 200
1 failed, 13 passed   (this branch's test_app.py against main's app.py; test_generate_dataset.py does not import on main: parameter_schema is new)

{'int, optional': 'string', 'List[int]': 'string', 'bool, optional': 'string', 'Tuple[float, float]': 'string', 'Optional[int]': 'string'}

Main's convert_parameter_type types 16 of the dataset's 30 distinct annotation strings (67,595 parameters) as string: int, optional, List[int], List[float], bool, optional, float, optional, List[List[int]], List[Union[int, float]], Tuple[float, float], List[str], List[List[float]], Callable[[float], float], set, List[Tuple[float, float]], List[List[str]], List[Tuple[int, int]], int, optional, default=100.

QA run (rc1, GPU lane, Qwen3-8B): mean/reward 0.5; 26 of 26 tool outputs {"detail":"Not Found"}; task 6 first-turn calls exact, then 6 retries of the error → num_predicted 8, num_correct 2, reward 0.0; tasks 1, 7, 9 lost only on "[1, 2, 3, 4, 3, 2, 1]" / "30" / "15.2,25.6,..." sent against string schemas.

After the fix

Gym f11b2d210 (this branch head, main 85193811b merged in), same commands:

.venv/bin/python -m pytest resources_servers/xlam_fc/tests -q
65 passed
{'int, optional': 'integer', 'List[int]': 'array', 'bool, optional': 'boolean', 'Tuple[float, float]': 'array', 'Optional[int]': 'integer'}

e2e control on h100 (QA case xlam_fc, README flow: full dataset generation, then Qwen3-8B on vLLM over --limit 10 of the fresh train split; run 20261029T165950842371Z-01c8eb7c): mean/reward 0.9 (rc1 sample with the old code: 0.5), 13 tool calls / 12 correct, every one of the 13 tool outputs is the acknowledgement {"status":"ok","message":"<tool> call recorded. ..."} (none is {"detail":"Not Found"}), item sequences RFORM ×7 / RFFOORM ×3: no row made a call after the acknowledgement and no row ended incomplete. The one 0.0 row matched 1 of its 2 expected calls, a model miss.

Regenerated data/example_rollouts.jsonl (76733047f, README command on this branch, Qwen3-8B on one H100): rewards 1.0, 1.0, 1.0, 0.0, 1.0 (was 1.0, 1.0, 1.0, 0.0, 0.0), all 6 tool outputs are the acknowledgement (were {"detail":"Not Found"}); the t3ma row now scores 1.0 (time_period: 14 against an integer schema), and the remaining 0.0 (list_titles, release_date_start 20100101 vs expected 20110101) is a model error in both files. Two of the five rows (t3ma, list_titles) end with ng_termination_reason: incomplete_reasoning: after the acknowledgement the model began another <tool_call> inside its final reasoning item, which never became a function_call item, so num_predicted stays 1 and t3ma keeps its 1.0 for that reason alone (under the all-turn rule an emitted second call would have scored it 0.0). The acknowledgement therefore does not stop repeated calls; this is recorded for the grading-rule discussion (D3).

Validation

  • QA testcase xlam_fc (nmfw_tests, GPU lane, one H100) with the updated case (independent annotation parser, tool-acknowledgement probe, all-turn oracle as on main): before (main 166af7d0d, run 20261029T012328511471Z-773cac1b) 0/1, FAIL (13.8s): full source conversion/content and seeded split order (the generated schemas disagree with the annotations before any model runs; the registered case passed on main only because its oracle mirrored the lossy mapping); after (this branch, run 20261029T165950842371Z-01c8eb7c) 1/1 PASS in 72.8s, mean/reward 0.9.
  • resources_servers/xlam_fc/tests: 65 passed at f11b2d210 (10 on main, 55 added: 4 in test_app.py, of which the acknowledgement test fails on main, and 51 in test_generate_dataset.py, which does not import on main). The generator tests are parametrized over all 30 distinct annotation strings in the dataset, extracted from the 60,000-row source, plus 15 spellings outside it.
  • tests/unit_tests/test_task_data.py committed-data sweep (-k "committed or Repo or sweep"): 12 passed with the regenerated example.jsonl.
  • pre-commit run --files resources_servers/xlam_fc/...: passed.
  • Rollout evidence: the h100 e2e run above (10 real Qwen3-8B rows) and the regenerated data/example_rollouts.jsonl (76733047f).

Compatibility

The verify response is unchanged. Tool calls now return a 200 acknowledgement instead of a 404, so trajectories with tool calls carry status: completed tool records. Datasets generated with the old generator keep working but still carry string schemas for compound annotations; regenerate them to benefit from the fix.

🤖 Generated with Claude Code

@qiaochuz-nv qiaochuz-nv added bug Something isn't working QA_fix Fix implemented by a QA team member area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers needs-review PR is ready for code review and waiting on a reviewer complexity:low Localized change in one scope with a small, straightforward review surface labels Oct 29, 2026
@qiaochuz-nv
qiaochuz-nv requested a review from yaoyu-33 October 29, 2026 17:54
@copy-pr-bot

copy-pr-bot Bot commented Oct 29, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@qiaochuz-nv

Copy link
Copy Markdown
Contributor Author

/ok to test 7673304

@nemo-automation-bot
nemo-automation-bot Bot requested a review from a team October 29, 2026 18:07

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

SHIP

LGTM — no concerns found.

Reviewed all seven changed files and traced the schema generator, tool acknowledgement route, session endpoints, model-request conversion, and verifier consumption. The committed examples and rollout rewards agree with the unchanged scoring contract.

Static inspection only; tests and model runs were not executed. One delegated runtime report was unavailable, so that topic was independently re-inspected before completing the review.

Note: formal approval is not available for this request, so this review is posted as a comment only.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

cmunley1
cmunley1 previously approved these changes Oct 30, 2026
@cmunley1
cmunley1 enabled auto-merge October 30, 2026 05:11

@yaoyu-33 yaoyu-33 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for the careful write-up and the before/after evidence. Both defects are real, and the fix stays focused. The catch-all follows the nullable_tool_args / citation_if pattern and is registered after the protocol routes, so /seed_session, /close_session, /verify and /aggregate_metrics still reach their handlers (we checked this against Starlette 1.3.1). Re-running verify over the committed rollouts reproduces the recorded rewards, and gym env test --resources-server xlam_fc passes locally (41 passed).

There is one RISK and a few small notes inline. Beyond those:

  • CI: "Unit tests / Test" failed on three unrelated harbor image tests. That skipped "Changed server tests", so the xlam_fc tests have not run in CI at this head. A green re-run before merge would be good.
  • Registry dataset: the config still pins xlam_function_calling_60k 0.0.1, which you note was built by the old generator. A line in the README's Scoring section saying so, with a link to the tracking issue for the republish, would stop users of gym dataset collate --download from assuming they have the typed schemas.
  • PR body numbers: a few figures don't match the final diff. On main, xlam_fc has 10 tests, not 16, and the final diff adds 31. On main, example_rollouts.jsonl has 6 function_call_output items, not 15.

Verdict: SHIP WITH CARE.

@qiaochuz-nv

Copy link
Copy Markdown
Contributor Author

/ok to test f11b2d2

@qiaochuz-nv
qiaochuz-nv dismissed stale reviews from cmunley1 via f11b2d2 October 30, 2026 16:05
@copy-pr-bot

copy-pr-bot Bot commented Oct 30, 2026

Copy link
Copy Markdown

/ok to test f11b2d2

@qiaochuz-nv, there was an error processing your request: E2

See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/2/

qiaochuz-nv added a commit that referenced this pull request Oct 30, 2026
…type strings and the verify flow

parameter_schema raised IndexError on an annotation made only of commas or
spaces (","), which would abort a whole generation run; it now returns {}
like any other annotation it cannot type.

The generator tests are parametrized over the 30 distinct annotation strings
in Salesforce/xlam-function-calling-60k (main's mapping typed 16 of them, 67,595
parameters, as "string"), plus the spellings the dataset does not use. Two tests
drive the whole flow through the app: a tool call answered by the
acknowledgement route and then graded by /verify (reward 1.0), and the same
call repeated after the acknowledgement (0.0, num_predicted 2), which also pins
that /verify still reaches its handler with the catch-all registered.

Also: SPDX header on the new test module, the conversion docstring shows
"strict": False as the code emits, and the README says the pinned registry
artifact xlam_function_calling_60k 0.0.1 still carries the old schemas until it
is republished.

Found in review of #5326 by yaoyu-33.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: qiaochuz <[email protected]>
@qiaochuz-nv

Copy link
Copy Markdown
Contributor Author

/ok to test f11b2d2

@qiaochuz-nv

Copy link
Copy Markdown
Contributor Author

/ok to test f610f84

qiaochuz-nv and others added 3 commits November 6, 2026 23:18
…ead of 404

xlam_fc gave reward 0 to correct tool calls in two ways (NVBug 6900453):

- generate_dataset.py mapped every compound xlam type annotation ("int, optional",
  "List[int]", "bool, optional", "Tuple[float, float]") to JSON-schema "string",
  while expected_answers keep the native values and the verifier compares them
  strictly, so a model that followed the declared schema could not match 24.8% of
  the train rows. parameter_schema() now parses the annotation (qualifiers after
  the first top-level comma dropped, Optional/Union/array/object generics, items for
  homogeneous arrays) and leaves an untypeable annotation untyped instead of
  claiming "string". The committed example.jsonl is regenerated: only the declared
  types of nine parameters change.
- The resources server had no tool routes, so every tool call the model made came
  back as {"detail":"Not Found"}; with no turn cap the model retried, and every
  retry counted against it. A catch-all POST /{tool_name} now returns a short
  acknowledgement, so the model never sees an error for a tool it was told to use.
  In the README flow on this branch (Qwen3-8B) no row made a call after the
  acknowledgement.

Which calls the verifier should grade (every turn's, as today, or only the first
tool-calling turn's) is a product decision left open; the verifier is unchanged.

Tests cover the parser over the dataset's annotation shapes, the acknowledgement
route and the session contract. README documents the scoring, the acknowledgement
and the schema types.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: qiaochuz <[email protected]>
…knowledged tool calls

README command on this branch (gym env start --model-type vllm_model --resources-server xlam_fc; gym eval run
--no-serve --agent xlam_fc_simple_agent --input resources_servers/xlam_fc/data/example.jsonl --limit 5; Qwen3-8B
on one H100): rewards 1.0, 1.0, 1.0, 0.0, 1.0 and every tool output is the acknowledgement. The previous file
(Qwen3-30B-A3B, #262) had {"detail":"Not Found"} on all 6 tool outputs and scored the t3ma row 0.0 for
time_period "14" against a string schema (NVBug 6900453); the remaining 0.0 (list_titles, release_date_start
20100101 vs 20110101) is a model error in both files.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: qiaochuz <[email protected]>
…type strings and the verify flow

parameter_schema raised IndexError on an annotation made only of commas or
spaces (","), which would abort a whole generation run; it now returns {}
like any other annotation it cannot type.

The generator tests are parametrized over the 30 distinct annotation strings
in Salesforce/xlam-function-calling-60k (main's mapping typed 16 of them, 67,595
parameters, as "string"), plus the spellings the dataset does not use. Two tests
drive the whole flow through the app: a tool call answered by the
acknowledgement route and then graded by /verify (reward 1.0), and the same
call repeated after the acknowledgement (0.0, num_predicted 2), which also pins
that /verify still reaches its handler with the catch-all registered.

Also: SPDX header on the new test module, the conversion docstring shows
"strict": False as the code emits, and the README says the pinned registry
artifact xlam_function_calling_60k 0.0.1 still carries the old schemas until it
is republished.

Found in review of #5326 by yaoyu-33.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: qiaochuz <[email protected]>
@qiaochuz-nv

Copy link
Copy Markdown
Contributor Author

/ok to test 398a69a

@cmunley1
cmunley1 added this pull request to the merge queue Nov 7, 2026
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42393378769

Merged via the queue into main with commit bfb4698 Nov 7, 2026
62 checks passed
@cmunley1
cmunley1 deleted the qiaochuz/nvb-6900453-xlam-fc-types-first-turn branch November 7, 2026 17:08
@qiaochuz-nv

Copy link
Copy Markdown
Contributor Author

Retrospective QA-fix tracking issue: #6176

This branch was previously deployed

1 inactive deployment
public — 398a69ab Deployed Nov 7, 2026 by copy-pr-bot[bot] via release / finalize / notify #10840
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers bug Something isn't working complexity:low Localized change in one scope with a small, straightforward review surface needs-review PR is ready for code review and waiting on a reviewer QA_fix Fix implemented by a QA team member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants