Skip to content

AI Assistant: Filter command does not create Date objects in filter expression#33756

Open
Raushen wants to merge 4 commits into
DevExpress:26_1from
Raushen:AIAssistant-Date-Filtering
Open

AI Assistant: Filter command does not create Date objects in filter expression#33756
Raushen wants to merge 4 commits into
DevExpress:26_1from
Raushen:AIAssistant-Date-Filtering

Conversation

@Raushen
Copy link
Copy Markdown
Contributor

@Raushen Raushen commented May 28, 2026

No description provided.

@Raushen Raushen self-assigned this May 28, 2026
Copilot AI review requested due to automatic review settings May 28, 2026 10:13
@Raushen Raushen requested a review from a team as a code owner May 28, 2026 10:13
@Raushen Raushen added the 26_1 label May 28, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 filterValue command argument schema/types to allow Date values and document the "AIDate(...)" encoding.
  • Convert "AIDate(...)" strings into Date objects while parsing executeGridAssistant responses.
  • 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.

Copilot AI review requested due to automatic review settings May 28, 2026 13:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 uses z.date(). Since the response schema is generated via zodToJsonSchema(..., { 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 that parseDates will not convert, causing schema validation to reject the action. Consider modeling date values as a string schema that matches the AIDate(...) pattern and transforming it to Date during 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,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants