## Why The extraction agent needs few-shot examples to reliably produce correct structured output from sales emails. Without examples, the agent relies entirely on the instruction template and tool descriptions, which cannot fully convey the implicit mapping conventions (date parsing from "OB" prefix, flattening swap legs, currency symbol mapping, breakclause defaults). A curated set of 3-5 input/output examples injected as conversation turns in the ChatHistory dramatically improves extraction accuracy. The remaining ~95 available examples serve as an evaluation set for offline quality testing. Additionally, the extraction workflow needs a dedicated API endpoint separate from general chat, since it uses a different system prompt, different tools, and the few-shot ChatHistory prefix. ## What Changes - **Create examples folder structure** at `examples/extraction/few-shot/` with numbered subdirectories, each containing `input.html` (email) and `output.json` (expected ExtractionResult) - **Create extraction instruction template** — a fixed system prompt defining the extraction task, schema, and mapping rules (separate from the user-editable system prompt) - **Create a FewShotService** that loads examples from disk at startup and pre-assembles a ChatHistory prefix (system message + alternating user/assistant turns) - **Add `POST /api/chat/extract` endpoint** that uses the few-shot ChatHistory, appends the real email, and streams the extraction response via SSE - **Create `ExtractionRequest` DTO** for the extraction endpoint (email content + optional follow-up messages for disambiguation) - **Update client `ChatApiClient`** with a method for the extraction endpoint ## Capabilities ### New Capabilities - `few-shot-prompting`: Defines the example folder structure, loading mechanism, ChatHistory assembly, and instruction template for few-shot extraction prompting - `extraction-endpoint`: Defines the dedicated extraction API endpoint, its request/response contract, and how it differs from the general chat endpoint ### Modified Capabilities - `chat-streaming`: Add the extraction endpoint alongside the existing chat endpoint, sharing the same SSE streaming contract ## Impact - **New files**: examples folder, FewShotService, instruction template, ExtractionRequest DTO, extraction controller action - **Configuration**: example folder path in appsettings.json - **API surface**: new `POST /api/chat/extract` endpoint - **Client**: new method on ChatApiClient (no UI changes — that's the email-upload-ux change) - **Depends on**: `update-extraction-schema` (needs TradeItem schema for examples and validation tools)