Paper explained · Tool-use agents

HyperAgent: turn “which tool next?” into “which requirement is missing?”

A tool can be relevant to a task and still be impossible to call. HyperAgent makes the missing inputs and prerequisites explicit, then plans around the values and effects the agent already has.

Zian Zhai, Xingyu Tan, Gaowang Zou, Xiaoyang Wang, Wenjie Zhang · University of New South Wales

Original paper · PDF

1. The problem: similarity is not executability

Imagine asking an agent to remind a roommate about an unpaid payment request. A semantic retriever may correctly find a send_reminder API. But that API might require a phone number, a payment-request identifier, and an authenticated session. The request says what to do, not how to obtain these arguments.

Some necessary tools—logging in, looking up contacts, finding a payment request—may sound less similar to the original instruction. Returning only the most semantically relevant APIs can therefore omit precisely the tools needed to make the target API usable.

A coarse tool graph

lookup_contact → send_reminder

This says the tools are related. It does not say whether the contact lookup supplies the phone number, the request ID, or both. Nor does it say which other requirements remain.

A schema-level dependency

lookup_contact.phone → send_reminder.phone

This explains exactly what one tool supplies to another. The planner can distinguish a useful prerequisite from an irrelevant neighbor.

Why a hypergraph?

An ordinary directed edge connects one node to another. A directed hyperedge connects a set of inputs to a set of outputs. A tool is naturally such a relation: it requires its inputs jointly, and one invocation produces its outputs together.

{session, phone, request_id} — send_reminder → {reminder_sent}

Having a phone number alone is not sufficient. The set on the left is an AND requirement. Conversely, a contact lookup that returns both email and phone can satisfy two downstream requirements with one call.

Keep data and effects separate in your thinking. A contact lookup returns reusable values. A login creates a state condition; a reminder API changes the world. HyperAgent models both, because not all prerequisites and goals are ordinary returned fields.
authenticated sessionphone numberrequest IDsend_reminderreminder_sentall inputs required

Teaching illustration, not an API diagram reproduced from the paper.

2. The method: three graphs, two planning scales

HyperAgent does not replace reasoning with a single static tool chain. It combines a global dependency model, a task-level plan, and a fresh tool-level plan for the current state.

StructureWhat it representsWhen it is used
Tool–Schema Hypergraph (TSH)All modeled tools, their input/output/effect nodes, and port-level support linksReusable global structure
Tool Context GraphA compact, task-relevant subset of the TSH, including prerequisitesBefore task decomposition
Task DAGSubgoals and their data, effect, or ordering dependenciesHigh-level execution control; refined as needed
Tool Support SubgraphA candidate composition supporting one subgoal from the current stateBuilt dynamically for a ready subtask

The Task DAG and Tool Support Subgraph answer different questions. The first says “which subgoal must precede which?” The second says “which concrete producers are still necessary to execute this subgoal now?”

Step A — Build the global hypergraph

The authors start with In-N-Out, a parameter-level API graph built using LLM filtering and expert annotation. They convert each API into a hyperedge while preserving input/output schema nodes and cross-API dependency links.

They then enrich this structure with effects and conditions that do not appear as explicit API parameters. GPT-4o proposes state changes, preconditions, and alignments from documentation; experts validate them. Candidate effect–condition pairs are filtered for domain/entity compatibility, scored for semantic relevance, and reviewed by humans. Accepted state links are labeled strong or weak.

A dependency link means an output may support an input. It is a model of compatibility, not proof that every runtime value will be valid.

Step B — Retrieve a prerequisite-aware planning context

  1. Interpret the task: the LLM separates intended operations from schemas, values, constraints, and desired effects.
  2. Anchor tools: embedding similarity retrieves top-ranked tool descriptions above a threshold.
  3. Anchor schemas: input-side and output-side schema nodes are independently retrieved from the schema-level interpretation. Relevant producers and consumers add more seed tools.
  4. Expand backward: from needed input nodes, traverse support links backward to candidate producer tools. Add their inputs to the next frontier, within a hop budget.
backward score = dependency weight × cosine similarity(tool, intended operations)

This is not unrestricted graph traversal. Candidate limits, similarity thresholds, and hop budgets keep the context compact. They also introduce a trade-off: more expansion can recover prerequisites, but too much expansion adds distracting tools and tokens.

Step C — Ask the LLM for a schema-aware Task DAG

The retrieved context is serialized as tool names/descriptions, schema nodes, and producer-output → consumer-input links. The planner uses it to create subtasks. Each subtask records a local goal, target outputs/effects, candidate terminal tools, and execution status. DAG edges are grounded in the relevant dependencies rather than just a prose list of steps.

The agent selects a ready subtask—one whose predecessors have completed. This topological readiness is not yet enough to execute an API: its actual runtime inputs may still be missing.

Step D — Build a support graph from the current deficits

The runtime state stores execution history, subtask statuses, and schema–value bindings plus achieved effects. The same subgoal can require a different tool composition depending on that state. If a previous subtask already produced the request ID, retrieving it again is unnecessary.

deficits = required inputs − inputs grounded in state − inputs supported by selected producers

Deficit-Oriented Expansion (DOE) starts from each candidate terminal tool and searches backward for producers. Its support score for a tool e and input r is the strongest output-to-input link from that tool:

ρ(e, r) = max support weight from any output of e to r
Ω(e, M) = sum of ρ(e, r) over currently missing inputs r

A producer that covers several deficits can score higher than one that covers only one. The authors precompute these support scores in a sparse producer matrix for efficient lookup.

  1. Rank producer tools by overlap Ω with the current deficit set.
  2. Expand the top-K candidates: add one producer, remove requirements it supports, and add its own unresolved inputs.
  3. Rank the resulting candidates by remaining deficit count; retain a beam of width B.
  4. Stop expanding a candidate when its deficits are empty. Choose a complete support graph for execution.

K controls how many producer directions are explored; B controls how many competing partial graphs survive. This is bounded search, not an optimal-cost planner.

Step E — Execute, verify, and revise

The executor uses a persistent restricted Python REPL, so intermediate values can be reused. A successful API response does not automatically mean a subtask is complete. Verification checks expected outputs, effects, and constraints against the execution trace, valid bindings, intermediate results, and observed effects.

Verified outputs enter the state. If a subtask fails or no feasible support graph exists, observations are retained and the remaining Task DAG can be refined. The method therefore separates structural feasibility, runtime execution, and goal satisfaction.

InterpretOperations + schemas
RetrieveTools + prerequisites
DecomposeTask DAG
ResolveCurrent deficits
Execute & verifyUpdate state; refine

The main implementation uses GPT-4o for semantic components and ReAct-Code execution. Context extraction, DOE, and runtime binding validation are deterministic modules unless semantic ambiguity requires an LLM.

3. Playground: send one payment reminder

Try changing what is already known. The planner searches backward from send_reminder, but execution runs forward only when all inputs are available. A joint contact lookup can produce both phone and email.

Teaching model, not a reproduction. This tiny simulation uses exact schema names, unit-weight links, one terminal tool, a small beam, and synthetic APIs. It omits semantic retrieval, LLM task decomposition/refinement, entity disambiguation, and real services. Credentials and the roommate’s name are always initially available.

Initial state

The last switch affects execution, not the schema graph. If the request ID is already known, lookup is unnecessary and this switch has no effect.

Runtime facts

Executable order

Search and execution trace

Inspect the synthetic tool catalog
ToolRequired inputsOutputs / effects
logincredentialssession
lookup_contactsession, roommate_namephone, email
lookup_phonesession, roommate_namephone
lookup_emailsession, roommate_nameemail
lookup_paymentsession, emailrequest_id
send_remindersession, phone, request_idreminder_sent

What to notice

Changing any control resets the run. Search ties favor a smaller selected graph, a teaching convenience not specified as the paper’s DOE ranking rule. The simulation also checks for a forward executable schedule; an empty structural deficit set alone can hide circular support in a poorly formed graph.

4. A minimal prototype you can reason through

The essential implementation is set algebra plus bounded search. Real systems additionally need port-level links, typed values, entity scope, and evidence validation.

// Teaching pseudocode: exact schema names stand in for port links.
function deficits(selectedTools, known) {
  const required = union(selectedTools.map(t => t.inputs));
  const produced = union(selectedTools.map(t => t.outputs));
  return required.difference(known.union(produced));
}

beam = [{ tools: [terminal] }];
while (beam.length && depth < limit) {
  next = [];
  for (candidate of beam) {
    missing = deficits(candidate.tools, known);
    if (missing.size === 0) { complete.push(candidate); continue; }
    producers = rankByOutputOverlap(catalog, missing).take(K);
    for (producer of producers)
      next.push(addTool(candidate, producer));
  }
  beam = rankByDeficitCount(next).take(B);
}

// Structural support is prospective, not runtime evidence.
// During forward execution, require actual values/effects.
for (tool of executableOrder(chosen.tools, known)) {
  assert(allInputsActuallyBound(tool));
  result = invoke(tool);
  known.addAll(validatedBindingsAndEffects(result));
}
verifyGoalAgainstObservedEvidence();

Backward search treats selected producer outputs as potential support. Forward execution must obtain actual values. Confusing these two meanings is a direct route to hallucinated arguments.

Worked deficit trace

Selected toolsMissing requirementsWhy
send_remindersession, phone, request_idOnly credentials and name are initially known
+ lookup_contactsession, request_idPhone is supported; the contact tool also produces email
+ lookup_paymentsessionRequest ID is supported; payment lookup’s email is covered by contact output
+ loginnoneLogin supplies session from known credentials

One valid pedagogical expansion trace; a beam search may add these producers in a different order. Execution still needs the forward dependency order.

5. What the experiments actually establish

Benchmark and metrics

AppWorld contains stateful simulated consumer applications such as email, payments, shopping, music, phone, and file management. Unit tests check requested changes, unintended modifications, and final answers where applicable. This is more demanding than checking whether an API name was selected correctly.

There are 250 scenarios with three task variants each: 750 tasks. The splits are 105 training tasks, 60 development tasks, 168 normal-test tasks across 56 scenarios, and 417 challenge-test tasks across 139 scenarios. Challenge tasks require longer, more complex interactions and may involve applications unseen during training.

Same-backbone scaffold comparisons: Table 1

The following values reproduce the paper’s Table 1. All values are percentages.

BackboneScaffoldNormal TGCNormal SGCChallenge TGCChallenge SGC
GPT-4oReAct48.832.130.213.0
GPT-4oPlanExec44.623.219.77.9
GPT-4oFullCodeRefl33.926.819.212.2
GPT-4oHyperAgent63.152.635.718.9
GPT-4-TurboReAct26.812.517.55.8
GPT-4-TurboHyperAgent45.328.623.110.1
Llama-3-70B-InstructReAct20.88.93.40.0
Llama-3-70B-InstructHyperAgent30.119.78.96.4

The GPT-4-Turbo and Llama rows above are a subset of Table 1; GPT-4o includes all four reported scaffolds.

For GPT-4o, HyperAgent improves normal-test TGC over ReAct by 14.3 percentage points and challenge TGC by 5.5 points. Normal SGC rises by 20.5 points. These are differences in percentage points, not relative percentage improvements.

The direction is consistent across the three backbones, but the absolute challenge success rates remain modest. Llama’s challenge TGC reaches only 8.9%; explicit dependencies do not erase the effect of model capability or task difficulty.

Across optimization methods: Table 2

A second comparison includes supervised training, preference optimization, reinforcement learning, and non-fine-tuned scaffolds. Selected rows are shown below, separately from Table 1.

MethodNormal TGCNormal SGCChallenge TGCChallenge SGC
EI (iterated successful-rollout training)58.336.832.817.6
DMPO59.036.636.313.7
GRPO58.036.839.522.4
LOOP (token)71.353.645.726.6
Traj (SetBSR + Snippet)65.853.638.724.8
HyperAgent67.155.940.226.1

Table 2 supports the claim that HyperAgent is competitive with trained agents and leads the listed non-fine-tuned methods. It does not show universal superiority: LOOP (token) has higher TGC on both tests and higher challenge SGC.

A reporting inconsistency matters. Table 1 lists GPT-4o HyperAgent at 63.1 / 52.6 / 35.7 / 18.9, whereas Table 2 lists HyperAgent at 67.1 / 55.9 / 40.2 / 26.1. Table 2 also labels a PlanExec row with the former set of values, unlike Table 1’s PlanExec results. The main text does not reconcile this. Keep the tables distinct rather than silently treating one as a corrected version of the other.

There is another comparison limitation: trained SFT/DPO/RL baselines use Qwen-2.5-32B, while non-fine-tuned methods use GPT-4o. Cross-paradigm comparisons mix backbone capability with optimization strategy. Same-backbone scaffold comparisons are cleaner evidence for the framework’s contribution.

Efficiency, ablations, and retrieval checks

Cost comparison

The authors report fewer API calls, LLM interaction turns, and total tokens than ReAct on both test sets. Their rollout discussion attributes this to less documentation exploration and fewer retries.

This supports an online-execution efficiency claim; it does not by itself establish total ownership cost including graph construction and expert review.

Two component ablations

Removing graph context from DAG planning/refinement reduces performance. Replacing support subgraphs with semantically retrieved top-K tools also reduces performance. Both variants use more tokens and API calls.

This is evidence that the high-level context and state-conditioned tool-level support each matter.

Search-budget sensitivity

Increasing context hops from 1 to 2 and support top-K from 1 to 3 improves TGC and SGC. Further expansion gives little improvement while substantially increasing tokens.

More context is not automatically better context.

Two more focused evaluations

Under a common budget of 20 tools, context retrieval better preserves gold tool sets than semantic retrieval and In-N-Out retrieval.

On frozen subgoals with manually annotated completion contracts, support graphs increase subgoal completion while reducing LLM calls compared with ReAct plus semantic top-K retrieval.

The cost, ablation, sensitivity, retrieval, and subgoal results are reported primarily in Figures 2–6. Their exact plotted values were not exposed in the readable text, so this report gives the stated trends rather than inventing percentages or digitizing unavailable values. The paper refers to appendix implementation details and prompts; those appendix contents were not present in the full readable document returned for this report.

6. Where the idea can fail

The paper does not provide a dedicated limitations section in the readable text. The following are engineering implications of its method and evaluation, not additional measured findings.

  1. The graph is a maintained asset. It relies on expert-validated API dependencies and GPT-4o-assisted condition/effect enrichment. New APIs, changed schemas, and revised preconditions require updates. Incorrect or missing links can mislead both planning levels.
  2. Schema compatibility is weaker than value validity. An email is not necessarily the correct roommate’s email. A session can expire. A request ID may refer to a settled payment or the wrong user. Runtime binding validation and goal verification remain necessary.
  3. Empty deficits do not imply a safe, valid execution. Structural support must still be schedulable and grounded. Permission rules, resource availability, state changes, and business constraints can invalidate a plan. Circular producer dependencies need special handling.
  4. Beam search is heuristic. Fewest missing inputs is not necessarily fewest API calls, lowest latency, lowest risk, or the best success probability. A narrow beam or small retrieval budget can discard a useful path.
  5. Effects may invalidate old facts. The description emphasizes accumulated bindings and achieved effects. Production systems also need freshness, scope, and invalidation logic—for example, logging out invalidates session-dependent readiness.
  6. The evidence is benchmark-specific. AppWorld is stateful and unit-tested, but simulated. The study does not establish reliability under live-service outages, changing authorization policies, or real transaction risk. Reported tables do not include uncertainty intervals.

A useful way to remember the contribution

HyperAgent externalizes dependency reasoning that a language model would otherwise perform implicitly. It asks the LLM to interpret, decompose, and adapt, while deterministic machinery exposes which input requirements are missing and which tools might supply them.

One closing connection to context platforms: The reusable lesson is to store not just tool descriptions, but explicit input/output/effect relationships and evidence-backed runtime bindings; this lets a context graph supply operational prerequisites rather than merely similar text.