Skip to content

Commit d4eb324

Browse files
committed
fix(agent): overly broad check for secrets protection
1 parent 2e7e5ae commit d4eb324

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

apps/sim/executor/handlers/agent/agent-handler.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3497,6 +3497,42 @@ describe('AgentBlockHandler', () => {
34973497
expect(tools[0].parameters.required).toContain('format')
34983498
})
34993499

3500+
it('resolves a secret-backed customToolId without exposing it to the provider', async () => {
3501+
const toolId = 'custom-tool-123'
3502+
mockDBForCustomTool(toolId)
3503+
const registry = new ResolvedSecretTraceRegistry([
3504+
{
3505+
name: 'CANARY_CUSTOM_TOOL_ID',
3506+
plaintext: toolId,
3507+
encryptedValue: 'encrypted-custom-tool-id',
3508+
},
3509+
])
3510+
const inputPath = ['tools', '0', 'customToolId'] as const
3511+
registry.recordResolvedAtInputPath('CANARY_CUSTOM_TOOL_ID', toolId, inputPath)
3512+
registry.recordResolvedInputProjection(inputPath, toolId, '{{CANARY_CUSTOM_TOOL_ID}}')
3513+
mockContext.resolvedSecretTraceRegistry = registry
3514+
3515+
await handler.execute(mockContext, mockBlock, {
3516+
model: 'gpt-4o',
3517+
userPrompt: 'Format a report',
3518+
apiKey: 'test-api-key',
3519+
tools: [
3520+
{
3521+
type: 'custom-tool',
3522+
customToolId: toolId,
3523+
usageControl: 'auto',
3524+
},
3525+
],
3526+
})
3527+
3528+
expect(mockGetCustomToolById).toHaveBeenCalledWith(expect.objectContaining({ toolId }))
3529+
const providerRequest = mockExecuteProviderRequest.mock.calls[0][1]
3530+
expect(providerRequest.tools).toHaveLength(1)
3531+
expect(providerRequest.tools[0].name).toBe('formatReport')
3532+
expect(JSON.stringify(providerRequest.tools)).not.toContain(toolId)
3533+
expect(JSON.stringify(providerRequest.tools)).not.toContain('CANARY_CUSTOM_TOOL_ID')
3534+
})
3535+
35003536
it('should fall back to inline schema when DB fetch fails and inline exists', async () => {
35013537
mockDBFailure()
35023538

apps/sim/executor/handlers/agent/agent-handler.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,6 @@ export class AgentBlockHandler implements BlockHandler {
628628
const root = ['tools', String(toolIndex)] as const
629629
const paths: ResolvedSecretInputPath[] = [[...root, 'type']]
630630
if (tool.operation !== undefined) paths.push([...root, 'operation'])
631-
if (tool.customToolId !== undefined) paths.push([...root, 'customToolId'])
632631
if (tool.type === 'mcp') {
633632
paths.push([...root, 'params', 'serverId'], [...root, 'params', 'toolName'])
634633
}

0 commit comments

Comments
 (0)