What are cache fields?
Cache fields let you tag AI requests with business identifiers that echo back in every response and in the events ModelRiver sends for that request. They bridge the gap between your application's context and ModelRiver's processing pipeline.
When you define cache fields on a workflow, ModelRiver extracts matching values from your request payload and includes them in:
- The synchronous
/v1/airesponse undercustomer_data - WebSocket messages for async requests (including the final result)
- Webhook payloads for downstream processing
- Every step of a backend pipeline, through to the final result
Each key in customer_data is the field path you configured (for example metadata.user_id), not just the last segment.
Request Logs don't store customer_data as a separate column, and you can't filter or search logs by it. The original values are visible in the logged request body when the project saves full request and response text.
Configuring cache fields
Add cache fields when creating or editing a workflow:
- Navigate to Workflows in your project
- Open an existing workflow or create a new one
- In the Custom fields setting (under advanced settings), enter field paths separated by commas or newlines
Field path syntax
Use dot notation for nested data and indexes for arrays:
| Path | Extracts from |
|---|---|
user_id | Top-level user_id field |
metadata.segment | Nested metadata.segment value |
messages.0.content | First message's content field |
metadata.experiment.bucket | Deeply nested experiment bucket |
Example request and response
Request:
1{2 "model": "support_summarizer",3 "messages": [{"role": "user", "content": "Summarise this ticket"}],4 "metadata": {5 "user_id": "usr_abc123",6 "segment": "enterprise",7 "experiment": {"bucket": "v2"}8 }9}Response includes:
1{2 "customer_data": {3 "metadata.user_id": "usr_abc123",4 "metadata.segment": "enterprise",5 "metadata.experiment.bucket": "v2"6 }7}Best practices
- Keep it selective: Cache only the fields you need for observability. Avoid caching sensitive or high-cardinality data.
- Use consistent naming: Standardise field paths across workflows so the
customer_datakeys your code reads stay the same. - Don't replace persistence: Customer data is for observability echo, not a substitute for your database. Treat it as a convenient annotation layer.
- Leverage in debugging: Log
customer_datain your own application or webhook handler so you can trace specific users or experiments alongside ModelRiver'schannel_id.
Next steps
- Structured outputs: Enforce JSON response schemas
- Test mode: Validate workflows without provider calls
- Observability: Monitor and debug requests in Request Logs