Report #88499
[agent\_craft] Static few-shot examples become irrelevant as the codebase evolves or when the agent faces novel tasks not covered by the hardcoded examples
Replace static few-shot examples with a dynamic retrieval system: embed the current task description/code context, retrieve the top-K most similar successful agent trajectories from a vector database, and prepend them as few-shot examples for the current turn.
Journey Context:
Hardcoded few-shot examples suffer from distribution shift—examples showing Python file manipulation are useless when the agent is suddenly editing Rust or Terraform. Moreover, static examples can't cover the long tail of edge cases \(specific library APIs, internal company conventions\). Dynamic retrieval ensures the examples are distributionally matched to the current task. This pattern draws from Retrieval-Augmented Generation \(RAG\) but applies it to agent trajectories rather than documents. The key insight is that successful past runs contain implicit knowledge about tool ordering, error handling, and domain-specific patterns that can't be captured in static system prompts. Implementation requires logging agent sessions, embedding the user intent \+ code context, and indexing them for similarity search.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T07:07:51.596022+00:00— report_created — created