Skip to content

Commit ed03bbf

Browse files
committed
improvement(tools): state every pinned param, not just the credential
Two agent tools bound to the same Gmail account but different labels reached the model byte-identical: every param a user fills is stripped from the schema, and only the credential was ever named in the description. The model could not tell Inbox from Sent, and with a single tool it could promise a caller it would search a folder that tool can never reach. Each tool now states the values the workflow pinned on it, whether or not it has a duplicate sibling. Opaque resource ids still resolve to a display name; plain values like a label, a row limit or a toggle need no lookup and are stated directly. Secrets never are: a field marked `password`, a hidden field, a secret-named param, and every literal on a tool whose params resolved an environment variable are all withheld.
1 parent b478c8a commit ed03bbf

9 files changed

Lines changed: 726 additions & 624 deletions

File tree

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ import type {
6868
ResolvedSecretInputPath,
6969
ResolvedSecretTraceRegistry,
7070
} from '@/executor/utils/resolved-secret-trace-registry'
71-
import { annotateDuplicateToolBindings } from '@/executor/utils/tool-binding-labels'
71+
import { annotateToolPinnedParams } from '@/executor/utils/tool-pinned-params'
7272
import { resolveVertexCredential } from '@/executor/utils/vertex-credential'
7373
import { executeProviderRequest } from '@/providers'
7474
import {
@@ -808,7 +808,11 @@ export class AgentBlockHandler implements BlockHandler {
808808
const tools = allTools.filter(
809809
(tool): tool is ProviderToolConfig => tool !== null && tool !== undefined
810810
)
811-
await annotateDuplicateToolBindings(ctx, tools)
811+
await annotateToolPinnedParams(ctx, tools, {
812+
// A tool whose params resolved an environment secret must not have its literal values
813+
// stated; the provenance map already identifies exactly those tools.
814+
hasResolvedSecretInputs: (tool) => inputProvenance.has(tool),
815+
})
812816
return { tools, inputProvenance }
813817
}
814818

apps/sim/executor/handlers/pi/local/sim-tools.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import type { PiToolResult, PiToolSpec } from '@/executor/handlers/pi/core/backe
1616
import type { ExecutionContext } from '@/executor/types'
1717
import { projectResolvedSecretModelContent } from '@/executor/utils/resolved-secret-content-projection'
1818
import type { ResolvedSecretTraceRegistry } from '@/executor/utils/resolved-secret-trace-registry'
19-
import { annotateDuplicateToolBindings } from '@/executor/utils/tool-binding-labels'
19+
import { annotateToolPinnedParams } from '@/executor/utils/tool-pinned-params'
2020
import { assignProviderToolIdentities } from '@/providers/tool-identity'
2121
import type { ProviderToolConfig } from '@/providers/types'
2222
import { transformBlockTool } from '@/providers/utils'
@@ -233,7 +233,13 @@ export async function buildSimToolSpecs(
233233
}
234234

235235
const providers = configuredTools.map(({ provider }) => provider)
236-
await annotateDuplicateToolBindings(ctx, providers)
236+
// Pi resolves secret provenance per tool CALL rather than per format, so it cannot say which
237+
// individual tool carries one. Withhold literal values for the whole run when any input
238+
// resolved a secret — coarse, but it errs toward stating less.
239+
const runResolvedSecrets = Boolean(ctx.resolvedSecretTraceRegistry?.hasResolvedInputProjections())
240+
await annotateToolPinnedParams(ctx, providers, {
241+
hasResolvedSecretInputs: () => runResolvedSecrets,
242+
})
237243
assignProviderToolIdentities(providers)
238244
return configuredTools.map(({ provider, toolIndex }) =>
239245
buildSimToolSpec(ctx, inputTools, provider, toolIndex)

apps/sim/executor/utils/tool-binding-labels.test.ts

Lines changed: 0 additions & 256 deletions
This file was deleted.

0 commit comments

Comments
 (0)