Overhaul extraction pipeline with new TradeItem model, conversation flow, and dedicated extraction endpoint. Add sidebar navigation with NavMenu component and landing page. Introduce few-shot prompting service and tests. Add prompt settings and email upload specs. Update OpenSpec tooling with improved export-spec and extract-feature commands. Archive completed changes and export full specs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
3.0 KiB
MODIFIED Requirements
Requirement: Predefined extraction schema
The system SHALL define the extraction schema as a TradeItem class with fields: valuedate, counterparty, legal_entity, trade_id, display_ccy, pv, breakclause. Extraction output SHALL be wrapped in an ExtractionResult containing a List<TradeItem>. All extraction output MUST conform to this schema.
Scenario: Output conforms to schema
- WHEN the agent produces extracted fields from an email
- THEN every item in the output is a valid TradeItem with all required fields matching expected types
Scenario: Multiple items from one email
- WHEN the agent extracts data from an email containing multiple trade legs
- THEN the output ExtractionResult contains one TradeItem per trade leg
Requirement: Autonomous validation via tool calling
The agent SHALL validate extracted fields by calling external API tools exposed as Semantic Kernel functions. Validation tools include counterparty lookup, trade validation, currency validation, and schema validation. Each tool returns structured results that the agent reasons about.
Scenario: Validation passes
- WHEN the agent calls the schema validation tool with a complete and correct ExtractionResult
- THEN the tool returns a success result and the agent returns the final output to the user
Scenario: Validation fails with fixable errors
- WHEN a validation tool returns errors for missing or malformed fields
- THEN the agent re-reads the source text and attempts to fix the extraction without user intervention
Scenario: Counterparty disambiguation required
- WHEN the counterparty lookup tool returns multiple candidate (counterparty, legal_entity) tuples
- THEN the agent presents the candidates to the user as a numbered list in the chat and waits for the user to select one before completing the extraction
Requirement: Human-in-the-loop clarification
When the agent escalates to the user, the user SHALL be able to provide the missing information in natural language, and the agent SHALL incorporate the clarification and re-attempt extraction. Disambiguation of counterparty/legal_entity tuples is a specific case of human-in-the-loop clarification.
Scenario: User provides clarification
- WHEN the agent asks for clarification about missing fields and the user responds
- THEN the agent incorporates the user's response into the conversation context and produces an updated extraction
Scenario: User selects counterparty from candidates
- WHEN the agent presents a numbered list of counterparty/legal_entity candidates and the user replies with a selection
- THEN the agent populates the
legal_entityfield on all relevant TradeItems and proceeds with validation
Scenario: Clarification via normal chat
- WHEN the agent escalates for clarification
- THEN the clarification request appears as a regular assistant message in the chat UI, and the user responds via the normal chat input