-
Notifications
You must be signed in to change notification settings - Fork 3.7k
fix(agent): scope nested tool canonical-mode overrides by instance, not type #5534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging
Are you sure you want to change the base?
Changes from all commits
0b9019d
a54dcbe
28af223
d889f32
316bc8c
3f508e4
d6ec115
d7da35b
cf233bb
f8f3758
3c8bb40
d33acf4
4f40c4c
cbfab1c
4309d06
8b57476
e3d0e74
0ac0539
3838b6e
fc07922
3a1b1a8
46ffc49
010435c
c0bc62c
387cc97
2dbc7fd
8a50f18
dcf3302
bc09865
5f56e46
ca3bbf1
bbf400f
7c619e7
64cfda5
7ca736a
6066fc1
3422f64
595c4c3
d6c1bc2
58a3ae2
489f2d3
6aa3fe3
ecbf5e5
2aaf2b7
d445b9c
4bc6a17
5be12f8
4253e57
8d6b615
efcd51a
8d934f3
5ea80a8
3cc581e
273e608
07b8f1b
dcaf3e9
6aeb981
3e9849b
64d855a
ab156b5
c09a2c9
6a5eebc
4efe999
f69a9a0
db7f1c1
dbe8e51
11bcb8f
d14af04
e6b3cce
97a609a
fde70e2
e9ee351
b5b2d83
f6c9998
e532e0a
fd19470
856182b
6bf9e96
503432c
a8dcdd5
2f1f633
e32699d
12ada0c
e8f09ae
3ba8668
1192e20
1ce8e92
0c2df1e
7ffc495
d4722f9
f4d22ff
a48b4a1
79d98b3
e6587ca
8c3706e
59d9496
56a88a2
db47da5
8df34a3
aaca750
ad0b867
11168f9
613e8ea
38c088a
0371856
fabf696
6e426f8
62ef96f
4fcfe76
8afc4f1
616a71d
62d3140
21ee602
9d44d42
9f47896
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -512,11 +512,11 @@ export const ToolInput = memo(function ToolInput({ | |
| // Uses canonical resolution so the active field (basic vs advanced) is respected. | ||
| const toolCredentialId = useMemo(() => { | ||
| const allBlocks = getAllBlocks() | ||
| for (const tool of selectedTools) { | ||
| for (const [toolIndex, tool] of selectedTools.entries()) { | ||
| const blockConfig = allBlocks.find((b: { type: string }) => b.type === tool.type) | ||
| if (!blockConfig?.subBlocks) continue | ||
| const toolCanonical = buildCanonicalIndex(blockConfig.subBlocks) | ||
| const scopedOverrides = scopeCanonicalModesForTool(canonicalModeOverrides, tool.type) | ||
| const scopedOverrides = scopeCanonicalModesForTool(canonicalModeOverrides, toolIndex) | ||
| const reactiveSubBlock = blockConfig.subBlocks.find( | ||
| (sb: { reactiveCondition?: unknown }) => sb.reactiveCondition | ||
| ) | ||
|
|
@@ -1680,7 +1680,7 @@ export const ToolInput = memo(function ToolInput({ | |
| }) | ||
| : null | ||
|
|
||
| const toolScopedOverrides = scopeCanonicalModesForTool(canonicalModeOverrides, tool.type) | ||
| const toolScopedOverrides = scopeCanonicalModesForTool(canonicalModeOverrides, toolIndex) | ||
|
|
||
| const subBlocksResult: SubBlocksForToolInput | null = | ||
| !isCustomTool && !isMcpTool && currentToolId | ||
|
|
@@ -2072,7 +2072,7 @@ export const ToolInput = memo(function ToolInput({ | |
| const nextMode = canonicalMode === 'advanced' ? 'basic' : 'advanced' | ||
| collaborativeSetBlockCanonicalMode( | ||
| blockId, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When a user reorders or removes tools, the tool-input array changes but |
||
| `${tool.type}:${canonicalId}`, | ||
| `${toolIndex}:${canonicalId}`, | ||
| nextMode | ||
| ) | ||
| }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -260,18 +260,20 @@ export function resolveActiveCanonicalValue( | |
| } | ||
|
|
||
| /** | ||
| * Strip the `${toolType}:` prefix from canonical-mode override keys, returning the overrides for a | ||
| * Strip the `${toolIndex}:` prefix from canonical-mode override keys, returning the overrides for a | ||
| * nested tool keyed by bare `canonicalId`. An agent block stores its nested tools' modes scoped as | ||
| * `${toolType}:${canonicalId}` (to avoid cross-tool collisions when tools share a `canonicalParamId`), | ||
| * so this is the canonical un-scoping primitive. Returns `undefined` when there are no overrides, no | ||
| * `toolType`, or no matching keys. | ||
| * `${toolIndex}:${canonicalId}` — keyed by the tool's position in the `tool-input` array, not its | ||
| * `type` — so that two tool entries of the SAME type (e.g. two Table tools on one Agent block) get | ||
| * independent canonical modes instead of colliding on a shared `${toolType}:${canonicalId}` key. This | ||
| * is the canonical un-scoping primitive. Returns `undefined` when there are no overrides, no | ||
| * `toolIndex`, or no matching keys. | ||
| */ | ||
| export function scopeCanonicalModesForTool( | ||
| overrides: CanonicalModeOverrides | undefined, | ||
| toolType: string | undefined | ||
| toolIndex: number | undefined | ||
| ): CanonicalModeOverrides | undefined { | ||
| if (!overrides || !toolType) return undefined | ||
| const prefix = `${toolType}:` | ||
| if (!overrides || toolIndex === undefined) return undefined | ||
| const prefix = `${toolIndex}:` | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Legacy override keys ignoredMedium Severity Persisted agent blocks may still store nested tool canonical modes under the old Reviewed by Cursor Bugbot for commit 9f47896. Configure here. |
||
| let scoped: CanonicalModeOverrides | undefined | ||
| for (const [key, value] of Object.entries(overrides)) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Existing workflows can still have nested tool overrides stored as |
||
| if (key.startsWith(prefix) && value) { | ||
|
|
||


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stale modes after tool removal
Medium Severity
Canonical-mode overrides are now keyed by each tool’s array index (
${toolIndex}:${canonicalId}), but removing a tool only updates thetoolslist and leavesblock.data.canonicalModesunchanged. After a delete, surviving tools keep their old indices in storage while the UI and executor resolve modes by the new positions, so basic/advanced toggles and runtime param resolution can attach the wrong mode to the wrong instance.Additional Locations (1)
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/tool-input/tool-input.tsx#L906-L913Reviewed by Cursor Bugbot for commit 9f47896. Configure here.