| name | adaptive-agent-foundation-model |
| title | A²FM: An Adaptive Agent Foundation Model for Tool-Aware Hybrid Reasoning |
| version | 0.0.2 |
| engine | skillxiv-v0.0.2-claude-opus-4.6 |
| license | MIT |
| url | https://arxiv.org/abs/2510.12838 |
| keywords | ["agent foundation model","hybrid reasoning","tool use","task routing","cost efficiency"] |
| description | Route queries to specialized reasoning modes (internal reasoning, tool calling, or instant answers) using task-aware routing and Adaptive Policy Optimization to reduce inference costs by 45% while maintaining accuracy. |
Technique: Adaptive Agent Foundation Model — Efficient Hybrid Reasoning Routing
Current agent systems face a fundamental efficiency problem: reasoning-centric LLMs excel at internal chain-of-thought but cannot invoke external tools, while agentic LLMs can call tools but often lack deep reasoning. Both architectures tend to over-apply their primary capability—reasoning models overthink simple queries, agentic models make unnecessary tool calls. A²FM solves this by dynamically routing to the right mode for each query.
Rather than forcing all queries through the same pipeline, A²FM identifies simple queries that need instant answers, moderate queries requiring reasoning, and complex queries demanding tool interaction. This three-mode approach prevents wasted computation while maintaining performance across diverse benchmarks.
Core Concept
A²FM operates on a route-then-align principle:
- Task-aware routing: Classify incoming queries into three modes
- Mode-specific trajectories: Maintain specialized reasoning paths for each mode
- Shared foundation backbone: All modes align under a single 32B model
- Adaptive Policy Optimization: Cost-regularized rewards enforce efficient mode selection
The innovation prevents over-specification: answering "What is the capital of France?" through multi-step tool calls is wasteful, as is reasoning deeply about straightforward requests.
Architecture Overview
- Input Router: Query embedding → classify as instant/reasoning/tool mode
- Instant Mode Handler: Direct answer generation for factual questions (no reasoning overhead)
- Reasoning Mode: Deep chain-of-thought without external tool calls
- Tool Mode: Sequential tool invocation with verification loops
- Unified Backbone: Shared 32B foundation LLM with mode-specific adapter layers
- APO Training: Reward shaping that favors cost-efficient paths
Implementation Steps
The routing decision happens once per query. This example shows how to implement query classification and mode-specific forward passes.
import torch
import torch.nn as nn
class AdaptiveRouterA2FM(nn.Module):
"""Route queries to instant/reasoning/tool modes based on complexity."""
():
().__init__()
.query_encoder = nn.Linear(embedding_dim, hidden_dim)
.router = nn.Sequential(
nn.ReLU(),
nn.Linear(hidden_dim, ),
nn.ReLU(),
nn.Linear(, )
)
.mode_names = [, , ]
():
encoded = .query_encoder(query_embedding)
mode_logits = .router(encoded)
selected_mode = torch.argmax(mode_logits, dim=)
mode_logits, selected_mode
():
query_emb = encode_query(query)
mode_logits, selected_mode = router_model(query_emb)
mode_idx = selected_mode.item()
mode_idx == :
answer = instant_handler.answer(query)
cost =
mode_idx == :
answer = reasoning_model.chain_of_thought(query, max_steps=)
cost =
:
answer = tool_model.invoke_tools_with_reasoning(
query, available_tools=TOOLS, max_calls=
)
cost =
answer, cost, mode_idx