Dynamic Scaffolding
Inject task-specific scaffolding (examples, hints, schemas) into the prompt only when the task type warrants it.
Intent & Description
🎯 Intent
Inject task-specific scaffolding (examples, hints, schemas) into the prompt only when the task type warrants it.
📋 Context
A general-purpose agent handles a wide range of task types in one product — answering free-text questions, writing or refactoring code, querying databases, transforming structured documents. Some of those tasks benefit a lot from extra material in the prompt such as worked examples, output schemas, or domain hints, while others are trivial and need none of it. The same prompt is shared across every request unless the team does something about it.
💡 Solution
Maintain a library of scaffolds (few-shot examples, schemas, hints) keyed by task type or feature. At runtime, classify the task and inject the matching scaffolds. Audit which scaffolds fired per request.
Real-world Use Case
- Some tasks need few-shot examples, schemas, or hints and others do not — static prompts overshoot or undershoot.
- A library of scaffolds keyed by task type or feature can be maintained.
- Task classification at runtime is reliable enough to route the right scaffold.
Source
Advantages
- Token efficiency.
- Targeted quality lift on hard cases.
Disadvantages
- Scaffold library maintenance.
- Misclassification injects wrong scaffolds.