Exploring Weaknesses in Function-Calling Models via Reinforcement Learning: An Adversarial Data Augmentation ApproachExploring Weaknesses in Function Call Models via Reinforcement Learning: An Adversarial Data Augmentation Approach
RL query model enhances FC data; Qwen3-0.6B on BFCL with ours+RL round 2 Overall Acc 44.21%.
- Function calling fine-tuning relies on human- or model-generated data. The authors believe this data lacks design targeting FC weaknesses, with repetitive patterns, fixed distributions, and targeted error cases that are difficult to scale.
- Instead of generating challenge queries from scratch, an RL-trained query model rewrites seed queries. The judge first checks tool names, then uses reasoning for semantic filtering; when FC answers incorrectly, the query gets a positive reward. Embedding regularization and early stopping are used to maintain rewriting diversity, followed by alternating fine-tuning with the FC model.
- In the two-round BFCL evaluation, Qwen3-0.6B's ours+RL round 2 Overall Acc is 44.21%, higher than the same table's LLM-sampled RL's 42.60% and the base model's 39.27%. On Qwen3-8B, this method's round 2 is 52.89%, lower than the base model's 55.64%.
- The paper does not have a dedicated section discussing limitations. The authors plan to explore more function-calling optimizations and apply them to other scenarios. Two rounds of results on BFCL are reported for four FC models; baseline LLM names, subset sample sizes, and ablations are not reported.
- Evaluated models
- Qwen3-0.6BQwen3-4BQwen3-8BQwen2.5-3B-Instruct
- Benchmarks
- BFCLxlam-function-calling-60k内部人工标注的真实工具数据集
- Metrics
- Overall AccNon-Live AST AccLive AccRelevance DetectionIrrelevance Detection
The paper proposes an adversarial data augmentation method based on reinforcement learning to identify and patch weaknesses in function-calling (FC) models. The method trains a query model to generate adversarial queries that specifically challenge the function-calling model, and adopts a zero-sum game formulation in which the query model and the function-calling model are trained alternately in iterations. The authors state that this framework helps improve the robustness of function-calling models and provides a systematic way to discover and correct weaknesses in large language models' ability to interact with external tools.
Paper analysis
What problem does this paper attempt to solve?
Existing FC training data lacks targeted design for weaknesses; the authors use RL adversarial rewriting to supplement it.
Existing function-calling training data lacks targeted design for model weaknesses, thus limiting generalization and robustness.
- Use case: The authors state that LLMs are serving as interfaces between users and external tools/APIs, needing to convert queries into selected functions and parameters. The authors believe this step relates to the model's practical utility.
- Existing shortcomings: Data used in SFT and RL comes from manual annotation or automatic model generation. The authors believe this data lacks targeting; manual data has repetitive patterns, automatic data has fixed distributions and insufficient diversity, and targeted construction of error cases is difficult to scale.
- Core hypothesis: The authors believe that FC model failure cases should be covered as much as possible. RL's exploratory nature can actively search for bad cases, i.e., queries that cause the FC model to produce incorrect function calls, and augment training data accordingly.
- This paper's approach: The authors propose adversarial data augmentation: using RL to train a query model to rewrite seed queries, alternating iteratively with the FC model in a zero-sum game, combined with curriculum learning to increase data difficulty.
What related research exists?
Related work includes function-call data fabrication and two-player adversarial RL; the authors say these do not generate data targeted at FC weaknesses.
Function calling capability
- Task positioning: Yao et al. (2023), Qin et al. (2024a), and Patil et al. (2024) regard function calling as a key capability for LLMs to accomplish real-world tasks. The paper mentions this only as background, not as a comparison with this work.
- Representation and interaction: Toolformer by Schick et al. (2023) and ToolGen by Wang et al. (2025) enhance tool use from token representation; Lin et al. (2025) focus on multi-turn interaction. The paper does not criticize each work individually.
Training data construction
- Automatic generation: APIGen (Liu et al., 2024) uses LLM Chain-of-Thought to generate data and uses another model for semantic validation. ADC (Zhang et al., 2025) automatically constructs challenging data and incorporates code tasks into training to strengthen format constraints.
- Scenario-specific data: The paper also mentions long-context function calling (Kate et al., 2025), diverse tool use (Chen et al., 2025), and complex tool calling (Zhong et al., 2025).
- Authors' criticism: The authors state that although the above training methods can improve FC models, none generate targeted data based on model weaknesses.
Two-player RL and adversarial training
Cooperation and adversarial: Zhou, Du, and Li (2024) and Ma et al. (2024) use interaction or cooperation between two LLMs for RL fine-tuning. DuoGuard (Deng et al., 2025) and GPO (Zheng et al., 2024) use an attacker-defender framework, targeting guardrail classification and response safety, respectively.
Self-play: Cheng et al. (2024), Chen et al. (2024), Wu et al. (2025), and Absolute Zero (Zhao et al., 2025) use single-model self-play. Goodfellow et al. (2014) is cited to illustrate that adversarial training provides challenging samples to the model.
Authors' criticism: The authors state that these two-player adversarial and self-play methods have not been validated in function calling, and they rely on simultaneous attack-defense training, lacking stability and controllability.
Baselines and benchmarks: The comparison is direct repeated sampling rewriting of seeds with an LLM (the paper does not name this LLM), and an unfine-tuned base model. Evaluation uses BFCL (Patil et al., 2025). Seeds are internally human-annotated real tool data; round 2 adds parallel-type samples from xlam-function-calling-60k.
The authors position this work as: using an RL query model to rewrite seeds according to FC weaknesses, and enhancing FC models with alternating iteration rather than simultaneous attack-defense training.
How does the paper address this problem?
The RL-trained query model rewrites seed queries, which after filtering and zero-sum rewards are alternately trained with the FC model.
Overall, this is adversarial data augmentation: an RL-trained query model rewrites seed queries to specifically induce errors in the FC model, which are then used for FC post-training. The two alternate iteratively in a zero-sum game rather than updating simultaneously.
Problem Setting and Seed Rewriting
- Two policies: Both are autoregressive LLMs, denoted π_Q and π_F. The authors view the interaction as a zero-sum game: the query model scores by causing FC errors, and the FC model scores by answering correctly.
- Rewriting rather than generating from scratch: Each entry in seed D_seed contains a query, context, and the expected correct function call. The query's input is formed by a template wrapping the original query and ground truth into a prompt; the paper does not provide the full template.
- Three reasons: The authors state that prompt diversity in seed queries helps train π_Q; ground truth can constrain rewriting; rewriting facilitates controlling data types, avoiding π_Q over-concentrating on one category, such as samples related to irrelevance.
Reward: Two-Stage Filtering and Zero-Sum Adversarial
- First stage: A larger judge performs function calls on rewritten queries, comparing only whether the tool name matches the ground truth. The authors state that parameters may have multiple correct answers, and comparing only tool names preserves rewriting flexibility. If the tool name does not match, it is marked as failed.
- Second stage: For those that pass, the judge then uses reasoning to check semantics, such as whether key fields are missing or whether the query is posed from the user's perspective. The bias the authors cite is rewriting becoming the assistant's perspective, misleading FC to play the user. If it passes, ϕ_valid is True. When both stages pass, r_judge is 1, otherwise -1.
- Adversarial reward: The authors state that using only non-thinking judgment has lower accuracy, and using only thinking is time-consuming, hence the two stages. The query's final reward is the adversarial reward, defined as radv=1 (only when r_judge is 1 and the FC output does not match the ground truth), otherwise -1. The FC's reward is defined as RF=1 (when its output matches the ground truth), otherwise -1. Rewards are given once per complete generation.
Diversity Constraints and Early Stopping
- Embedding regularization: The authors believe that late RL tends to generate similar rewrites, limiting subsequent FC generalization. Formula (6) adds a term for the embedding of rewrites within the batch to the expected reward, with weight α, to lower cosine similarity. Experiments use α=0.05, and the vector model is text2vec-base-multilingual because queries contain Chinese and English. The main text also mentions encouraging larger edit distance, while the formula writes cosine similarity. The paper does not give the batch size.
- Early stopping: Stop when the absolute difference in expected reward between adjacent time steps is less than ε for 10 time steps, with ε manually set to 0.2. The authors want to preserve diverse rewrites before the query model converges to some extent. The main text states collecting FC bad cases during sampling; Algorithm 1 step 9 writes collecting rewrites with negative reward and ground truth. The paper does not clarify whether these are the same batch.
Alternating Training and Curriculum Learning
- One round of iteration: First train the query model, then use its rewrites to train the FC model, obtaining the next round π_F. The FC side can use full-parameter SFT, LoRA, or RL; in experiments, both sides use PPO for RL.
- Curriculum learning: The authors adjust the training set composition by stage, with examples being single function calls early and multiple function calls later. Figure 2 shows filtering, adversarial reward, and mixed queries in one round. Experiments only do two rounds, with parallel-type samples added in round 2; the paper does not specify whether these two rounds correspond to single-call and multi-call respectively.
- Reported training set: FC training merges rewritten queries with seeds. To align with LLM sampling, about 5,100 entries are randomly drawn from rewritten results each round. The paper does not report the proportion of bad cases among them.
What experiments did the paper conduct?
Qwen3-0.6B ours+RL round 2 Overall Acc is 44.21%; the 8B with the same setting is 52.89%, lower than the base model.
Experimental setup
- FC models: The main text selects Qwen2.5-3B-Instruct, Qwen3-0.6B, Qwen3-4B, and Qwen3-8B. The GPU configuration also mentions Qwen3-1.7B using 4 H20 GPUs, but its scores are not reported in the main text.
- Other models: The query model is Qwen2.5-7B-Instruct, the judge is Qwen3-32B, and the sentence embedding is text2vec-base-multilingual. The baseline LLM for direct sampling rewriting is not specified in the paper.
- Data: Round 1 has about 1,700 internally human-annotated seeds; round 2 adds 300 parallel-type samples from xlam-function-calling-60k. Each round randomly samples about 5,100 rewrites, which are merged with seeds for training.
- Optimization: Two rounds alternate. For 0.6B, full-parameter SFT, LoRA, and RL are compared; for other sizes, only RL is reported. Both sides use PPO and verl for RL. α=0.05, early stopping threshold ε=0.2.
- Hardware: All are NVIDIA H20. The query model uses 8 GPUs; Qwen3-0.6B and Qwen3-1.7B use 4 GPUs; Qwen3-4B uses 8 GPUs; Qwen3-8B uses 16 GPUs. The paper does not specify the number of GPUs for Qwen2.5-3B-Instruct.
- Metrics and protocol: BFCL's Overall Acc, Non-Live AST Acc, Live Acc, Relevance Detection, and Irrelevance Detection. The paper does not report subset sample sizes, number of repetitions, or judgment details. Fine-tuning is in non-thinking mode; the base model uses prompt mode.
Main results
The table below shows Qwen3-0.6B on BFCL for the base model and round 2 (Table 1). One row in the table is written as Qwen3-0-6B, treated here as the same model. Round 1 is not in the table.
| Setting | Overall | Non-Live | Live | Relevance | Irrelevance | | Base | 39.27% | 56.73% | 53.93% | 66.67% | 90.35% | | LLM+LoRA round 2 | 37.82% | 48.58% | 58.60% | 83.33% | 75.20% | | ours+LoRA round 2 | 39.41% | 52.42% | 60.02% | 88.89% | 76.53% | | LLM+SFT round 2 | 33.59% | 38.56% | 55.00% | 61.11% | 78.16% | | ours+SFT round 2 | 34.94% | 55.00% | 50.64% | 88.89% | 54.61% | | LLM+RL round 2 | 42.60% | 64.31% | 61.35% | 83.33% | 72.36% | | ours+RL round 2 | 44.21% | 69.10% | 61.84% | 77.78% | 75.09% |
- Horizontal comparison: The authors state that fine-tuning with their data yields higher Overall Acc than LLM sampling. This holds for all three methods in round 2. In round 1, this is not always the case: ours+SFT Overall Acc is 31.41%, lower than LLM+SFT's 32.15%; ours+RL is 39.09%, lower than LLM+RL's 41.23%.
- Vertical comparison: The authors attribute the round 1 decline to not yet fitting the data distribution; after round 2, full-parameter SFT and RL overall performance increases. ours+LoRA Overall Acc drops from 41.77% in round 1 to round 2, and the authors do not include LoRA in this increase.
- Fine-tuning methods: The authors believe full-parameter SFT is the most unstable and prone to overfitting, LoRA provides limited improvement over the base, and RL yields the largest improvement on Qwen3-0.6B. The authors state that with their data plus RL, non-live and live are higher than the baseline and base; in round 1, ours+RL Non-Live AST Acc is 53.58%, lower than the base's 56.73%. The authors state that the base remains best on irrelevant detection because without function calling training it tends to reject many queries.
Different model sizes
- Overall Acc: Table 2 round 2 ours+RL / LLM+RL / base: Qwen3-4B is 52.88% / 50.96% / 52.18%; Qwen3-8B is 52.89% / 52.96% / 55.64%; Qwen2.5-3B-Instruct is 49.87% / 47.26% / 43.82%.
- Differences given by the authors: The authors state Qwen3-0.6B is 1.61% higher than the baseline and 4.94% higher than the base; for Qwen3-4B they state 1.92% and 0.7%. In the same paragraph, they first list Qwen3-4B as a smaller model, then later call it a larger model. The authors write 2.61% and 6.05% for Qwen2.5-7B-Instruct; Table 2 does not include that model, and these two differences match the Qwen2.5-3B-Instruct row.
- Authors' explanation for 8B: The authors state that for 8B, no advantage over the baseline and base is observed, and give three points: 8B already has strong function calling capability, leading to more low-quality rewrites exploiting reward hacking; the query model's scale limits rewriting, and larger FC requires a larger query model; as FC grows, the judge needs to be stricter, and with Qwen3-32B, reward hacking is more likely. The authors believe the method is more suitable for low-latency or offline deployment, such as chatbots and mobile devices.
Exceptions on sub-metrics
- Irrelevant detection cannot be extrapolated: The authors state the base remains best on irrelevant detection, corresponding to Qwen3-0.6B in Table 1. In Table 2, Qwen3-4B base Irrelevance Detection is 62.21%, and ours+RL round 2 is 72.81%.
- Relevance detection: Qwen3-4B base is 100.00%, Qwen3-8B base is 94.44%, and both have ours+RL round 2 at 88.89%. Qwen2.5-3B-Instruct's ours+RL round 2 is 94.44%, same as the base; LLM+RL round 2 is 72.22%.
- Live / non-live: Qwen3-8B base Non-Live AST Acc is 88.90% and Live Acc is 73.88%, while ours+RL round 2 is 87.52% and 72.99%. For this model, LLM+RL round 1 Live Acc is 75.66%, higher than the base. For Qwen2.5-3B-Instruct's Irrelevance, LLM+RL round 2 at 78.10% is higher than ours+RL's 71.73%.
Other ablations and analyses
- Embedding regularization, α, ε, two-stage filtering, curriculum data composition: the paper does not report separate ablation numbers.
- Thinking mode: the paper does not report BFCL scores; all reported fine-tuning is non-thinking.
- About 5,100 rewrites: the paper does not report the proportion passing filtering or constituting bad cases, nor the actual steps before early stopping.
What are some points that can be further explored?
The paper does not have a dedicated limitations section; the authors plan to explore more function calling optimizations and extend to other scenarios.
Limitations and future directions noted by the authors
- No dedicated section: The paper does not have a dedicated Limitations section, nor does it frame the scale differences in the current experiments as a methodological limitation.
- Future directions: The Conclusion states that the authors plan to explore more optimization methods related to function calling and attempt to apply them to scenarios beyond function calling.
Experimental coverage
- Reported models: The main text selects and reports Qwen3-0.6B, Qwen3-4B, Qwen3-8B, and Qwen2.5-3B-Instruct, each for two rounds. For 0.6B, it compares full-parameter SFT, LoRA, and RL; for other sizes, only RL is reported.
- Training roles: The query model is Qwen2.5-7B-Instruct, the judge is Qwen3-32B, the sentence embedding is text2vec-base-multilingual, and RL uses PPO. The GPU section also mentions Qwen3-1.7B using 4 cards, but its metrics are not reported in the main text.
- Data and protocol: Round 1 has about 1,700 internally human-annotated seeds; round 2 adds 300 parallel-type samples from xlam-function-calling-60k; each round has about 5,100 rewrites. Evaluation uses BFCL's five metrics. Fine-tuning is non-thinking, and the base model is in prompt mode.
- Not reported in the paper: The name of the baseline sampling LLM, sample sizes for each BFCL subset, number of repetitions, full template text, actual steps before early stopping, and separate ablations for embedding loss, early stopping, and two-stage filtering. The authors claim the method does not depend on specific seeds, but the main text does not report results with different seeds.
Summarize the main content of the paper
RL adversarial rewriting is used to enhance FC training; the small model's Overall increased in round 2, but the 8B and irrelevant detection did not show the same trend.
Positioning: Use reinforcement learning for adversarial data augmentation to expose and correct weaknesses in function-calling models.
- Problem: The authors believe that manually annotated and model-generated FC data are not specifically targeted at failure modes; the patterns and distributions are relatively fixed, and targeted error cases are difficult to scale.
- Approach: The query model starts from Qwen2.5-7B-Instruct and uses PPO to rewrite seeds. Qwen3-32B first checks tool names, then performs semantic filtering; when FC answers incorrectly, the query gets a positive reward. Embedding regularization and early stopping are used to suppress repetitive rewrites, then alternating fine-tuning with the FC model.
- 0.6B: On BFCL, Qwen3-0.6B's ours+RL round 2 Overall Acc is 44.21%, LLM+RL is 42.60%, and the base model is 39.27%. The authors state this is 1.61% higher than the baseline and 4.94% higher than the base model. In the same table, the two full-parameter SFT round 2 Overall Acc values are 33.59% and 34.94%, both lower than the base model. Irrelevance detection is highest with the base model at 90.35%; the authors believe the untrained base model tends to reject many queries.
- Other scales: Qwen2.5-3B-Instruct's ours+RL round 2 Overall Acc is 49.87%. The authors attribute the 2.61% higher than baseline and 6.05% higher than base model to Qwen2.5-7B-Instruct; Table 2 has no such row, and these two differences match the 3B row. Qwen3-8B's ours+RL round 2 is 52.89%, lower than the base model's 55.64% and also lower than LLM+RL's 52.96%. The authors attribute this to reward hacking, query model scale, and using Qwen3-32B as judge.
- Authors' conclusion: The authors believe this method improves the robustness and generalization of function calling and consider it more suitable for low-latency or offline deployment. The authors plan to continue researching function-calling optimization and extend it to other scenarios.