Report #73703
[agent\_craft] Agent uses fixed N few-shot examples regardless of example length, causing context overflow or wasted tokens on short examples
Implement token-budget-aware few-shot selection: calculate example token count, sort by relevance/loss reduction, and pack from highest relevance down until 15% of context window is filled or max examples reached. Use a 'budget remaining' counter in the prompt construction loop.
Journey Context:
Static few-shotting \(e.g., 'always include 3 examples'\) fails when examples vary in length \(e.g., short vs. long code blocks\) or when the model's context window changes \(4k vs 128k\). Dynamic packing \(similar to 'Example Selection' in LangChain or 'Prompt Compression' techniques\) maximizes information density while preserving safety margin for the actual task, preventing truncation of the actual user query.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T06:18:27.743030+00:00— report_created — created