Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions apps/sim/lib/copilot/tools/server/workflow/edit-workflow/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
} from './lint'
import { type EditWorkflowParams, isDeferredSkippedItem, type ValidationError } from './types'
import {
collectUnresolvedAgentToolReferences,
collectUnresolvedReferences,
preValidateCredentialInputs,
UNRESOLVABLE_AT_LINT_NOTE,
Expand Down Expand Up @@ -190,6 +191,31 @@ export const editWorkflowServerTool: BaseServerTool<EditWorkflowParams, unknown>
error: toError(error).message,
})
}

// Resolve agent-block tool/skill references (custom tools, MCP servers,
// skills). A well-shaped entry whose id does not resolve is dropped at
// runtime, so the agent silently loses the tool/skill - surface it through
// the same lint + input-validation channels as credential/resource refs.
try {
const toolReferences = await collectUnresolvedAgentToolReferences(modifiedWorkflowState, {
userId: context.userId,
workspaceId,
})
unresolvedReferences.push(...toolReferences)
validationErrors.push(
...toolReferences.map((ref) => ({
blockId: ref.blockId,
blockType: ref.blockType ?? 'agent',
field: ref.field,
value: ref.value,
error: ref.reason,
}))
)
} catch (error) {
logger.warn('Agent tool/skill reference validation failed', {
error: toError(error).message,
})
}
}

// Validate the workflow state
Expand Down
22 changes: 18 additions & 4 deletions apps/sim/lib/copilot/tools/server/workflow/edit-workflow/lint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@ export interface WorkflowLintFieldIssue extends WorkflowLintBlockRef {
inactiveModeValues: InactiveModeValue[]
}

/** Tier-2 (async, DB) credential/resource reference that does not resolve to an accessible entity. */
/** Tier-2 (async, DB) reference that does not resolve to an accessible entity. */
export interface WorkflowLintUnresolvedReference extends WorkflowLintBlockRef {
field: string
value: string | string[]
kind: 'credential' | 'resource'
kind: 'credential' | 'resource' | 'custom-tool' | 'mcp-tool' | 'skill'
reason: string
}

Expand Down Expand Up @@ -351,9 +351,23 @@ export function formatWorkflowLintMessage(lint: WorkflowLintIssueView) {
}

const unresolved = lint.unresolvedReferences ?? []
if (unresolved.length > 0) {
const credResourceRefs = unresolved.filter(
(ref) => ref.kind === 'credential' || ref.kind === 'resource'
)
if (credResourceRefs.length > 0) {
parts.push(
`Credential/resource references that do not resolve: ${credResourceRefs
.map((ref) => `"${ref.blockName || ref.blockId}".${ref.field} (${ref.reason})`)
.join(', ')}`
)
}

const toolSkillRefs = unresolved.filter(
(ref) => ref.kind === 'custom-tool' || ref.kind === 'mcp-tool' || ref.kind === 'skill'
)
if (toolSkillRefs.length > 0) {
parts.push(
`Credential/resource references that do not resolve: ${unresolved
`Agent tool/skill references that do not resolve (they will not attach at runtime): ${toolSkillRefs
.map((ref) => `"${ref.blockName || ref.blockId}".${ref.field} (${ref.reason})`)
.join(', ')}`
)
Expand Down
Loading
Loading