@@ -6,6 +6,7 @@ import { sleep } from '@sim/utils/helpers'
66import { isPlainRecord } from '@sim/utils/object'
77import { truncate } from '@sim/utils/string'
88import { and , eq , inArray , isNull } from 'drizzle-orm'
9+ import { isDev } from '@/lib/core/config/env-flags'
910import { normalizeStringRecord , normalizeWorkflowVariables } from '@/lib/core/utils/records'
1011import { createMcpToolId } from '@/lib/mcp/utils'
1112import {
@@ -67,7 +68,7 @@ import {
6768import { isAutoModel , SIM_AUTO_MODEL_ID } from '@/providers/models'
6869import { getProviderFromModel , transformBlockTool } from '@/providers/utils'
6970import type { SerializedBlock } from '@/serializer/types'
70- import { filterSchemaForLLM , type ToolSchema } from '@/tools/params'
71+ import { filterSchemaForLLM , type ToolSchema , ToolSchemaEnrichmentError } from '@/tools/params'
7172import { getTool } from '@/tools/utils'
7273import { getToolAsync } from '@/tools/utils.server'
7374
@@ -247,6 +248,32 @@ export class AgentBlockHandler implements BlockHandler {
247248 streaming : streamingConfig . shouldUseStreaming ?? false ,
248249 } )
249250
251+ if ( isDev ) {
252+ const tableQueryRowsV1Tools = formattedTools . filter ( ( tool ) => {
253+ const toolId = tool ?. id
254+ if ( typeof toolId !== 'string' ) return false
255+
256+ const isTableQueryRows =
257+ toolId === 'table_query_rows' || toolId . startsWith ( 'table_query_rows_' )
258+ const isV2 = toolId === 'table_query_rows_v2' || toolId . startsWith ( 'table_query_rows_v2_' )
259+ return isTableQueryRows && ! isV2
260+ } )
261+
262+ if ( tableQueryRowsV1Tools . length > 0 ) {
263+ logger . info ( 'Passing table_query_rows v1 tool schema to agent provider' , {
264+ blockId : block . id ,
265+ executionId : ctx . executionId ,
266+ providerId,
267+ model,
268+ tools : tableQueryRowsV1Tools . map ( ( tool ) => ( {
269+ id : tool . id ,
270+ description : tool . description ,
271+ parameters : tool . parameters ,
272+ } ) ) ,
273+ } )
274+ }
275+ }
276+
250277 const result = await this . executeProviderRequest ( ctx , providerRequest , block , responseFormat )
251278
252279 if ( autoRouting && autoRouting . billableRoutingCost > 0 ) {
@@ -526,6 +553,7 @@ export class AgentBlockHandler implements BlockHandler {
526553 }
527554 return this . transformBlockTool ( ctx , tool , canonicalModes , toolIndex )
528555 } catch ( error ) {
556+ if ( error instanceof ToolSchemaEnrichmentError ) throw error
529557 logger . error (
530558 '[AgentHandler] Error creating tool' ,
531559 projectAgentDiagnosticMetadata (
@@ -952,6 +980,12 @@ export class AgentBlockHandler implements BlockHandler {
952980 } ) ,
953981 getTool,
954982 canonicalModes,
983+ enrichmentContext : {
984+ workflowId : ctx . workflowId ,
985+ workspaceId : ctx . workspaceId ,
986+ executionId : ctx . executionId ,
987+ userId : ctx . userId ,
988+ } ,
955989 toolIndex,
956990 resolveCustomBlockBinding : ( blockType : string ) =>
957991 resolveCustomBlockToolBinding ( blockType , ctx . workspaceId ) ,
0 commit comments