-
Notifications
You must be signed in to change notification settings - Fork 334
Open
Description
Description
The AI chat feature consistently fails when attempting to generate funnel reports (and likely other chart types). The LLM calls getFunnelReport but omits the required type discriminator field in series objects, causing Zod validation to reject every tool call.
Error
AI_InvalidToolArgumentsError → AI_TypeValidationError → ZodError
{
"code": "invalid_union_discriminator",
"options": ["event", "formula"],
"path": ["series", 0, "type"],
"message": "Invalid discriminator value. Expected 'event' | 'formula'"
}
What the LLM sends
{
"series": [
{ "name": "screen_view", "displayName": "Page View" },
{ "name": "signup_completed", "displayName": "Signup Completed" }
]
}What the schema expects
{
"series": [
{ "type": "event", "name": "screen_view", "displayName": "Page View" },
{ "type": "event", "name": "signup_completed", "displayName": "Signup Completed" }
]
}Impact
- The AI chat is effectively broken for any analytical query that requires tool calls
- The error loops silently — the user sees repeated "An error occurred" messages with no useful feedback
finishReason: "tool-calls"confirms the LLM is trying to call tools but they all fail validation
Reproduction
- Open AI chat in the OpenPanel dashboard
- Ask something like "Show me a funnel report for screen_view → signup_completed"
- The AI attempts a tool call, Zod rejects it, and "An error occurred" is returned
Suggested fix
The LLM isn't being told about the required type field in series objects. Either:
- Add explicit examples in the system prompt showing
"type": "event"in series objects - Ensure the full Zod schema (including the discriminated union) is passed to the model's tool definitions
- Add a default
type: "event"fallback in the tool argument parser before Zod validation
Environment
- OpenPanel version: 2.2.1 (
lindesvard/openpanel-api:2) - Self-hosted via Coolify
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels