Active Inference as Context Acquisition for AI Agents
{"primary":"cs.AI","secondary":["cs.CL","cs.LG"]}local graph
Active Inference as Context Acquisition for AI Agents
Section titled “Active Inference as Context Acquisition for AI Agents”Authors: Sanchayan Dutta, Sai Niranjan Ramachandran, Suvrit Sra
arxiv: 2608.19202
Converted to markdown on 2026-10-13 from the arXiv HTML (LaTeXML) rendering; figures embedded from the same source.
Abstract
Section titled “Abstract”Interactive AI agents must acquire the right context as efficiently as possible. When a user omits a constraint, preference, file, or task variable, an agent can proceed with a default assumption or spend tokens on a clarifying question, retrieval call, tool call, or prompt trial. We formulate this tradeoff as active inference for context acquisition. An inner inference step updates beliefs over a latent task state, and an outer decision selects the next context action, task action, or stop action to minimize expected free energy under cost. In deterministic settings, the epistemic term reduces to expected information gain, optionally normalized by token cost. We instantiate the framework in Optimal Question Asking (OQA), with exact posteriors and a dynamic programming oracle, and benchmark frontier language models on binary and multiway categorical tasks from 25 to 300 candidates. We also study clarification before generation and automated prompt optimization under token budgets. The formulation is model-agnostic and views active inference as a design principle for the context-acquisition layer of AI agents.
1 Introduction
Section titled “1 Introduction”Users of AI systems rarely specify everything up front. A constraint may be omitted or a preference left implicit. Faced with such inputs, the system can commit early and risk being wrong, or it can acquire more context first. The context action might be a clarifying question, retrieval call, tool call, prompt evaluation, or visual inspection. Each such action has a price. It costs tokens, adds latency, and can require effort from a user or environment.
We study this tradeoff using active inference. Let be the latent task state, such as intent, target, preference, missing constraint, or best prompt. Let be either a context action or a task action, and let be the resulting reply, trace, or observation, modeled by . For each candidate action, an inner inference step updates beliefs over under possible observations. An outer step then chooses the action that minimizes expected free energy, including risk, epistemic value, and cost. Under exact inference and deterministic observations, the epistemic term is expected information gain. The rule is simple. Acquire more context only when the expected reduction in relevant uncertainty justifies its cost.
To make uncertainty measurable, we instantiate the idea in Optimal Question Asking (OQA). OQA turns question asking into a controlled Twenty Questions game (Jedynak et al., 2012) over a finite attribute table. A hidden target is sampled uniformly. The agent asks about one listed attribute per turn. Answers are obtained by table lookup, either yes/no for binary tables or categorical values for -ary tables. Each transcript induces a remaining consistent set , or an equivalence class when several items share the same attribute vector. With noiseless answers, the posterior is uniform over , so uncertainty is exact and entropy is . We also compute the optimal expected number of questions under the same allowed queries using dynamic programming. This gives a direct planning gap against an oracle.
We then test the same accounting view in two token-budgeted prompting workflows. In prompt autocompletion, the model may spend a few clarification turns before writing a final description. In automated prompt optimization, the model allocates a fixed evaluation budget across prompt variants and uses outcomes to infer which prompt is best. In both cases, tokens buy evidence about a hidden choice that matters for the final decision.
This framing is close to reinforcement learning and control-as-inference (Levine, 2018; Millidge et al., 2020). We do not treat active inference as a rival to RL. The distinction is operational. In context-acquisition settings, the agent can choose the next measurement and thereby shape the evidence stream before acting. Expected free energy gives a compact language for that choice.
1.1 Main Contributions
Section titled “1.1 Main Contributions”-
•
Context acquisition as active inference. We cast questions, retrievals, tool calls, prompt trials, and inspections as actions whose purpose is to improve beliefs before a task action.
-
•
A bilevel one-step formulation. We separate the inner belief update under a hypothetical observation from the outer choice of the next context action, task action, or stop action that minimizes expected free energy under cost.
-
•
OQA, a benchmark with exact uncertainty. We introduce Optimal Question Asking (OQA), a deterministic attribute-table benchmark in which a model identifies a hidden target by asking informative questions.
-
•
Oracle baselines and stopping rules. For a fixed table, we compute an optimal questioning strategy using dynamic programming, and state value-of-information conditions for when context acquisition is worth its cost.
-
•
Two prompting case studies with token budgets. We apply the same accounting view to clarification before generation and automated prompt optimization, reading token spending as active experiment selection.
We validate these ideas empirically in OQA on seven frontier models11 1 Models: GPT-5, GPT-4.1, Gemini 2.5 Pro, Gemini 2.0 Flash, Claude Sonnet 4.5, Claude Haiku 4.5, and Grok 4. via API, and in both prompting studies.
In the appendix, we include a discussion of how the bilevel view of one-step active inference can be used to mathematically model adaptive prompt attacks and possible defenses. We also discuss the structural similarities and differences between active inference and bilevel reinforcement learning.
2 Related Work
Section titled “2 Related Work”Active inference (Friston et al., 2017; Parr and Friston, 2019) extends classical inference by incorporating ideas from control theory. The core idea is to select actions that maximize information gain through explicit decomposition of preference and epistemic uncertainty over hidden states. This information-theoretic perspective connects to a rich literature on optimal querying and exploration.
Expected information gain is fundamental in Bayesian experimental design (Lindley, 1956; Chaloner and Verdinelli, 1995; Rainforth et al., 2024) and drives action selection in active learning and Bayesian optimization through analogous mutual information objectives (Houlsby et al., 2011; Hennig and Schuler, 2012). Similarly, information-directed sampling in bandits balances regret against information acquisition (Russo and Van Roy, 2014). A closely related line of work establishes stopping rules for interactions as a function of query cost (Haertel et al., 2008; Bloodgood and Vijay-Shanker, 2009).
LLM information seeking and clarification.
Section titled “LLM information seeking and clarification.”Recent work has begun to treat LLMs as active information seekers rather than passive respondents. UoT uses uncertainty-aware simulation and information-gain-motivated rewards to select follow-up questions (Hu et al., 2024). Active preference inference uses probabilistic models induced by LLM prompts to ask informative preference questions (Piriyakulkij et al., 2023). CLAMBER evaluates whether models detect and clarify ambiguous information needs (Zhang et al., 2024), while Ask-when-Needed studies tool-use failures under unclear instructions (Wang et al., 2024). Active Task Disambiguation and BED-LLM both frame clarification as Bayesian experimental design for LLM agents (Kobalczyk et al., 2025; Choudhury et al., 2025). Complementary work on termination, such as CaRT, studies when an agent has gathered enough information to stop and act (Liu et al., 2025). Our work connects these directions to the active-inference expected-free-energy decomposition and adds exact oracle diagnostics through OQA.
Our setting, optimal question asking (OQA), instantiates these ideas in a Twenty Questions framework. Here, successive queries partition a hypothesis set until one target remains (Jedynak et al., 2012). Generalized binary search provides optimal splitting strategies under deterministic answers (Nowak, 2011), with extensions handling noisy responses and group identification (Nowak, 2009; Bellala et al., 2010). Algorithmically, our approach mirrors the bilevel optimization structure of meta-learning: an inner loop updates beliefs given an answer, while an outer loop selects which question maximizes expected utility (Colson et al., 2007; Franceschi et al., 2018). This parallels intrinsic motivation in RL, where information gain drives exploration (Houthooft et al., 2016; Pathak et al., 2017), and prompt optimization methods that search over discrete or continuous prompt spaces (Shin et al., 2020; Zhou et al., 2023). Active inference agents have been deployed in similar settings, from OpenAI Gym environments (Cullen et al., 2018) to cognitive models of visual search (Cullen et al., 2020).
Active inference and reinforcement learning.
Section titled “Active inference and reinforcement learning.”A sharp separation between active inference and RL would be misleading. Control-as-inference shows how RL objectives can be represented as probabilistic inference problems (Levine, 2018), and Millidge and coauthors show that active inference and control-as-inference differ mainly in how rewards, goals, or preferences are encoded in the graphical model (Millidge et al., 2020; Millidge, 2021). Millidge’s retrospective makes the same point in plain language, while also emphasizing that the expected-free-energy objective foregrounds information gain and exploration (Millidge, 2024; Millidge et al., 2021). Our contribution is therefore not the claim that active inference is categorically different from RL. It is the claim that the active-inference decomposition gives a compact design language for LLM systems that can choose what evidence to buy before acting.
Table 1: Operational distinction used in this paper. The contrast is not categorical: RL can include information bonuses, and active inference can use RL solvers.
| Aspect | Generic RL view | Active-inference view used here |
|---|---|---|
| Control | Optimize actions for return under the sampled or observed data stream. | Choose actions that also determine what evidence arrives next. |
| Exploration | Usually added through bonuses, entropy, optimism, or posterior sampling. | Appears directly as epistemic value in expected free energy. |
| Belief and queries | Beliefs may be implicit in a value function, recurrent state, or model posterior. | An explicit posterior over intent, target, or best prompt makes queries first-class actions. |
| Evaluation | Return, regret, accuracy, or reward-model score. | Entropy drop, oracle gap, bits per token, and final task success. |
3 One-Step Active Inference as Bilevel Optimization
Section titled “3 One-Step Active Inference as Bilevel Optimization”In single step active inference we separate belief update from action selection. Let be a latent state, let be an action, and let be the next observation. Given a likelihood and a current belief , define the predictive distribution
| (1) | ||||
| --- | --- | --- | --- | --- |
| (2) |
assuming for the relevant . In discrete settings, we can replace integrals with sums. Unless stated otherwise, denotes the natural logarithm, so KL and mutual information are in nats; OQA reports entropy in bits.
Fix and let be a candidate posterior. We define the variational free energy
| (3) | ||||
| --- | --- | --- | --- | --- |
| (4) |
The inner update is
| (5) |
If contains , then . In the proof of concept experiments, contains the exact posterior, so the inner update is closed form.
Preferences over observations are represented by a distribution . A standard one step expected free energy includes a term that penalizes ambiguity in the observation model through . In the deterministic answer settings used in OQA, this ambiguity term is zero, and the action score can be written as
| (6) | ||||
With an exact inner update, the second term is an information gain term, as made explicit below.
Proposition 3.1 (Mutual-information form and deterministic special case).
Section titled “Proposition 3.1 (Mutual-information form and deterministic special case).”Assume the inner solution is exact, , with predictive from (1). Then
| (7) |
the mutual information under the joint . If is constant, the risk term in (6) is independent of , so
| (8) |
Moreover,
| (9) |
If for -a.e. , for example in discrete deterministic observation models, then .
Proof.
Section titled “Proof.”By definition under the joint ,
Substituting gives (7). If is constant, does not depend on , which yields (8). The identity (9) is the standard entropy decomposition of mutual information. ∎
The dependence of (6) on the optimizer in (5) yields the bilevel program:
| (10) |
The outer expectation in is taken over .
Proposition 3.2 (Differentiability of the bilevel objective).
Section titled “Proposition 3.2 (Differentiability of the bilevel objective).”Let and write . Define
| (11) | ||||
for a differentiable outer integrand . Suppose that for relevant the minimizer is isolated, that is twice continuously differentiable in , and that . Then is locally differentiable in . If, in addition, and satisfy standard conditions for differentiating under the expectation, then is differentiable. Gradients can be computed by implicit differentiation or by unrolling an inner solver. For discrete , (6) can be evaluated by enumeration, or by a differentiable relaxation.
Proof sketch.
Section titled “Proof sketch.”At an isolated minimizer, . If , the Jacobian with respect to is invertible, so the implicit function theorem yields local differentiability of in and the standard implicit gradient expression. ∎
Proposition 3.3 (Information-per-cost stopping rule).
Section titled “Proposition 3.3 (Information-per-cost stopping rule).”Suppose the inner update is exact, preferences are constant over the possible observations of each information-gathering action, and taking no further measurement has score . Let action have expected cost , and let the one-step objective be expected posterior entropy plus a cost penalty , with . Then an information-gathering action is worthwhile exactly when
| (12) |
Among worthwhile actions, the optimal one maximizes . Equivalently, if a fixed cost budget is spent greedily in small units, the myopic selector ranks actions by information gained per unit cost.
Proof.
Section titled “Proof.”For a fixed current belief, is independent of the next action. Exact Bayes gives
Adding the cost penalty yields the one-step score . Subtracting the no-measurement score gives . Thus asking is beneficial precisely when (12) holds, and the maximizing rule follows by dropping the action-independent entropy term. ∎
Theorem 3.4 (Bayes-risk value of context).
Section titled “Theorem 3.4 (Bayes-risk value of context).”Let be a set of terminal decisions and let be a finite loss. For a belief over , define the Bayes risk
| (13) |
Consider a context-acquisition action with cost , predictive distribution , and exact posterior after observing . Suppose the agent may either act immediately, incurring risk , or take one context action and then act optimally under the resulting posterior, incurring expected score
| (14) |
Then is strictly preferred to acting now exactly when
| (15) |
If the terminal loss is logarithmic and the terminal decision is a predictive distribution, then and the left side of (15) is .
Proof.
Section titled “Proof.”Acting immediately gives the optimal terminal risk by definition. Taking first gives an observation-dependent posterior and then the optimal terminal risk for that posterior, plus the cost penalty. Comparing the two scores yields (15). For logarithmic loss, the Bayes-optimal predictive distribution is the belief itself and the Bayes risk is entropy. The expected entropy reduction identity gives
which proves the final claim. ∎
4 Active Inference as Context Acquisition
Section titled “4 Active Inference as Context Acquisition”The preceding objective can be read as an inference-time control layer for AI agents. The agent maintains a belief over latent task state, then chooses among context actions, task actions, and stopping. A context action is any move that primarily changes the information available to the agent: asking the user, retrieving a passage, calling a tool to fill a missing field, evaluating a prompt variant, or inspecting part of an input. A task action is the move that commits to the requested output.
This view separates three roles that are often mixed in prompting practice. The belief state stores what the agent currently thinks is true about the task. The measurement model says what each context action could reveal. The preference or loss model says which terminal outcomes matter. Expected free energy then scores a candidate context action by how much it is expected to reduce decision-relevant uncertainty, not merely by whether it seems like a reasonable question.
OQA instantiates this loop with a finite candidate set, deterministic measurements, and exact posteriors. Prompt autocompletion instantiates it with a latent style variable and fixed clarification templates. Prompt optimization instantiates it with a latent best-prompt identity and automatically scored trials. These are deliberately restricted cases, but the abstraction is broader: an AI agent can treat every token, query, tool call, or inspection as an experiment that competes against acting now.
The framework also clarifies what OQA does not claim. In deterministic OQA with flat observation preferences, one-step expected free energy reduces to greedy expected information gain. Greedy information gain is a useful local rule, but it is not the same as the globally optimal policy over a full dialogue. The dynamic programming oracle therefore plays a conceptual role beyond benchmarking: it measures the cost of myopic context acquisition.
5 Binary OQA Experiments: 25 and 100 Candidates
Section titled “5 Binary OQA Experiments: 25 and 100 Candidates”


Figure 1: Binary OQA with N = 25 N=25 . Curves show mean entropy H t = log 2 | C t | H_{t}=\log_{2}|C_{t}| across uniformly sampled targets, with ± 1 \pm 1 standard deviation, along with the DP oracle.



Figure 2: Binary OQA with N = 100 N=100 . Curves show mean entropy H t = log 2 | C t | H_{t}=\log_{2}|C_{t}| across uniformly sampled targets, with ± 1 \pm 1 standard deviation, along with the DP oracle. In Animals, duplicate attribute vectors can force stopping with a small residual entropy.
Binary OQA starts with a set of items. Each item has a fixed yes or no value for each of the same attribute names, which can be viewed as its attribute vector. For example, in an animals table the item “cat” might have values like “mammal = yes,” “has_fur = yes,” and “can_swim = no.” One item is chosen uniformly at random as the hidden target, and the candidate set starts at . Each turn asks for one attribute value and removes all items that disagree with the replies so far, leaving the updated candidate set . With a uniform prior and noiseless answers, the belief is uniform on . The uncertainty is and per question progress is . A run ends when , or earlier when no attribute can split . The latter happens when the remaining items share the same full attribute vector, so some runs can end with .
Let be the model’s count and the DP oracle’s count under the same attribute menu and stopping rule. We define the metric “planning gap” as the average number of extra questions the model uses compared to the oracle, A simple baseline is a greedy strategy that picks the attribute with the largest expected reduction in uncertainty. For a candidate set and a yes or no attribute , asking splits into and . Near-balanced splits tend to be most informative. In this deterministic setting, the expected entropy reduction equals mutual information up to the log base, but it is optimal only for the next step and can be suboptimal over multiple steps.
Our DP oracle is optimal in the sense that it minimizes the expected number of questions until stopping. Let be the optimal expected number of additional questions when the remaining candidate set is , assuming the hidden target is uniform on . If an attribute splits into and , then asking costs one question plus the expected remaining cost weighted by branch sizes, giving
| $$\min_{j:\ C^{\text{yes}},C^{\text{no}}\neq\emptyset}\left(1+\frac{ | C^{\text{yes}} | }{ |
with when or when no attribute can split .
Theorem 5.1 (Optimality of the deterministic OQA oracle).
Section titled “Theorem 5.1 (Optimality of the deterministic OQA oracle).”Consider any finite deterministic OQA game with candidate set , a uniform target within , a finite menu of allowed queries, and unit query cost. Each query partitions into nonempty cells , and terminal sets are those with one candidate or no query that can split them. Let
| $$V(C)=\begin{cases}0,&C\text{ terminal},\[5.69054pt] \displaystyle\min_{a}\left(1+\sum_{o\in\mathcal{O}_{a}}\frac{ | C_{o}(a) | }{ |
where the minimum ranges over queries that split . Then is the minimum expected number of additional queries over all allowed adaptive decision trees. Any policy that attains the minimum in (17) at every reachable set is optimal.
Proof.
Section titled “Proof.”The proof is by induction on . Terminal sets have value zero by definition. For nonterminal , any valid decision tree must choose some first query , pay one unit of cost, and then continue independently inside the cell selected by the truthful answer. Since the target is uniform on , that cell occurs with probability . By the induction hypothesis, the best possible continuation cost in each branch is . Thus every decision tree has expected cost at least the right side of (17). Choosing a minimizing query and then using optimal subtrees for all child cells attains this bound, so the recurrence is both necessary and sufficient. ∎
We compute with caching, since the same candidate set can arise from different question sequences. To plot an oracle trace for a fixed target , start from . At turn , choose an attribute that minimizes (16), filter to obtain , and record . We run this on Places, Cars, and Animals with , using one API call per question with temperature=0, fresh sessions per target, and no external tools. Figures 1 and 2 show mean entropy trajectories over uniformly sampled targets, with standard deviation, alongside the DP oracle.
Summary and takeaways. We evaluate frontier LLMs on 25- and 100-tier binary OQA datasets, tracking posterior entropy exactly and comparing each model to a dynamic programming (DP) oracle under the same attribute menu and stopping rule. However, even in a clean setting where uncertainty can be measured exactly, models leave efficiency on the table. They do make steady progress, but they still ask avoidable questions compared to an optimal strategy.
6 Multiway Categorical OQA Experiments: 100, 200, and 300 Candidates
Section titled “6 Multiway Categorical OQA Experiments: 100, 200, and 300 Candidates”Similar to binary OQA, multiway categorical OQA starts with a set of items. Each item has a fixed categorical value for each of the same attribute names, which can be viewed as its attribute vector. For example, an item might have values like color = red, shape = hexagon, and material = steel. One item is chosen uniformly at random as the hidden target, and the candidate set starts at . Each turn asks for the value of one attribute and removes all items that disagree with the replies so far, leaving the updated candidate set . With a uniform prior and deterministic answers, the belief is uniform on . As before, the uncertainty is and per question progress is . A run ends when , or earlier when no attribute can split .
Formally, let be the finite attribute set, and for each let map items to a finite value set. At turn the agent chooses , observes the truthful reply , and filters by consistency, . We call a tier -ary, where . In our released tiers, . We keep the early stopping rule above for completeness, although in the released tiers the attribute vectors are unique, so runs end with . As in the binary setting, we summarize planning by questions to stop. Let be the model’s count and the DP oracle’s count under the same attribute menu and stopping rule. The planning gap is .
A simple baseline is a greedy strategy that picks the attribute with the largest expected reduction in uncertainty. Fix a candidate set and an attribute . For each value , define . Under the uniform belief on , , and the expected entropy reduction from asking is
Near-balanced partitions tend to be most informative. In this deterministic setting, matches mutual information up to the log base (Prop. 3.1), but it is optimal only for the next step and can be suboptimal over multiple steps.
The DP oracle is optimal under our rules, in the sense that it minimizes the expected number of questions until stopping. Let be the optimal expected number of additional questions when the remaining candidate set is , assuming the hidden target is uniform on . For an attribute , let . If , then does not split and is ignored. Otherwise,
| $$\min_{a\in\mathcal{A}:, | B_{a}(C) | \geq 2}\left(1+\sum_{v\in\mathcal{V}_{a}:, |
with when or when no attribute can split . We compute with caching using a canonical representation of , such as a sorted tuple of item IDs. To plot an oracle trace for a fixed target , start from . At turn , choose an attribute that minimizes (18), apply using the target’s true value, and record until stopping.
We use three tiers with . All tiers share the same eight attributes, namely color, shape, material, size, pattern, origin, use_case, and energy. Each query must request the value of exactly one named attribute, and the evaluator answers by table lookup.
We evaluate targets per tier with tool use disabled, using one API call per question with temperature=0 in a fresh session per target. Mean entropy trajectories are plotted with standard deviation alongside the DP oracle in Figure 3.
Summary and takeaways.
Section titled “Summary and takeaways.”We extend OQA to multiway categorical attributes using deterministic table lookups, with 100, 200, and 300 tiers and a fixed menu of eight attributes. We again track posterior entropy and measure efficiency by planning gap. Frontier models consistently shrink the consistent set over turns, and yet they remain less question-efficient than the dynamic programming (DP) oracle.



Figure 3: Multiway categorical OQA for | 𝒳 | ∈ { 100,200,300 } |\mathcal{X}|\in{100,200,300} (top to bottom). Curves show mean posterior entropy over uniformly sampled targets. The DP oracle uses the same query menu and stopping rule. Error bars show ± 1 \pm 1 standard deviation when available.
7 Prompt Autocompletion as Active Inference
Section titled “7 Prompt Autocompletion as Active Inference”This is our first prompt experiment. Suppose a user asks for a product description but does not specify a style. Each task provides a product name and three feature phrases. We model the desired style as a hidden variable . The tone is either formal or friendly, length is either short or medium, and format is either bullet points or a paragraph. We sample these three style choices independently and uniformly. The agent may ask up to three clarifying questions before writing one final description. In this experiment, the questions use fixed templates, and we simulate the answers from the hidden . This keeps the focus on the agent’s choice of what to ask, rather than how the questions are phrased. Each question targets exactly one component of , and we never ask about the same component twice.
We assume that the answers are always truthful, and we add uncertainty only when updating the agent’s belief about , using a symmetric label noise model, so the posterior does not become overly confident. We also charge a synthetic token cost for each clarification. The first costs tokens, then , then . After any clarifications, we call the base model once and request a description using the MAP style . We further assume that the agent’s belief over styles factorizes across the three attributes, so , and we start from a uniform prior. When the agent asks about one attribute (tone, length, or format), it updates only . We model mistakes in this update with a fixed error rate . The information gained from that question is , measured in bits.
After the agent produces the final description, a deterministic verifier checks it. The verifier requires each feature phrase to appear as an exact substring, and it checks format and word count. A short description has at most 70 words, while a medium description has 70 to 160 words. Tone is not checked, so the sampled style and the verifier reward do not perfectly match. We compare five question asking policies. baseline asks no questions and uses the default style. ask_all asks about tone, length, and format. random samples uniformly from , then asks distinct attributes in random order. active chooses the unasked attribute with the largest entropy per expected token cost, , and stops when this score falls below . active_weighted uses the same rule, but weights the entropy term by , with , , and .
In Figure 4, we fix and on 48 tasks to show the cost accuracy trade-off across policies. We then tune active_weighted via grid search over and , maximizing J(\epsilon,K\_{\max})=\mathbb{E}[\mathrm{ok}]-0.02\,\mathbb{E}[\text{tokens\\_total}]/1000, where tokens_total is the model-reported tokens for the final generation plus the synthetic clarification costs. We score on 24 training tasks and evaluate on 24 held out tasks. The best setting is and , reaching compliance at about tokens per task (vs. baseline at compliance and about tokens).
Summary and takeaways. We study how to spend a limited token budget between clarifying turns and a final completion when the style is hidden, answers to fixed clarification templates are truthful, and when success is measured by a deterministic verifier. Policies that ask targeted clarifications improve verifier pass rates relative to asking none, showing that paying for a small number of well chosen questions can be worthwhile, but only when those questions buy information the final output will actually be judged on.



(a) Clarifications used
8 Automated Prompt Optimization
Section titled “8 Automated Prompt Optimization”In this second prompt experiment, the model never asks the user follow-up questions, but rather treats the choice of system prompt as an online decision problem under a fixed token budget, aiming to quickly identify which prompt variant yields the most reliable multiple-choice answers. We fix a small library of candidate system prompts: , , , , , and . At training step we select a prompt , format one ARC-Challenge question Clark et al. (2018) using a fixed user-message template, and query the base model once with temperature=0 so the output is deterministic given the prompt. From the response we extract the first standalone letter in , score it as correct or incorrect to obtain , and record the token cost .
Each prompt is modeled as a Bernoulli arm with unknown accuracy , and we maintain independent Beta posteriors initialized at . After observing for the chosen prompt , we update only that prompt via and , and report the posterior mean .
To summarize uncertainty about which prompt is truly best, we define and estimate the induced distribution over by Monte Carlo sampling, where we draw one from each Beta factor and take the maximizing prompt for each draw. From this empirical distribution we compute an entropy in bits, and after each training step we log the realized entropy drop along with an information-efficiency measure which can be read as the entropy reduction achieved per thousand tokens spent on that step.
Prompt selection is handled by an outer-loop policy that chooses each step. Round robin cycles through prompts, Thompson sampling draws from each posterior and picks the largest, KG chooses the prompt with the highest expected one-step gain in the current best posterior-mean accuracy, MI chooses the prompt with the largest expected reduction in , and EFE blends MI and KG with a linearly decaying epistemic weight to shift from exploration to exploitation. Since prompts can differ in response length, MI, KG, and EFE normalize their scores by a per-prompt token-cost estimate tracked with an exponential moving average of . Training stops at 400 questions or tokens. In Figure 5 the 400-question cap binds (about tokens), after which we select the prompt with the highest posterior mean and evaluate it on a shared validation subset. KG tends to concentrate queries early, leaving rarely tested prompts near the 0.5 prior mean, while MI and EFE are often most informative early and Thompson sampling and round robin spread learning more evenly.



(a) Posterior mean accuracies
Summary and takeaways. We treat system-prompt choice as an online decision problem under a fixed token budget, using repeated, automatically scored trials to update which prompt variant looks best. The main lesson is to use early trials to reduce uncertainty rather than commit too soon, then choose the variant with the strongest track record under the same scoring rule used throughout training.
9 Limitations and Discussion
Section titled “9 Limitations and Discussion”This paper intentionally studies restricted forms of context acquisition. In OQA, the AI assistant must identify a hidden item by asking about entries in a fixed attribute table. We test both yes–no tables and tables where answers take a small set of named values (Sections 5 and 6). The advantage is precision: after each question, we can say exactly how many items remain valid, and we can compare the model to a best-possible strategy under the same rules. The cost is realism. Real conversations may include vague replies, new constraints, contradictory preferences, missing files, and evidence that does not fit a prewritten attribute list. A stricter future benchmark would allow free-form questions and ground answers in richer inputs, including images and compositional attributes, for example, CLEVR-style scenes (Johnson et al., 2017).
The current experiments cover three real attribute tables (Places, Cars, Animals), larger synthetic multiway attribute tables up to 300 items, and two token-budget studies on how to spend limited tokens (Sections 7 and 8). This is enough to test the central accounting principle, but not enough to claim a complete agent benchmark. We leave out temporal reasoning, multimodal perception, robotics, open-ended tool-use, and multi-user collaboration, all of which make context acquisition harder (Mirza et al., 2016; Lanillos et al., 2021).
We also turn off tools on purpose. We disable retrieval, function calls, and scratchpads so we can measure what the model can do on its own (Lewis et al., 2020; Schick et al., 2023; Nye et al., 2022). In real products, tools do a lot of the heavy lifting. They can store the candidate list, filter it exactly, keep memory across turns, and call external systems. A tool-enabled version of the benchmark would test whether the agent asks for the right missing information before invoking a tool, instead of hallucinating missing arguments or making premature calls.
There is also a scaling issue with the oracle we use for comparison. Our dynamic program gives the best strategy under our rules, but as the number of items grows, the number of different remaining sets that can appear may explode. It is manageable for the tiers we release, but it will not stay manageable forever. For larger tasks, approximate baselines based on sampling, search, or learned lookahead will be needed (Kirsch et al., 2019; Schrittwieser et al., 2020). More broadly, a locally good question is not always part of the best overall plan. This is why we report a DP oracle where possible rather than treating greedy information gain as the final answer.
The two token-budget studies are controlled demonstrations, not full replicas of real workflows. In prompt autocompletion (Section 7), the assistant chooses among fixed clarifications, and answers are simulated from a hidden style choice. This isolates whether the assistant asks about the right variables, but it does not test natural phrasing, unclear answers, user impatience, or changing preferences. In automated prompt optimization (Section 8), we pick from a small handwritten set of prompt variants and test them on a multiple-choice benchmark. This is clean and automatically scored, but real prompt libraries are larger, correlated, task-dependent, and often judged by softer preferences. Token costs can also change across deployments. Since we evaluate frontier models through hosted APIs, model updates can affect reproducibility.
Finally, efficient context acquisition is dual use. The same machinery that helps an assistant ask fewer and better questions can help a malicious actor collect sensitive details, profile users, or probe hidden system rules. We discuss these connections in the appendix, but we do not test attacks or defenses. Deployment should pair information-gain objectives with limits on sensitive follow-ups, rate limits, audit trails, consent for personal data collection, and privacy-aware safeguards (Huang et al., 2024; Charles et al., 2024; Freiberger et al., 2025).
10 Conclusion and Future Work
Section titled “10 Conclusion and Future Work”We presented active inference as a context-acquisition layer for AI agents. The central decision is whether to act with the current context or spend tokens, interaction, or computation to acquire more evidence. The bilevel formulation separates the posterior update caused by a hypothetical observation from the outer decision that chooses the next context action or task action. OQA makes this decision measurable through exact posteriors and a dynamic programming oracle. Across tiers, frontier models reduce uncertainty each turn but still ask more questions than the oracle. The two token-budget studies show the same principle in prompting: a small amount of targeted clarification or prompt experimentation can improve final success when it buys decision-relevant information.
Future work should move beyond fixed tables to noisy, open-ended, and multimodal interaction. It should also scale oracle baselines with sampling-based search, evaluate tool-enabled agents with memory, and integrate explicit stopping decisions. A central open direction is to make context acquisition safe by design: the agent should learn what it needs to know, but not overcollect information that is irrelevant, sensitive, or unsafe to request.
Impact Statement
Section titled “Impact Statement”This paper advances machine learning methods for deciding when an interactive system should acquire more context versus act, using active inference, information gain, and controlled oracle diagnostics. Potential benefits include fewer unnecessary questioning turns, lower token and compute cost, better tool-use reliability, and improved task success under ambiguity.
Risks are that more efficient context acquisition can be misused to extract sensitive information, enable profiling, or speed up adversarial probing of system defenses. OQA itself uses synthetic data and simulated answers, so it does not require collecting personal data. In deployment, mitigation includes limiting and auditing follow-ups, obtaining consent for personal data collection, and adding explicit privacy and safety constraints to the objective.
References
Section titled “References”- Bellala et al. (2010) G. Bellala, S. Bhavnani, and C. Scott Extensions of generalized binary search to group identification and exponential costs. In Advances in Neural Information Processing Systems 23, pp. 154–162. Cited by: §2.
- Bloodgood and Vijay-Shanker (2009) M. Bloodgood and K. Vijay-Shanker A method for stopping active learning based on stabilizing predictions and the need for user-adjustable stopping. In Proceedings of the Thirteenth Conference on Computational Natural Language Learning (CoNLL 2009), pp. 39–47. External Links: Link Cited by: §2.
- Chaloner and Verdinelli (1995) K. Chaloner and I. Verdinelli Bayesian experimental design: a review. Statistical Science 10 (3), pp. 273–304. External Links: Document Cited by: §2.
- Charles et al. (2024) Z. Charles, A. Ganesh, R. McKenna, H. B. McMahan, N. Mitchell, K. Pillutla, and K. Rush Fine-tuning large language models with user-level differential privacy. arXiv preprint arXiv:2407.07737. External Links: Document Cited by: §9.
- Choudhury et al. (2025) D. Choudhury, S. Williamson, A. Golinski, N. Miao, F. Bickford Smith, M. Kirchhof, Y. Zhang, and T. Rainforth BED-LLM: intelligent information gathering with LLMs and bayesian experimental design. External Links: 2508.21184, Link Cited by: §2.
- Clark et al. (2018) P. Clark, I. Cowhey, O. Etzioni, T. Khot, A. Sabharwal, C. Schoenick, and O. Tafjord Think you have solved question answering? try arc, the ai2 reasoning challenge. arXiv preprint arXiv:1803.05457. Cited by: §8.
- Colson et al. (2007) B. Colson, P. Marcotte, and G. Savard An overview of bilevel optimization. Annals of Operations Research 153 (1), pp. 235–256. External Links: Document Cited by: §2.
- Cullen et al. (2018) M. Cullen, B. Davey, K. J. Friston, and R. J. Moran Active inference in OpenAI gym: a paradigm for computational investigations into psychiatric illness. Biological Psychiatry: Cognitive Neuroscience and Neuroimaging 3 (9), pp. 809–818. External Links: Document Cited by: §2.
- Cullen et al. (2020) M. Cullen, J. Monney, M. B. Mirza, and R. Moran A meta-bayesian model of intentional visual search. arXiv preprint arXiv:2006.03531. External Links: Link Cited by: §2.
- Franceschi et al. (2018) L. Franceschi, P. Frasconi, S. Salzo, R. Grazzi, and M. Pontil Bilevel programming for hyperparameter optimization and meta-learning. In Proceedings of the 35th International Conference on Machine Learning (ICML), Proceedings of Machine Learning Research, Vol. 80, pp. 1568–1577. External Links: Link Cited by: §2.
- Freiberger et al. (2025) V. Freiberger, A. Fleig, and E. Buchmann “You don’t need a university degree to comprehend data protection this way”: LLM-Powered Interactive Privacy Policy Assessment. In Extended Abstracts of the CHI Conference on Human Factors in Computing Systems (CHI EA ’25), New York, NY, USA. External Links: Document Cited by: §9.
- Friston et al. (2017) K. J. Friston, T. H. FitzGerald, F. Rigoli, P. Schwartenbeck, and G. Pezzulo Active inference: a process theory. Neural Computation 29 (1), pp. 1–49. Cited by: Appendix G, §2.
- Haertel et al. (2008) R. Haertel, E. Ringger, K. Seppi, J. Carroll, and P. McClanahan Assessing the costs of sampling methods in active learning for annotation. In Proceedings of ACL-08: HLT Short Papers, pp. 65–68. External Links: Link Cited by: §2.
- Hennig and Schuler (2012) P. Hennig and C. J. Schuler Entropy search for information-efficient global optimization. Journal of Machine Learning Research 13, pp. 1809–1837. External Links: Link Cited by: §2.
- Houlsby et al. (2011) N. Houlsby, F. Huszár, Z. Ghahramani, and M. Lengyel Bayesian active learning for classification and preference learning. External Links: 1112.5745, Link Cited by: §2.
- Houthooft et al. (2016) R. Houthooft, X. Chen, Y. Duan, J. Schulman, F. De Turck, and P. Abbeel VIME: variational information maximizing exploration. In Advances in Neural Information Processing Systems 29, pp. 1109–1117. External Links: Link Cited by: §2.
- Hu et al. (2024) Z. Hu, C. Liu, X. Feng, Y. Zhao, S. Ng, A. T. Luu, J. He, P. W. Koh, and B. Hooi Uncertainty of thoughts: uncertainty-aware planning enhances information seeking in large language models. External Links: 2402.03271, Link Cited by: §2.
- Huang et al. (2024) K. Huang, B. Chen, Y. Lu, S. Wu, D. Wang, Y. Huang, H. Jiang, Z. Zhou, J. Cao, and X. Peng Lifting the veil on composition, risks, and mitigations of the large language model supply chain. arXiv preprint arXiv:2410.21218. External Links: Document Cited by: §9.
- Jedynak et al. (2012) B. Jedynak, P. I. Frazier, and R. Sznitman Twenty questions with noise: bayes optimal policies for entropy loss. Journal of Applied Probability 49 (1), pp. 114–136. External Links: Document Cited by: §1, §2.
- Johnson et al. (2017) J. Johnson, B. Hariharan, L. van der Maaten, F. Li, C. L. Zitnick, and R. Girshick CLEVR: a diagnostic dataset for compositional language and elementary visual reasoning. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition (CVPR), pp. 1988–1997. External Links: Document Cited by: §9.
- Kirsch et al. (2019) A. Kirsch, J. van Amersfoort, and Y. Gal BatchBALD: efficient and diverse batch acquisition for deep bayesian active learning. In Advances in Neural Information Processing Systems, External Links: Link Cited by: §9.
- Kobalczyk et al. (2025) K. Kobalczyk, N. Astorga, T. Liu, and M. van der Schaar Active task disambiguation with llms. External Links: 2502.04485, Link Cited by: §2.
- Lanillos et al. (2021) P. Lanillos, C. Meo, C. Pezzato, A. A. Meera, M. Baioumy, W. Ohata, A. Tschantz, B. Millidge, M. Wisse, C. L. Buckley, and J. Tani Active inference in robotics and artificial agents: survey and challenges. arXiv preprint arXiv:2112.01871. External Links: Document Cited by: §9.
- Levine (2018) S. Levine Reinforcement learning and control as probabilistic inference: tutorial and review. arXiv preprint arXiv:1805.00909. External Links: 1805.00909, Link Cited by: §1, §2.
- Lewis et al. (2020) P. Lewis, E. Perez, A. Piktus, F. Petroni, V. Karpukhin, N. Goyal, H. Küttler, M. Lewis, W. Yih, T. Rocktäschel, S. Riedel, and D. Kiela Retrieval-augmented generation for knowledge-intensive NLP tasks. In Advances in Neural Information Processing Systems, Vol. 33, pp. 9459–9474. External Links: Document Cited by: §9.
- Lindley (1956) D. V. Lindley On a measure of the information provided by an experiment. The Annals of Mathematical Statistics 27 (4), pp. 986–1005. External Links: Document Cited by: §2.
- Liu et al. (2025) G. Liu, Y. Qu, J. Schneider, A. Singh, and A. Kumar CaRT: teaching LLM agents to know when they know enough. External Links: 2510.08517, Link Cited by: §2.
- Millidge et al. (2021) B. Millidge, A. Seth, and C. L. Buckley Understanding the origin of information-seeking exploration in probabilistic objectives for control. arXiv preprint arXiv:2103.06859. External Links: 2103.06859, Link Cited by: §2.
- Millidge et al. (2020) B. Millidge, A. Tschantz, A. K. Seth, and C. L. Buckley On the relationship between active inference and control as inference. In Active Inference, Communications in Computer and Information Science, Vol. 1326, pp. 3–11. External Links: Document Cited by: §1, §2.
- Millidge (2021) B. Millidge Applications of the free energy principle to machine learning and neuroscience. Note: PhD thesis, arXiv:2107.00140 External Links: 2107.00140, Link Cited by: §2.
- Millidge (2024) B. Millidge A retrospective on active inference. Note: https://www.beren.io/2024-07-27-A-Retrospective-on-Active-Inference/Blog post, posted July 27, 2024 Cited by: §2.
- Mirza et al. (2016) M. B. Mirza, R. A. Adams, C. D. Mathys, and K. J. Friston Scene construction, visual foraging, and active inference. Frontiers in Computational Neuroscience 10, pp. 56. External Links: Document Cited by: §9.
- Nowak (2011) R. D. Nowak The geometry of generalized binary search. IEEE Transactions on Information Theory 57 (12), pp. 7893–7906. External Links: Document, Link Cited by: §2.
- Nowak (2009) R. Nowak Noisy generalized binary search. In Advances in Neural Information Processing Systems 22, pp. 1366–1374. Cited by: §2.
- Nye et al. (2022) M. Nye, A. J. Andreassen, G. Gur-Ari, H. Michalewski, J. Austin, D. Bieber, D. Dohan, A. Lewkowycz, M. Bosma, D. Luan, C. Sutton, and A. Odena Show your work: scratchpads for intermediate computation with language models. In International Conference on Learning Representations (ICLR), External Links: Link Cited by: §9.
- Parr and Friston (2019) T. Parr and K. J. Friston Generalised free energy and active inference. Biological Cybernetics 113, pp. 495–513. Cited by: Appendix G, §2.
- Pathak et al. (2017) D. Pathak, P. Agrawal, A. A. Efros, and T. Darrell Curiosity-driven exploration by self-supervised prediction. In Proceedings of the 34th International Conference on Machine Learning (ICML), Proceedings of Machine Learning Research, Vol. 70, pp. 2778–2787. External Links: Link Cited by: §2.
- Piriyakulkij et al. (2023) W. T. Piriyakulkij, V. Kuleshov, and K. Ellis Active preference inference using language models and probabilistic reasoning. External Links: 2312.12009, Link Cited by: §2.
- Prakash et al. (2025) A. Prakash, N. He, D. Goktas, and A. Greenwald Bi-level policy optimization with nyström hypergradients. CoRR abs/2505.11714. External Links: 2505.11714, Link Cited by: Appendix G.
- Rainforth et al. (2024) T. Rainforth, A. Foster, D. R. Ivanova, and F. Bickford Smith Modern bayesian experimental design. Statistical Science 39 (1), pp. 100–114. Cited by: §2.
- Russo and Van Roy (2014) D. Russo and B. Van Roy Learning to optimize via information-directed sampling. Advances in neural information processing systems 27. Cited by: §2.
- Schick et al. (2023) T. Schick, J. Dwivedi-Yu, R. Dessì, R. Raileanu, M. Lomeli, E. Hambro, L. Zettlemoyer, N. Cancedda, and T. Scialom Toolformer: language models can teach themselves to use tools. In Advances in Neural Information Processing Systems, Vol. 36, pp. 68539–68551. External Links: Document Cited by: §9.
- Schrittwieser et al. (2020) J. Schrittwieser, I. Antonoglou, T. Hubert, K. Simonyan, L. Sifre, S. Schmitt, A. Guez, E. Lockhart, D. Hassabis, T. Graepel, T. Lillicrap, and D. Silver Mastering atari, go, chess and shogi by planning with a learned model. Nature 588 (7839), pp. 604–609. External Links: Document, 1911.08265 Cited by: §9.
- Shen et al. (2024) H. Shen, Z. Yang, and T. Chen Principled penalty-based methods for bilevel reinforcement learning and RLHF. Note: Shorter version accepted to ICML 2024 External Links: 2402.06886, Link Cited by: Appendix G.
- Shin et al. (2020) T. Shin, Y. Razeghi, R. L. Logan, E. Wallace, and S. Singh AutoPrompt: eliciting knowledge from language models with automatically generated prompts. In Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing (EMNLP), External Links: Link Cited by: §2.
- Thoma et al. (2024) V. Thoma, B. Pasztor, A. Krause, G. Ramponi, and Y. Hu Contextual bilevel reinforcement learning for incentive alignment. In Advances in Neural Information Processing Systems, Vol. 37, pp. 127369–127435. External Links: Link Cited by: Appendix G.
- Wang et al. (2024) W. Wang, J. Shi, Z. Ling, Y. Chan, C. Wang, C. Lee, Y. Yuan, J. Huang, W. Jiao, and M. R. Lyu Learning to ask: when llm agents meet unclear instruction. External Links: 2409.00557, Link Cited by: §2.
- Zhang et al. (2024) T. Zhang, P. Qin, Y. Deng, C. Huang, W. Lei, J. Liu, D. Jin, H. Liang, and T. Chua CLAMBER: a benchmark of identifying and clarifying ambiguous information needs in large language models. In Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics, External Links: Link Cited by: §2.
- Zhou et al. (2023) Y. Zhou, A. I. Muresanu, Z. Han, K. Paster, S. Pitis, H. Chan, and J. Ba Large language models are human-level prompt engineers. In International Conference on Learning Representations (ICLR), External Links: Link Cited by: §2.
Appendix A Optimal Question Asking: API Transcripts and Prompt Templates
Section titled “Appendix A Optimal Question Asking: API Transcripts and Prompt Templates”OQA is scored from the transcript alone. At each turn, the model asks about exactly one named attribute. The oracle returns the answer by looking it up in a finite table of attributes. After the reply, a scoring script filters the remaining set by exact consistency. Because every step is deterministic, the score is fully reproducible. With the same prompt and the same hidden target, replaying the same message sequence yields the same , the same entropy , and the same stopping time.
The protocol enforces two rules. Every question must use an attribute name from a fixed list. Each turn may refer to only one attribute. In binary OQA, the oracle replies “Yes” or “No”, and the update is . In multiway OQA, the oracle replies with a single value string, and the update is . A run ends when . It can also end earlier when the remaining items share the same vector of attributes, so no allowed query can split them further. For reliable parsing, a strict JSON format is available. The next query is read from the “question” field, while any extra fields are ignored and may be used for debugging.
This is a