Get Invocations
Models & Invocations
Get Invocations
Retrieve conversation history with AI invocations, tool calls, and trading decisions
GET
Get Invocations
Overview
ThegetInvocations endpoint returns a comprehensive snapshot of all AI model invocations (conversations) including:
- Model responses and reasoning
- Trading tool calls (CREATE_POSITION, CLOSE_POSITION, HOLDING)
- Parsed trading decisions and execution results
- Timestamps and metadata for each action
Invocation Tracking
Each time a trading model is invoked by the scheduler, the system:- Creates an Invocation record with the model’s response
- Logs ToolCalls for each trading action (open, close, hold positions)
- Parses metadata to extract structured decisions and results
- Filters auto-triggered actions (stop-loss/take-profit) from the conversation view
modelId.
Request
Empty object - no parameters required
Response
Array of conversation snapshots ordered by timestamp (newest first)
Database Schema
Invocations Table
ToolCalls Table
Auto-Triggered Filtering
The endpoint automatically excludes invocations that only contain auto-triggered stop-loss or take-profit closures:Tool Call Types
Model decided to open a new position (LONG or SHORT)Typical decisions:
- Symbol, side (LONG/SHORT), quantity, leverage
- Entry price, stop-loss, take-profit targets
- Confidence score, invalidation conditions
Model decided to close an existing positionTypical decisions:
- Symbol, side, quantity to close
- Reason for closure (profit target hit, invalidation, risk management)
- Realized P&L after execution
Model evaluated positions but decided to hold (no action)Typical decisions:
- Current portfolio state confirmation
- Reasoning for maintaining existing positions
- Market analysis and next evaluation time
TanStack Query Integration
Client Usage
Query Configuration
Example Response
Variant-Aware Fetching
The endpoint fetches invocations across all variants with fair representation:Performance Considerations
- Tool Calls Limit: Each invocation loads up to 50 tool calls (most recent first)
- Invocation Limit: Returns 100 invocations per variant (400 total max)
- Auto-Filtering: Removes system-triggered invocations to reduce noise
- Cache Duration: 20-second stale time with 3-minute garbage collection
Error Handling
The endpoint throws an error if the database query fails:getModels, this endpoint does not provide fallback data since invocation history cannot be derived from static configuration.
Related Endpoints
- Get Models - Fetch list of all trading models
- Get Positions - Fetch active positions with decision status
- Get Trades - Fetch closed trades with P&L
Implementation Details
Source Files:- Router:
src/server/orpc/router/models.ts:43-59 - Query Function:
src/server/features/trading/conversationsSnapshot.server.ts:61-144 - Schema:
src/db/schema.ts:50-88(Invocations + ToolCalls tables)
- Stale Time: 20 seconds (updated by scheduler)
- GC Time: 3 minutes
- Refetch: On window focus (default TanStack behavior)

