@@ -5,6 +5,7 @@ import { toError } from '@sim/utils/errors'
55import { sleep } from '@sim/utils/helpers'
66import { truncate } from '@sim/utils/string'
77import { and , eq , inArray , isNull } from 'drizzle-orm'
8+ import { isDev } from '@/lib/core/config/env-flags'
89import { normalizeStringRecord , normalizeWorkflowVariables } from '@/lib/core/utils/records'
910import { createMcpToolId } from '@/lib/mcp/utils'
1011import {
@@ -65,7 +66,7 @@ import {
6566import { isAutoModel , SIM_AUTO_MODEL_ID } from '@/providers/models'
6667import { getProviderFromModel , transformBlockTool } from '@/providers/utils'
6768import type { SerializedBlock } from '@/serializer/types'
68- import { filterSchemaForLLM , type ToolSchema } from '@/tools/params'
69+ import { filterSchemaForLLM , type ToolSchema , ToolSchemaEnrichmentError } from '@/tools/params'
6970import { getTool } from '@/tools/utils'
7071import { getToolAsync } from '@/tools/utils.server'
7172
@@ -182,6 +183,32 @@ export class AgentBlockHandler implements BlockHandler {
182183 streaming : streamingConfig . shouldUseStreaming ?? false ,
183184 } )
184185
186+ if ( isDev ) {
187+ const tableQueryRowsV1Tools = formattedTools . filter ( ( tool ) => {
188+ const toolId = tool ?. id
189+ if ( typeof toolId !== 'string' ) return false
190+
191+ const isTableQueryRows =
192+ toolId === 'table_query_rows' || toolId . startsWith ( 'table_query_rows_' )
193+ const isV2 = toolId === 'table_query_rows_v2' || toolId . startsWith ( 'table_query_rows_v2_' )
194+ return isTableQueryRows && ! isV2
195+ } )
196+
197+ if ( tableQueryRowsV1Tools . length > 0 ) {
198+ logger . info ( 'Passing table_query_rows v1 tool schema to agent provider' , {
199+ blockId : block . id ,
200+ executionId : ctx . executionId ,
201+ providerId,
202+ model,
203+ tools : tableQueryRowsV1Tools . map ( ( tool ) => ( {
204+ id : tool . id ,
205+ description : tool . description ,
206+ parameters : tool . parameters ,
207+ } ) ) ,
208+ } )
209+ }
210+ }
211+
185212 const result = await this . executeProviderRequest ( ctx , providerRequest , block , responseFormat )
186213
187214 if ( autoRouting && autoRouting . billableRoutingCost > 0 ) {
@@ -454,6 +481,7 @@ export class AgentBlockHandler implements BlockHandler {
454481 }
455482 return this . transformBlockTool ( ctx , tool , canonicalModes , toolIndex )
456483 } catch ( error ) {
484+ if ( error instanceof ToolSchemaEnrichmentError ) throw error
457485 logger . error ( `[AgentHandler] Error creating tool:` , { tool, error } )
458486 return null
459487 }
@@ -783,6 +811,12 @@ export class AgentBlockHandler implements BlockHandler {
783811 } ) ,
784812 getTool,
785813 canonicalModes,
814+ enrichmentContext : {
815+ workflowId : ctx . workflowId ,
816+ workspaceId : ctx . workspaceId ,
817+ executionId : ctx . executionId ,
818+ userId : ctx . userId ,
819+ } ,
786820 toolIndex,
787821 resolveCustomBlockBinding : ( blockType : string ) =>
788822 resolveCustomBlockToolBinding ( blockType , ctx . workspaceId ) ,
0 commit comments