Homeostatic Instruction Budgets for Textual Gradient Optimization

Textual gradient optimizers improve a language model's prompt the way gradient descent improves a network's weights. An "optimizer" LLM reads the model's failures, writes a critique in plain English (the "textual gradient"), and rewrites the prompt to fix them. Run for many steps, these optimizers mostly add text: a new rule for each edge case, a caveat for each mistake. Prompts and feedback swell. Old fixes get buried or contradicted, and capabilities that used to work start to break. Neuroscience has a precise name for this failure. Hebbian learning strengthens whatever was just useful, and left alone it drives synapses to saturation until the neuron can store nothing new. The brain's answer is synaptic normalization: each neuron gets a fixed total budget of synaptic strength. When one input grows, the others must shrink.

We propose to give each optimized prompt a fixed instruction budget enforced by a measured, credit-driven competition among its instructions. The prompt is held as a set of discrete instruction units. Each unit carries a strength that rises when the unit is actually used on solved examples and falls when it sits idle. When a new textual gradient adds a unit and the budget would be exceeded, weak, inactive units are depressed and evicted. This mirrors heterosynaptic depression, where inactive neighbours of a strengthened synapse are weakened. The claim to test is specific. Under a long or continual optimization run, which units are evicted should depend on observed per-unit activity, not on the optimizer LLM's own judgement or on length alone. Doing this should preserve earlier fixes and stop the prompt from bloating, at no loss of peak accuracy.

Where This Sits in Prior Work

The neuroscience literature supplies the mechanism. Grajski et al. showed that a constant total synaptic sum forces inputs to compete for representational resources. Chechik et al. proved that this remodeling prevents saturation and lets memory capacity scale with network size. That capacity argument is the one we transfer: a budgeted prompt should keep absorbing new fixes without overwriting old ones.

Normalization can also be enforced in two different ways, and these give us two prompt variants to compare. In the multiplicative form, every synapse is scaled down uniformly, which preserves relative ratios; Hartmann et al. show this acts as variance reduction. In the subtractive or competitive form, which emerges from asymmetric spike-timing windows (Abbott), inputs that fire out of step with the neuron (uncorrelated inputs) are driven to zero (Butts). Agnes and Vogels add that the depression should be gated by local activity, which is the role our activity signal plays. SPICED shows that periodic renormalization helps continual learning in numerical EEG decoders. We borrow its continual-learning framing but apply it to discrete text. Baldi et al. formalize input-output balance for networks with homogeneous activations. We do not claim their guarantees transfer to text, and we use only the budget idea.

On the textual side, three lines of work motivate the gap and constrain the design.

The first is the base method we optimize on top of. TextGrad introduced backpropagation of LLM critiques through a computation graph, and it rewrites variables without any capacity constraint.

The second line stabilizes the gradient signal rather than the parameters:

  • Agentic Neural Networks add textual momentum and validation-based rejection. Rejection accepts or refuses a whole edit but never prunes what has already accumulated.
  • TextResNet routes feedback between local and upstream causes and schedules which node to optimize by error density. It controls context growth with truncation and top-$k$ caps.
  • Textual Equilibrium Propagation (TEP) keeps feedback local to each node. Its paper also documents that summarizing feedback to fit a length bound strips out actionable specifics ("vanishing specificity").

All three manage the feedback. None bounds or rebalances the prompt itself, which is what we target.

The third line constrains the design. The Prompt Optimization Diagnostics study finds that prompt optimization underperforms zero-shot in roughly half of runs, and that agent coupling explains only 0.18–2.15% of variance in a two-agent pipeline. This forces two choices. We report full run distributions rather than best runs, and we concentrate on single-prompt and lightly coupled settings, where accumulation over time rather than inter-agent credit is the bottleneck. ACON optimizes natural-language guidelines for compressing an agent's running context. It compresses the agent's observations, not its own evolving instruction set, so it is a neighbouring baseline rather than a substitute. PHP prompt tuning reports, for continuous soft prompts, that longer prompts resist forgetting but transfer worse. That is evidence a fixed static length is the wrong control, and we test it directly.

Core Mechanism

Units and budget. The prompt is a list of instruction units $u_1,\dots,u_K$, each a sentence-scale directive. Each unit has a token cost $c_k$ and a strength $s_k \ge 0$. The budget requires $\sum_k c_k \le B$, where $B$ is a fixed token budget.

Activity. After each minibatch, an attribution pass labels each unit as active or inactive on each example. We use two estimators. The cheap one has the task model's own trace judged for which units it relied on. The expensive one is leave-one-out ablation of each unit on a small probe set, which we use to validate the cheap one.

Strength update. Let $a_k$ be the fraction of solved examples on which unit $k$ was active. Strength follows a Hebbian-plus-decay rule:

$$s_k \leftarrow (1-\delta)\,s_k + \eta\,a_k,$$

where $\eta$ is the potentiation rate and $\delta$ the decay rate.

Adding a unit. When a textual gradient proposes a new unit, it enters with strength $s_0$. If the budget is now exceeded, we apply one of two regimes:

  • Subtractive (heterosynaptic) regime: evict the lowest-strength units until the budget holds.
  • Multiplicative regime: ask the optimizer to compress every unit to a common fraction $B/\sum_k c_k$ of its length, which keeps all units at reduced size.

Strength also sets the rendering order, with strongest units placed first. This mechanism runs unchanged inside TextGrad, ANN-style, or TEP-style optimizers.

Research Program

We first build the unit-and-strength representation as a wrapper around an existing textual-gradient optimizer, so that every comparison varies only the parameter-side rule.

Second, we establish when bloat actually hurts. We run unconstrained TextGrad for long horizons (hundreds of steps rather than the usual few) and track three quantities:

  • prompt length,
  • accuracy on the current batch,
  • accuracy on a frozen set of earlier-fixed examples, which measures retention.

Third, we run the main continual setting. Tasks arrive in stages, and the same prompt must be optimized across all of them. The question is whether credit-driven eviction keeps old stages solved better than alternatives under an identical budget.

Fourth, we compare the subtractive and multiplicative regimes. Neuroscience predicts that subtractive normalization preserves sharp, specific rules but can lose rarely needed ones, while multiplicative normalization preserves breadth at the cost of specificity. We measure specificity directly by checking whether named variables, functions, and edge-case conditions survive across steps.

Finally, we measure what attribution costs, including how well the cheap trace-based activity estimate agrees with the ablation-based one.

Baselines

Zero-shot (do-nothing reference). The task model runs with its default prompt and no optimization. The diagnostics study shows this is a genuine competitor, beaten in only about half of optimization runs. Our method counts as useful only if a clear majority of seeds beat zero-shot on retention-weighted accuracy, not merely the best seed.

Vanilla TextGrad (TextGrad). This is the unconstrained reference that exhibits the bloat. It reports 36% on LeetCode-Hard and lifts GPT-4o on GPQA from 51% to 55%. We run it with the same task model, optimizer model, minibatches, and step count as everything else.

Strongest existing methods (TextResNet and TEP). These are the best reported systems on the benchmarks we use:

  • On a 5-component multi-hop retrieval pipeline over HotpotQA, TextResNet reports 46.23 F1 using 21k tokens, versus 24.86 F1 for TextGrad using 63k tokens.
  • TEP reports an 8.1% improvement over the next-best method on HotpotQA and a 3.4% gain on BigCodeBench. On a deepened BigCodeBench pipeline it keeps feedback under 5,000 tokens, where TextGrad exceeds 42,000.
  • For BigCodeBench, the only absolute number in the file for this question is GPT-4o's calibrated 51.1% on the Instruct split (BigCodeBench). No absolute textual-optimizer score on BigCodeBench was found on Lacuna.

We run both methods with and without our budget wrapper. Beating them means one of two outcomes: matching their final accuracy within seed noise while using less prompt and feedback tokens and retaining earlier stages better, or improving accuracy over a long horizon where they degrade.

Momentum plus validation rejection (Agentic Neural Networks). This is the most direct stability competitor. It reports 93.9% on HumanEval and 82.8% on MATH. We give it the same number of task-model calls that our attribution pass consumes, and spend those calls on validation, so that compute is matched.

Budget-instructed rewriting. This is the alternative most likely to match us. TextGrad is given the same budget $B$ and told to stay under it, deciding for itself what to cut.

Ablations that isolate the key ingredient. We run three variants under an identical budget:

  • random eviction, which tests whether credit matters at all;
  • recency-based eviction, which tests whether activity matters or simply age;
  • our activity-based eviction.

If budget-instructed rewriting or recency eviction matches activity-based eviction, the bio-inspired credit signal adds nothing and the claim fails.

Fairness rules. All methods share the same task and optimizer LLMs, the same data splits, the same tuning sweep size for their own hyperparameters, and the same total token budget. That total counts attribution and validation calls.

Why not just…?

Why not just put a length limit in the optimizer prompt? This is the real threat. A strong optimizer told "stay under $B$ tokens" may already prune sensibly. The evidence against it is indirect. TEP shows that LLM-driven compression to meet a length bound drops specifics. TextResNet notes that its caps risk discarding needed dependencies. Neither tested budget-aware instruction pruning against measured credit. The budget-instructed baseline and the eviction ablations settle the question directly. We commit to reporting it as a negative result if the optimizer's own pruning ties ours on retention and specificity.

Why not just reject bad edits with validation, as in Agentic Neural Networks? Rejection only filters what enters the prompt. A sequence of individually acceptable edits can still accumulate into a bloated, self-contradictory prompt, and ANN itself reports growing complexity over extended evolution. The compute-matched comparison tests the specific failure case: whether retention on early stages degrades under ANN-style rejection but not under budgeted eviction across a long continual run.

Why not just compress periodically with an ACON-style compressor? ACON cuts token use by 26–54% by compressing the agent's running context under learned guidelines. Applied to the instruction set, it would amount to our multiplicative regime with a learned compressor in place of the optimizer. We therefore include it as the strongest version of the multiplicative arm. The prediction is that it loses specific edge-case rules that the subtractive arm keeps, and the specificity-survival metric tests exactly that.

Why not just skip optimization, given the coin-flip finding? The diagnostics study is the main contrary evidence. It also shows optimization helps where there is exploitable structure, such as gains of up to +6.8 on HelpSteer2. Large reported gains appear on multi-hop and code tasks. We treat zero-shot as a baseline that must be beaten across the run distribution, not only at the best seed.

Proposed Experiments

Continual code setting. The main experiment optimizes one system prompt for BigCodeBench-Instruct, presenting its seven domains sequentially. After each stage we measure pass rate on that stage and on all earlier stages, along with prompt token count. Budgets are swept from tight to loose, and every method is run over many seeds, matching the run counts of the diagnostics study.

Multi-hop pipeline setting. The second experiment reuses the 5-component HotpotQA retrieval pipeline, with per-node budgets, wrapping both TextResNet and TEP. It reports answer F1 and total tokens against the 46.23 F1 / 21k-token TextResNet reference.

Short-horizon checks. MATH and HumanEval check that budgeting does not cost peak accuracy in short runs, measured against the ANN numbers above.

Decisive checks. Three outcomes decide the claim:

  • Activity-based eviction must beat random, recency-based, and budget-instructed pruning on earlier-stage retention at matched budget and matched compute.
  • The subtractive and multiplicative regimes should split as predicted on specificity survival.
  • The share of seeds beating zero-shot should rise relative to unconstrained TextGrad.

If the first check fails, the proposal reduces to "use a token budget," and we would report it as such.