Joint Optimization of Tool Creation and Use for Large Language Model Agents
Organizations: Appier AI Research · National Taiwan University
Abstract
Tool-augmented language models are bounded by the APIs humans bothered to write; existing tool-creation systems patch this by prompting a frozen LLM at inference time, leaving the model that writes a tool decoupled from the one that uses it, with no signal that the schemas it produces are schemas it can invoke. We propose SMITH (Schema-grounded Multi-task Iterative Tool Honing), a reinforcement learning framework that jointly trains tool creation and tool use inside a single policy. Each rollout is either a build task (write a tool from a few examples) or a use task (invoke a pooled tool on a held-out question). Three separate reward axes catch schema, code, and outcome failures independently, so each failure mode contributes its own gradient. A 4B Qwen3 trained with SMITH on 13 procedural reasoning tasks with exact verifiers reaches 79.8 macro-average accuracy on held-out tasks, the best across all evaluated methods and ahead of an untrained 30B-A3B tool-writer. It also reaches 40.4 on TabMWP-Hard and 42.6 on out-of-domain GQA (+7.6 over the best same-backbone inference-time baseline), without any visual or tabular training data. Tools written by our 4B models also lifted the performance of LFM-2.5-350M and Qwen3-30B-A3B under same reasoning tasks.
Figures & tables
| Seen | Unseen RG | |||||||
| Method | Avg | Logic | Game | Algebra | Arith | Algo | Avg | I/O |
| Standard CoT | 58.0 | 49.9 | 60.3 | 56.8 | 62.7 | 48.6 | 55.7 | 173 / 3,206 |
| LATM* [ 2 ] | 77.6 | 53.9 | 55.5 | 38.6 | 53.0 | 90.2 | 58.3 | 607 / 174 |
| LATM* - Qwen3-30B-A3B | 74.0 | 68.7 | 64.2 | 97.3 | 56.5 | 84.0 | 74.1 | 659 / 405 |
| CRAFT [ 35 ] | 74.1 0.7 | 27.4 1.3 | 89.5 0.0 | 94.2 1.2 | 76.6 1.1 | 95.0 0.0 | 76.5 0.4 | 1,226 / 418 |
| Trove [ 31 ] | 52.6 0.4 | 60.7 2.4 | 10.6 1.3 | 51.2 3.5 | 59.8 0.8 | 97.0 0.0 | 55.9 0.6 | 347 / 575 |
| Method | RG (Seen) | RG (Unseen) | TabMWP | GQA |
| LFM2.5-350M (no tool) | 14.2 | 11.6 | 0.0 | 0.1 |
| + Qwen3-4B-Instruct (tool writer) | 36.8 | 23.4 | 4.2 | 0.1 |
| + Qwen3-30B-A3B (tool writer) | 10.4 | 41.5 | 4.1 | 0.1 |
| + RL on LFM2.5-350M | 39.1 | 30.2 | 4.2 | 0.1 |
| + RL 4B (Ours) | 38.9 | 42.9 | 4.1 | 0.1 |
| Method | Held-out RG (10 tasks) | Seen RG (13 tasks) | TabMWP-Hard | GQA | Overall |
| LATM ∗ (30B writes its own tool) | 71.9 | 78.1 | 0.7 | 20.2 | 70.2 |
| SMITH-4B to 30B consumer | 74.5 | 84.6 | 38.8 | 30.2 | 76.6 |
| Baselines | Distilled | ||||||||
| Task | CoT | LATM | LATM* (30B) | CRAFT | TroVE | KTCE | ReTool | LATM (distill) | SMITH |
| TabMWP-Hard | 7.2 | 19.7 | 0.7 | 30.0 | 36.4 | 27.2 | 3.0 | 7.1 | 40.4 |
| GQA | 11.5 | 35.0 | 29.8 | 21.9 | 21.4 | 0.0 | 26.1 | 56.0 | 42.6 |
| Method | RG (Seen) | RG (Unseen) | TabMWP | GQA |
| Qwen3-8B (baseline) | 72.6 | 72.2 | 42.4 | 17.3 |
| SMITH: Qwen3-8B | 79.4 | 81.7 | 56.7 | 28.7 |
| SMITH: Self-Judge | 74.7 | 85.9 | 54.5 | 16.3 |
| Granite-3.3-8B (baseline) | 31.2 | 22.0 | 3.9 | 7.8 |
| SMITH: Granite-3.3-8B | 39.1 | 28.5 | 4.5 | 11.7 |
| Qwen3-4B-Instruct | Qwen3-8B | Granite-3.3-8B | ||||
| Metric | Base | SMITH | Base | SMITH | Base | SMITH |
| BFCLv4 | 45.1 | 48.6 | 43.3 | 55.8 | 36.3 | 38.7 |
| Method | Tool Use | RG (S) | RG (U) | TabMWP | GQA | |
| Qwen3-4B-Instruct | – | – | 61.85 | 47.01 | 19.70 | 20.86 |
| Tool Create | 30B-A3B | No | 77.43 | 59.39 | 15.60 | 37.01 |
| Tool Create | 4B | No | 73.88 | 68.80 | 17.70 | 35.82 |
| Decoupled Create/Use | 30B-A3B | Yes | 76.44 | 58.93 | 13.90 | 35.04 |
| SMITH : No Sync | 4B | Yes | 80.29 | 66.89 | 25.81 | 24.58 |
| SMITH : No LLM Judge | self | Yes | 82.57 | 67.81 | 18.30 | 42.63 |
Appendix figures & tables10 assets
Supplementary material from the paper’s appendix.
Appendix
| Step | env_reward | eval_reward | step1_fail | fn_mismatch | param_mismatch | judge_reward |
| 1 | 1.363 | 0.386 | 34.9% | 23.4% | 11.5% | 0.460 |
| 2 | 1.809 | 0.466 | 10.4% | 8.3% | 2.1% | 0.614 |
| 3 | 2.026 | 0.557 | 2.1% | 1.0% | 1.0% | 0.670 |
| 4 | 2.043 | 0.684 | 9.4% | 5.2% | 3.6% | 0.710 |
| 5 | 2.123 | 0.662 | 2.6% | 0.0% | 2.6% | 0.722 |
| LoRA sync applied after step 5 | ||||||
| Component | Condition | Penalty |
| Structural verifier | fn name absent | , trajectory terminates |
| LLM judge | fn name absent | (partial credit) |
| # | Principle | Implication |
| 1 | Hard failures must be hard everywhere. | If the verifier zeros a trajectory, the judge must also return zero for that condition. Never apply partial credit to a fatal structural error. |
| 2 | Align the judge prompt to verifier constraints. | Every binary constraint enforced by the verifier should appear verbatim in the judge prompt, with a scored negative example. |
| 3 | Log structural sub-metrics as first-class signals. | Track each constraint-violation rate independently. Set alerts on violation rates, not only on aggregate reward. |
| 4 | Gate the judge signal on verifier pass. | Apply whenever the verifier assigns to prevent gradient leaks from judge partial credit. |
| 5 | Structural constraints belong in the verifier, not the judge. | RL policies transfer styles associated with high reward. If a structural property can be enforced exactly by a rule, enforce it as a hard verifier check rather than as a soft judge preference. |
| Task | Category | Induction band (easy) | Evaluation band (hard) | Key difficulty axis |
| Bitwise arithmetic | Arithmetic | Expression depth 2 | Expression depth 4–5 | Nesting depth of the bit-operation expression tree |
| Cryptarithmetic | Arithmetic | unique letters (easy/medium puzzles) | unique letters, including 10-letter puzzles such as FORTY+TEN+TEN=SIXTY | Number of unique letters (exponential search space growth) |
| Bit counting | Algorithms | Integer values – | Integer values – | Magnitude of the input integer |
| LCM | Algorithms | 2 numbers, values 1–50 | 3–4 numbers, values 100–500 | Count and magnitude of operands |
| GCD | Algorithms | 2 numbers, values 1–500 | 3–4 numbers, values 1,000–5,000 | Count and magnitude of operands |
| Base conversion | Algorithms | Bases 2–10, values 1–500 | Bases 2–16, values 2,000–5,000 | Target base range and magnitude of the number |
| Hyperparameter | Value |
| Base model | Qwen3-4B-Instruct |
| Training dataset | JoeYing/ReTool-SFT |
| Adapter | QLoRA (4-bit NF4, double quantisation) |
| LoRA rank | 64 |
| LoRA | 128 |
| LoRA dropout | 0.05 |
| Hyperparameter | Value |
| Base model | Qwen3-4B-Instruct |
| Adapter | None (full fine-tuning) |
| Epochs | 4 |
| Sequence length | 16,000 tokens |
| Gradient accumulation | 18 |
| Micro-batch size | 2 |
| System | Tool creation timing | Weights changed? | Tools survive across problems? |
| KTCE | Fully offline (before any test problem) | No | Yes (fixed toolset) |
| CRAFT | Fully offline (before any test problem) | No | Yes (fixed library) |
| TroVE | Online / streaming (during test inference) | No | Yes (library grows sequentially) |
| SMITH | Trained offline via RL | Yes | Yes (quality-filtered pool) |
| Dimension | KTCE | CRAFT | TroVE | SMITH |
|---|---|---|---|---|
| Tool creation trigger | Per knowledge-subfield cluster of training data | Per training problem (diversity-sampled across epochs) | Per test problem that yields a novel, executable function | RL training rollout on build tasks |
| Tool structure | Python function + name / docstring / experience_pool | Python function + docstring + 4 SimCSE embedding vectors | Python function + docstring + frequency counter | Python function + OpenAI JSON schema |
| Tool verification | Execution + majority-vote during creation; loss-tracked during optimization | Execution + answer correctness at both specific and abstract stages | Implicit: tool enters library only if full solution executes correctly and wins 3-way selection | Execution accuracy as RL reward; format consistency as separate reward axis |
| Optimization / refinement | Explicit 5-iteration evolutionary loop: evaluate compute loss LLM delete / modify / add rollback if worse | None (one-shot: create, validate, deduplicate) | Implicit frequency-based forgetting: low-reuse tools pruned every 500 examples | RL training is the optimization loop; gradient updates improve the tool-writing policy itself |
| Retrieval mechanism | Two-stage: (1) subfield lookup from metadata; (2) LLM reads numbered list and selects tools | Multi-view SimCSE similarity across 4 views (name, explanation, docstring, original question) | None; entire current library injected into the import-mode prompt, library size bounded by trimming | None at test time; model generates the required tool directly (trained to do so) |
| Tool reuse across problems | Yes (fixed toolset shared across all test problems) | Yes (fixed library shared across all test problems) | Yes (tools created for problem available for problem onward) | Yes (shared execution-verified pool) |
| Task | Acc. (%) | N | Real LLM calls | Stub tool | Failure mode |
| ab | 0.0 | 210 | 64 / 210 | Yes | FM2 + FM3 |
| base_conversion | 0.0 | 210 | 0 / 210 | Yes | FM2 + FM3 |
| bitwise_arithmetic | 100.0 | 280 | 0 / 280 | N/A | FM1 (solver) |
| caesar_cipher | 82.4 | 210 | 0 / 210 | No | FM1 (solver) |
| calendar_arithmetic | 66.7 | 198 | 198 / 198 | Yes | FM2 |
| chinese_theorem | 100.0 | 100 | 0 / 100 | No | FM1 (solver) |
| Task | N | v1 | v2 (bundled) | v3 (punct.) | v4 (example) |
| bitwise_arithmetic a | 280 | 55.0 | 27.5 ∗ | 40.4 ∗ | 45.4 ∗ |
| caesar_cipher | 196 | 59.2 | excl. | 49.5 ∗ | 51.5 ∗ |
| chinese_theorem | 100 | 96.0 | 100.0 | 96.0 | 96.0 |
| count_bits | 210 | 100.0 | 100.0 | 100.0 | 100.0 |
| isomorphic_string | 350 | 100.0 | 100.0 | 100.0 | 100.0 |
| knights_knaves | 210 | 51.0 | 50.5 | 51.0 | 52.9 |
Tool-Augmented Language Model Agents
Tool-augmented language model agents use external tools, APIs, and environments to solve tasks beyond text generation alone.
See all 166 papers