Context
Right now, when the planner builds a graph, library suggestions that succeed get promoted and reused. The selection is greedy — first match wins, and there's no mechanism to discover that an untried approach might be better. This is the multi-armed bandit problem (Kochenderfer Ch. 15).
The Idea
Add Upper Confidence Bound (UCB) scoring to library suggestion selection. Each library entry tracks successes and attempts. When the planner selects a suggestion, instead of picking the first/best match, it picks the one with the highest UCB score:
score = (successes / attempts) + C * sqrt(ln(total_attempts) / attempts)
The second term is an uncertainty bonus — large when an option hasn't been tried much, shrinking as it gets more attempts. This naturally balances explore (try uncertain options) vs. exploit (use proven ones).
Concrete Example
mail search --from jake -> 8/10 successes, well-tested, small bonus -> score ~ 0.85mail search --filter "from/emailAddress/address eq 'jake@microsoft.com'" -> never tried, huge uncertainty bonus -> score ~ 1.0+- System tries the untried option once. If it works (1/1), it competes on merit. If it fails (0/1), system goes back to the known option.
Questions to answer before implementing
- How does library promotion currently work? Where are suggestions stored, how are they matched to planner context, and how are they surfaced to the LLM?
- Would adding
attempts and successes fields to the library model be straightforward? - How to feed UCB scores into the planner prompt? Options: (a) rank suggestions by UCB before including them, (b) include the scores and let the LLM factor them in, (c) filter to top-N by UCB score.
- Where does "success" get recorded? After graph.Ok, or per-task?
- Interaction with the repair loop — if a suggestion fails on first attempt but succeeds after repair, is that a success or failure for the bandit?
- The exploration constant C needs tuning. What should it be given typical library size and usage frequency?
Estimated scope
~30 lines of scoring logic if the data model cooperates. The hard part is deciding the success signal and repair loop interaction, not the math.
References
- Kochenderfer, Wheeler, Wray — Algorithms for Decision Making, Ch. 15 (Exploration and Exploitation)
- Related to the capability system collapse (commit bbd4ada) and prompt consolidation (commit 6610034) from the recent refactor
Context
Right now, when the planner builds a graph, library suggestions that succeed get promoted and reused. The selection is greedy — first match wins, and there's no mechanism to discover that an untried approach might be better. This is the multi-armed bandit problem (Kochenderfer Ch. 15).
The Idea
Add Upper Confidence Bound (UCB) scoring to library suggestion selection. Each library entry tracks
successesandattempts. When the planner selects a suggestion, instead of picking the first/best match, it picks the one with the highest UCB score:The second term is an uncertainty bonus — large when an option hasn't been tried much, shrinking as it gets more attempts. This naturally balances explore (try uncertain options) vs. exploit (use proven ones).
Concrete Example
mail search --from jake-> 8/10 successes, well-tested, small bonus -> score ~ 0.85mail search --filter "from/emailAddress/address eq 'jake@microsoft.com'"-> never tried, huge uncertainty bonus -> score ~ 1.0+Questions to answer before implementing
attemptsandsuccessesfields to the library model be straightforward?Estimated scope
~30 lines of scoring logic if the data model cooperates. The hard part is deciding the success signal and repair loop interaction, not the math.
References