If an agent has already run a plan for this exact task before and it worked well, re-deriving a plan from scratch is wasted effort — the cheapest, most reliable plan is often just "do what worked last time." This is the simplest possible form of experience-based planning: not a general similarity search (that's the previous question's job), just a direct lookup for an exact repeat of a task the agent has already solved.
You're given query_task (the exact task being planned for right now) and past_plans — (task_name, plan, success_rate) for every past run logged, in order. Implement pick_best_past_plan(query_task, past_plans). Among entries whose task_name exactly matches query_task, return the plan with the highest success_rate (ties broken by whichever was seen first in past_plans). Return None if no past plan exists for this exact task.
success_rate is a real number in [0, 1].This is a filtered argmax: only consider entries whose task_name exactly matches, and among those, track the one with the highest success_rate seen so far as you scan.
Use a strict > comparison (not >=) when updating the best-so-far — that's what makes the first occurrence of the maximum win a tie, rather than the last.
No results yet
Run your code to check it against the examples, or submit to run every test.