Skip to content

AI Assistant: fix json schema building#33588

Open
dmirgaev wants to merge 7 commits into
DevExpress:26_1from
dmirgaev:26_1__ai_assistant_json_schema
Open

AI Assistant: fix json schema building#33588
dmirgaev wants to merge 7 commits into
DevExpress:26_1from
dmirgaev:26_1__ai_assistant_json_schema

Conversation

@dmirgaev
Copy link
Copy Markdown
Contributor

No description provided.

@dmirgaev dmirgaev self-assigned this May 14, 2026
Copilot AI review requested due to automatic review settings May 14, 2026 23:45
@dmirgaev dmirgaev requested a review from a team as a code owner May 14, 2026 23:45
@dmirgaev dmirgaev added the 26_1 label May 14, 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

This PR updates the Grid AI Assistant’s response JSON Schema generation to be compatible with structured-output APIs (notably OpenAI Structured Outputs), by normalizing unsupported schema constructs and ensuring $ref resolution works at the schema root.

Changes:

  • Switch JSON Schema generation to zod-to-json-schema’s openAi target and remove reliance on draft-07 $schema.
  • Add schema post-processing utilities to (1) expand array-style type to anyOf and (2) hoist/rewrite $ref targets into root-level $defs.
  • Refactor filterValue command schema to a discriminated-union object format (instead of tuple arrays) and update/add tests for schema + execution + integration behavior.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/devextreme/js/__internal/grids/grid_core/ai_assistant/utils.ts Adds JSON Schema transformation utilities (expandTypeArraysToAnyOf, $ref hoisting/rewriting helpers).
packages/devextreme/js/__internal/grids/grid_core/ai_assistant/types.ts Simplifies JsonSchema typing and introduces ResponseSchemaBranch shape used by schema builder.
packages/devextreme/js/__internal/grids/grid_core/ai_assistant/grid_commands.ts Builds OpenAI-targeted response schema, expands type unions, and hoists $defs to schema root.
packages/devextreme/js/__internal/grids/grid_core/ai_assistant/commands/index.ts Removes obsolete TODO comment.
packages/devextreme/js/__internal/grids/grid_core/ai_assistant/commands/filtering.ts Changes filter expression input to object-based discriminated union; converts to DataGrid’s expected array filter format at execution.
packages/devextreme/js/__internal/grids/grid_core/ai_assistant/commands/tests/filtering.test.ts Updates filter command schema/execute tests for the new object expression format.
packages/devextreme/js/__internal/grids/grid_core/ai_assistant/ai_assistant_integration_controller.ts Refactors context building into overridable buildContext / buildColumnContext and caches controllers during init().
packages/devextreme/js/__internal/grids/grid_core/ai_assistant/tests/utils.test.ts Adds unit tests for the new schema utilities (expandTypeArraysToAnyOf, hoistSchemaRefs).
packages/devextreme/js/__internal/grids/grid_core/ai_assistant/tests/grid_commands.test.ts Updates schema tests for OpenAI target and adds coverage for $defs hoisting / inline $ref rewriting.
packages/devextreme/js/__internal/grids/grid_core/ai_assistant/tests/ai_assistant_integration_controller.integration.test.ts Minor typing cleanup in test setup (aligns with new controller behavior).
packages/devextreme/js/__internal/grids/grid_core/ai_assistant/tests/ai_assistant_controller.test.ts Adds coverage for additional failure paths, request concurrency rejection, header title formatting, and dispose behavior.
packages/devextreme/js/__internal/grids/data_grid/ai_assistant/commands/index.ts Removes obsolete TODO comment.
packages/devextreme/js/__internal/grids/data_grid/ai_assistant/ai_assistant_integration_controller.ts Updates overrides to buildContext / buildColumnContext to enrich context with summary info.
packages/devextreme/js/__internal/grids/data_grid/ai_assistant/tests/ai_assistant_integration_controller.integration.test.ts New integration tests validating DataGrid-specific context enrichment and lifecycle behaviors.
packages/devextreme/js/__internal/grids/data_grid/ai_assistant/tests/ai_assistant_controller.test.ts New controller tests ensuring DataGrid controller inherits core behavior and wiring.

Copilot AI review requested due to automatic review settings May 15, 2026 00:23
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 20 out of 20 changed files in this pull request and generated 2 comments.

Comment on lines +82 to +98

if (Array.isArray(result.type)) {
const { type, ...rest } = result;

return {
anyOf: (type as string[]).map((t) => ({ type: t })),
...rest,
};
}

for (const key of SCHEMA_TRAVERSAL_KEYS) {
if (key in result) {
result[key] = transformNested(key, result[key]);
}
}

return result;
return undefined;
}

current = (current as Record<string, unknown>)[segment];
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