ADDED Requirements
Requirement: SSE Visualization Event
The system SHALL emit an SSE event of type visualization when an agent tool returns structured chart data, containing the chart type, component name, title, and props sufficient to render the corresponding frontend chart component.
Scenario: MarketAgent returns K-line data
- GIVEN a user asks "分析一下贵州茅台的K线"
- WHEN MarketAgent's
get_klinetool returns data - THEN an SSE
visualizationevent SHALL be emitted with typeklineand props containingdata(array of OHLCV objects)
Scenario: ReportAgent returns financial analysis
- GIVEN a user asks "分析贵州茅台的财报"
- WHEN ReportAgent's
get_comprehensive_financial_analysistool returns data - THEN an SSE
visualizationevent SHALL be emitted with typefinancial_trendand props containing revenue, profit, and ratio trend data
Scenario: BacktestAgent returns backtest results
- GIVEN a user asks "用MACD策略回测贵州茅台"
- WHEN BacktestAgent's
run_simple_backtesttool returns data - THEN an SSE
visualizationevent SHALL be emitted with typeprofit_curveand props containing portfolio value time series
Requirement: Dynamic Chart Component Rendering
The frontend MessageList SHALL render visualization events using the corresponding reusable chart component (KLineChart, TrendChart, ProfitChart, IndexCompareChart) based on the type field, displaying charts inline within the assistant message.
Scenario: K-line chart rendered in chat
- WHEN a
visualizationevent with typeklineis received - THEN the system SHALL render the KLineChart component with the event's props data inline in the message
Scenario: No chart data
- WHEN a tool returns no
_visualizationfield - THEN no visualization event SHALL be emitted and the message SHALL render as text-only
Requirement: Visualization Data Persistence
The system SHALL persist visualization data in the message metadata so that charts can be re-rendered when loading historical messages.
Scenario: Reload chat with charts
- GIVEN a message with visualization data was previously sent
- WHEN the user reloads the chat session
- THEN the charts SHALL be re-rendered from persisted metadata