Repository navigation
fix(xlam_fc): map compound xlam types and acknowledge tool calls instead of 404 - #5326
Conversation
|
/ok to test 7673304 |
svcnvidia-nemo-ci
left a comment
There was a problem hiding this comment.
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.
yaoyu-33
left a comment
There was a problem hiding this comment.
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_60k0.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 ofgym dataset collate --downloadfrom 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.jsonlhas 6function_call_outputitems, not 15.
Verdict: SHIP WITH CARE.
|
/ok to test f11b2d2 |
@qiaochuz-nv, there was an error processing your request: See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/2/ |
…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]>
|
/ok to test f11b2d2 |
|
/ok to test f610f84 |
…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]>
|
/ok to test 398a69a |
f610f84 to
398a69a
Compare
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/42393378769 |
|
Retrospective QA-fix tracking issue: #6176 |
What does this PR do?
xlam_fcgave 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):generate_dataset.pyknew only bare type names and mapped every compound xlam annotation ("int, optional","List[int]","bool, optional","Tuple[float, float]") to JSON-schema"string", whileexpected_answerskeep 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 claimingstring.{"detail":"Not Found"}(6/6 tool outputs in the shippedexample_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 anyPOST /{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 callsverifyshould 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 includeint, 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:SimpleResourcesServerregisters only/seed_session,/close_session,/verify,/aggregate_metrics; the server added no tool route, andsimple_agentreturns the error body to the model as the tool output._extract_function_calls_from_responsecollectsfunction_callitems from the wholeresponse.output, and_calculate_rewardrequiresnum_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[...]→arraywithitemswhen the members agree,Dict|Mapping[...]→object,Union[...]typed only when its members agree, anything else untyped).convert_parameter_typestays as a thin wrapper returning the top-level type.data/example.jsonlis regenerated with the fixed generator: ids, prompts,expected_answers, descriptions, defaults andrequiredare unchanged; the declared types of 9 parameters change (t3ma.{v_factor,outputsize,time_period}andget_animes.{year_greater,year_less,limit,offset,year_equal}→integer,get_animes.sort→boolean).example_metrics.jsonre-collated: unchanged.app.py: catch-allPOST /{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.xlam_function_calling_60k0.0.1) still carries the old schemas until it is republished.f11b2d210, @yaoyu-33; main85193811bmerged inb2e421ed7for thenemo_gym.coreimport move):parameter_schemareturns{}for an annotation of only separators or spaces instead of raisingIndexError; 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, asstring) 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 withnum_predicted2); 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_60kversion0.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'sgitlab_identifierthen bumps).data/example_rollouts.jsonlis regenerated in this PR's second commit (see below). Also not done: emitting adefaultof the matching JSON type; the generator still copies the xlam default verbatim (v_factorkeeps"default": 0.7underinteger, severalget_animesparameters keep"default": ""), as the file already did for integer parameters before this change;strict: falseschemas tolerate it.Before the fix
Gym
0b8783981(main when the branch was cut; the e2e control below ran on mainf70bf75c3):.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]']})"Main's
convert_parameter_typetypes 16 of the dataset's 30 distinct annotation strings (67,595 parameters) asstring: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 againststringschemas.After the fix
Gym
f11b2d210(this branch head, main85193811bmerged in), same commands:e2e control on h100 (QA case
xlam_fc, README flow: full dataset generation, then Qwen3-8B on vLLM over--limit 10of the fresh train split; run20261029T165950842371Z-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 sequencesRFORM×7 /RFFOORM×3: no row made a call after the acknowledgement and no row endedincomplete. 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): rewards1.0, 1.0, 1.0, 0.0, 1.0(was1.0, 1.0, 1.0, 0.0, 0.0), all 6 tool outputs are the acknowledgement (were{"detail":"Not Found"}); thet3marow now scores 1.0 (time_period: 14against anintegerschema), and the remaining 0.0 (list_titles,release_date_start20100101 vs expected 20110101) is a model error in both files. Two of the five rows (t3ma,list_titles) end withng_termination_reason: incomplete_reasoning: after the acknowledgement the model began another<tool_call>inside its final reasoning item, which never became afunction_callitem, sonum_predictedstays 1 andt3makeeps 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
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 (main166af7d0d, run20261029T012328511471Z-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, run20261029T165950842371Z-01c8eb7c) 1/1 PASS in 72.8s,mean/reward 0.9.resources_servers/xlam_fc/tests: 65 passed atf11b2d210(10 on main, 55 added: 4 intest_app.py, of which the acknowledgement test fails on main, and 51 intest_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.pycommitted-data sweep (-k "committed or Repo or sweep"): 12 passed with the regeneratedexample.jsonl.pre-commit run --files resources_servers/xlam_fc/...: passed.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: completedtool records. Datasets generated with the old generator keep working but still carrystringschemas for compound annotations; regenerate them to benefit from the fix.🤖 Generated with Claude Code