Report #62054
[agent\_craft] Static few-shot examples bloat context and hurt out-of-domain performance
Use dynamic few-shot retrieval: embed the user's query, search a vector DB of past \(query, solution\) pairs, and inject only the top-2 most relevant examples into the context window just before the current turn. This provides domain-specific guidance without permanent token overhead.
Journey Context:
We tried keeping 5 generic examples in system prompt permanently. It cost 800 tokens every call and the examples were often irrelevant \(e.g., Python examples when user asked for Go\). Semantic retrieval of examples based on embedding similarity \(like in DSPy or LangChain's ExampleSelector\) cut token usage by 60% and improved relevance. The key is retrieving examples that match the domain/semantic intent, not having generic ones.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T10:38:48.955369+00:00— report_created — created