fix(ai) - optim (#21233)
1. tool-registry.service.ts, Pass precomputed catalog to resolveSchemas() resolveSchemas() now accepts an optional precomputedCatalog parameter. Both getToolsByName() and getToolInfo() pass the catalog they already fetched, eliminating a redundant getCatalog() rebuild inside resolveSchemas(). 2. database-tool.provider.ts, Skip field lookup when schemas=false When building the catalog index (includeSchemas=false), getFlatFieldsFromFlatObjectMetadata() is no longer called for each of the 25 objects. The hasGroupByToolInputSchema() check is also skipped, group_by tools are always included in the index, with the real eligibility check deferred to learn_tools time. --> 100/150ms gain on learn/execute_tool execution
This commit is contained in:
+5
-3
@@ -44,6 +44,8 @@ export const buildMcpServerInstructions = (
|
||||
` Single record by id → find_one_{object}`,
|
||||
` Analytics / grouped metrics → group_by_{objects} (COUNT, SUM, AVG, MIN, MAX)`,
|
||||
` Multiple metrics → run parallel group_by calls, merge results`,
|
||||
` Per-record updates (different data per record) → find_many_{objects} first, then upsert_many_{objects} with each record's id (or other unique identifier) and new values`,
|
||||
` Bulk update (same data for all) → update_many_{objects}`,
|
||||
` Non-CRUD task → use tool name from the list above + learn_tools for schema`,
|
||||
``,
|
||||
`Execution rules:`,
|
||||
@@ -53,10 +55,10 @@ export const buildMcpServerInstructions = (
|
||||
`Data efficiency:`,
|
||||
` Default limit: 10. Only increase if user explicitly needs more.`,
|
||||
` Always apply filters to narrow results — don't fetch all records of a type.`,
|
||||
` Use batch tools (create_many_*, update_many_*) instead of looping single-item calls.`,
|
||||
` Use batch tools (create_many_*, upsert_many_*, update_many_*) instead of looping single-item calls.`,
|
||||
``,
|
||||
`Destructive operations (update_many, delete):`,
|
||||
` 1. Run find_{objects} with the same filter — state record count to user`,
|
||||
`Destructive operations (delete_one, delete_many):`,
|
||||
` 1. Run find_many_{objects} with the same filter — state record count to user`,
|
||||
` 2. Wait for explicit confirmation before executing`,
|
||||
``,
|
||||
`Twenty primitives:`,
|
||||
|
||||
Reference in New Issue
Block a user