fix(ai) - optimize metadata CRUD tools (#21235)

Reduces output tokens for all 13 metadata tools by (~49%) based on
production sampling data.

GET tools (field + object metadata)

System fields are now returned as compact {id, name, type} instead of
the full ~20-key payload (opt-in includeFullSystemFields to get full
payload). System objects are similarly compacted to {id, nameSingular,
namePlural}.
Internal fields the agent never uses (searchVector, deletedAt, position,
updatedBy) are excluded entirely.
workspaceId and applicationId are hoisted into a response envelope
instead of being repeated on every record.
Null/default-false properties are stripped from custom field and object
payloads (e.g. options: null, settings: null, isUIReadOnly: false).

CUD tools (create/update/delete)

Create and update field tools now return {id, name, type, label} instead
of the full DTO.
Create and update object tools now return {id, nameSingular,
labelSingular} instead of the full DTO.
Delete tools return {id, success: true} instead of the full DTO of the
deleted entity.
Validation errors are grouped by message — e.g. 10 fields failing the
same check produce one line with all names instead of 10 identical
lines.

Learn schemas (all tools)

UUID pattern regex stripped from JSON schemas (keeps format: "uuid").
$schema and additionalProperties: false stripped from all generated
schemas.
All Zod .describe() annotations and tool descriptions shortened.
Skill & tool description updates:

All references to the removed list_object_metadata_items tool replaced
with get_object_metadata / get_field_metadata across skill instructions,
dashboard tools, view filter/sort tools, and MCP server instructions.
This commit is contained in:
Etienne
2026-06-08 13:55:29 +02:00
committed by GitHub
parent afec1f1332
commit b56fea69aa
24 changed files with 656 additions and 219 deletions
@@ -14,7 +14,7 @@ export const buildMcpServerInstructions = (
``,
`Meta-tools (always available):`,
` execute_tool(toolName, arguments) — execute any CRUD or action tool by name`,
` learn_tools(toolNames) — fetch input schema for specific tools before calling them`,
` learn_tools(toolNames) — fetch input schemas before calling tools; pass ALL needed tool names in one call, not one call per tool`,
` load_skills(skillNames) — load step-by-step instructions for complex tasks`,
``,
...(skillNames ? [`Available skills: ${skillNames}.`, ``] : []),
@@ -26,6 +26,7 @@ export const buildMcpServerInstructions = (
` ACTION: http_request | send_email | draft_email | navigate_app | code_interpreter | search_help_center`,
` WORKFLOW: create_complete_workflow | create/update/delete_workflow_version_step | activate/deactivate_workflow_version`,
` METADATA: get/create/update/delete_object_metadata | get/create/update/delete_field_metadata`,
` Both GET tools return system items as compact summaries by default — keep that default for listing/inspecting; only set includeFullSystemObjects / includeFullSystemFields=true when you specifically need a system item's full configuration`,
` VIEW: get_views | get_view_query_parameters | create/update/delete_view | manage view fields, filters, sorts`,
` DASHBOARD: list_dashboards | get_dashboard | create_complete_dashboard | add/update/delete_dashboard_widget`,
` WEBHOOK: list/create/update/delete_webhook`,