AI Assistant: Filter command does not create Date objects in filter expression#33756
Open
Raushen wants to merge 4 commits into
Open
AI Assistant: Filter command does not create Date objects in filter expression#33756Raushen wants to merge 4 commits into
Raushen wants to merge 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for date-based filter values in the Grid AI Assistant flow by allowing the filtering command to accept Date values and introducing an "AIDate(y, m, d)" string encoding that is converted to Date objects during assistant response parsing.
Changes:
- Extend
filterValuecommand argument schema/types to allowDatevalues and document the"AIDate(...)"encoding. - Convert
"AIDate(...)"strings intoDateobjects while parsingexecuteGridAssistantresponses. - Add unit tests to validate schema acceptance and date conversion behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| packages/devextreme/js/__internal/grids/grid_core/ai_assistant/commands/filtering.ts | Allows Date as a scalar filter value and documents "AIDate(year, month, day)" encoding in the command description. |
| packages/devextreme/js/__internal/grids/grid_core/ai_assistant/commands/tests/filtering.test.ts | Adds coverage for accepting/passing Date values through to the legacy filter array. |
| packages/devextreme/js/__internal/core/ai_integration/commands/executeGridAssistant.ts | Adds a JSON.parse reviver to convert "AIDate(...)" strings into Date objects during response parsing. |
| packages/devextreme/js/__internal/core/ai_integration/commands/executeGridAssistant.test.ts | Adds tests asserting "AIDate(...)" strings are converted to Date objects for string response forms. |
added 2 commits
May 28, 2026 16:01
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
packages/devextreme/js/__internal/grids/grid_core/ai_assistant/commands/filtering.ts:55
- The command instructs the assistant to emit dates as the custom string format
AIDate(y, m, d), but the args schema now usesz.date(). Since the response schema is generated viazodToJsonSchema(..., { target: 'openAi' })(see grid_commands.ts),z.date()will be represented as a JSON string in the schema (often a date-time), which can steer the model toward ISO-style strings thatparseDateswill not convert, causing schema validation to reject the action. Consider modeling date values as a string schema that matches theAIDate(...)pattern and transforming it toDateduring zod parsing (or extend parsing to accept ISO as well) so the schema, prompt, and runtime parsing stay consistent.
const filterOpSchema = z.enum(FILTER_OPS);
const filterValueScalarSchema = z.union([z.string(), z.number(), z.boolean(), z.null(), z.date()]);
const basicFilterExprSchema = z.object({
type: z.enum(['basic']),
field: z.string(),
operator: filterOpSchema,
value: filterValueScalarSchema,
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.