Decision-orchestrated reflect loops to max_iterations: sufficiency check reads only the head of the evidence, follow-up rounds re-fetch the same pages
Version: stock ghcr.io/vectorize-io/hindsight:1.2.1, reflect decision model provider=hindsight (hs-decide-1-flash), main LLM via the Codex provider.
What happens
With the decision model on for reflect, a question whose first retrieval round is judged "not enough" keeps running follow-up rounds until max_iterations. At budget high (20 iterations, the coding-agents plugin's default reflectBudget) we saw reflects of 14, 9 and 18 iterations (39 / 24 / 51 tool calls) taking 106 / 57 / 117 s and about 1.2M input tokens each (roughly 0.55M LLM + 0.65M decision-model). Across all reflect traces on our server, enabling the decision model moved p50 from 31 s to 41 s and p90 from 95 s to 121 s, and LLM input per reflect from ~152k to ~424k tokens.
Two things in the loop look like the cause:
1. The sufficiency check only ever sees the head of the evidence.
evidence_is_sufficient (engine/cross_encoder.py) fits the evidence with truncate_to_tokens(evidence, budget) and the comment says it "keeps the head of the evidence". The evidence passed in is every tool message joined in order, so each follow-up round is appended at the tail. Once round one already fills the question window, later rounds can never change what the decision model reads. In an 18-iteration trace the decision_evidence_sufficiency request size went 23,085 → 24,555 → 27,751 tokens and then stayed at exactly 27,751 for every remaining round, while the agent context grew from 29k to 78k tokens. The verdict is then decided on identical input each round, so the loop only ends at the iteration cap.
2. Every follow-up round re-runs all forced layers, including the same pages.
_parallel_round issues search_mental_models + search_observations + recall for each follow-up query. In practice search_mental_models returns largely the same pages each round (~55k characters each time in our traces), which are then pruned again (kept 15/71, 15/77, 15/79, ...). Nothing new is learned, but each round costs three tool calls, a prune, a sufficiency call and one more LLM turn over a growing context.
A/B on the same three questions (same bank, same minute)
| budget | q1 | q2 | q3 |
|---|---|---|---|
| low (5 it.) | 5 it, 54 s, 195k tok | 1 it, 17 s, 29k | 1 it, 18 s, 30k |
| mid (10 it.) | 6 it, 45 s, 276k | 1 it, 19 s, 29k | 10 it (cap), 73 s, 483k |
| high (20 it.) | 7 it, 53 s, 324k | 1 it, 19 s, 28k | 1 it, 16 s, 29k |
q3 was judged sufficient after one round at low and high but ran to the cap at mid, and the 1-round and 10-round answers stated the same facts. So whether a reflect loops is partly chance, and only the cap bounds the cost.
Suggestions
- Judge sufficiency on evidence that includes the newest round (keep the tail, or summarise earlier rounds), so a follow-up search can actually change the verdict.
- Skip layers whose results are already in context on follow-up rounds (or de-duplicate page results by id before pruning).
- Give decision-orchestrated follow-up rounds their own small cap, independent of the budget multiplier;
highcurrently means up to ~19 extra rounds.
Workaround we use: reflectBudget: "low" in the coding-agents plugin config, and for now the decision model switched off for reflect (HINDSIGHT_API_REFLECT_USE_DECISION_MODEL=false).