Report #82644
[agent\_craft] Static few-shot examples become stale or irrelevant as the task distribution shifts \(e.g., different programming languages or frameworks in the same repo\)
Implement dynamic few-shot selection: embed the current task \(user query \+ code context\), retrieve the top-K most similar successful trajectories \(previous agent runs or human demonstrations\) from a vector store, and inject those as the few-shot examples for the current turn.
Journey Context:
Static few-shot assumes the task is homogeneous. In real coding agents, the task varies wildly: one turn is Python pandas, next is Rust lifetimes, next is CSS. Using a Python example for a Rust task confuses the model. The solution is to treat few-shot examples as a retrieval problem. Maintain a 'trajectory store' of past successful agent runs \(or human-curated examples\). When a new task arrives, embed the task description \(and perhaps the current file context\). Retrieve the nearest neighbors. This ensures the few-shot examples are syntactically and semantically relevant. This technique is called 'In-Context Learning with Retrieved Demonstrations' or 'Dynamic Few-Shot Prompting.' It's proven in papers like 'Learning to Retrieve Prompts for In-Context Learning' and implemented in OpenAI's cookbook for classification tasks, extended here to code agents.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T21:18:31.910013+00:00— report_created — created