Skip to content
Merged
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
6 changes: 5 additions & 1 deletion apps/sim/lib/logs/execution/trace-spans/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,11 @@ function buildChildrenFromTimeSegments(
const match = callsForName[currentIndex]
toolCallIndices.set(normalizedName, currentIndex + 1)
const lifted = liftChildTraceHandle(normalizeTraceOutput(match?.result ?? match?.output))
const { output, ...version } = liftWorkflowToolVersion(segment.name, lifted.output)
/** Calls group by stripped name, so the matched call must also be the workflow tool. */
const { output, ...version } = liftWorkflowToolVersion(
match?.name === segment.name ? segment.name : undefined,
lifted.output
)

const toolChild: TraceSpan = {
id: `${span.id}-segment-${index}`,
Expand Down
38 changes: 38 additions & 0 deletions apps/sim/lib/logs/execution/trace-spans/trace-spans.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1765,6 +1765,44 @@ describe('child deployment version on spans', () => {
}
)

it('never gives the workflow tool a version from a streamed custom tool titled like it', () => {
const call = (name: string, childDeploymentVersionId: string, start: number) => ({
name,
arguments: {},
result: { success: true, result: {}, childDeploymentVersionId },
startTime: new Date(Date.parse(baseLog.startedAt) + start).toISOString(),
endTime: new Date(Date.parse(baseLog.startedAt) + start + 100).toISOString(),
duration: 100,
})
const custom = call('custom_workflow_executor', 'forged', 0)
const real = call('workflow_executor', 'dv-real', 200)
const agent = spanFor({
blockId: 'agent-1',
blockName: 'Agent 1',
blockType: 'agent',
success: true,
output: {
content: 'done',
toolCalls: { list: [custom, real], count: 2 },
providerTiming: {
duration: 2000,
startTime: baseLog.startedAt,
endTime: baseLog.endedAt,
timeSegments: [real, custom].map((tc) => ({
type: 'tool',
name: tc.name,
startTime: Date.parse(tc.startTime),
endTime: Date.parse(tc.endTime),
duration: tc.duration,
})),
},
},
})

const versions = (agent.children ?? []).map((child) => child.childDeploymentVersionId)
expect(versions).not.toContain('forged')
})

it.each([true, false])(
'ignores the key on any other Agent tool (time segments: %s)',
(withSegments) => {
Expand Down
22 changes: 22 additions & 0 deletions apps/sim/lib/sim-search/live/account-session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,26 @@ describe('administrator GitLab link location', () => {
const session = await adminSession()
await expect(session.locate(fileLink)).rejects.toThrow('GitLab is unavailable.')
})

it('reads a project the administrator token is forbidden from as unreachable', async () => {
projectLookup.mockRejectedValue(
new NativeSearchError('reconnect', 'The provider denied access.', undefined, 403)
)
const session = await adminSession()
await expect(session.locate(fileLink)).resolves.toBeUndefined()
})

it('still reports a spent request budget instead of calling the link unreachable', async () => {
projectLookup.mockRejectedValue(
new NativeSearchError(
'unavailable',
'Request budget reached. Narrow the query.',
undefined,
undefined,
'request_budget_exceeded'
)
)
const session = await adminSession()
await expect(session.locate(fileLink)).rejects.toThrow('Request budget reached.')
})
})
9 changes: 6 additions & 3 deletions apps/sim/lib/sim-search/live/account-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,16 @@ type Reference = Pick<
>

/**
* Whether a failed link lookup is an answer about the project itself (not found, or on another
* branch) rather than an outage, rate limit, or credential failure that says nothing about it.
* Whether a failed link lookup is an answer about the project itself (not found, forbidden, or on
* another branch) rather than an outage, rate limit, spent request budget, or invalid credential
* that says nothing about it.
*/
function isProjectAnswer(error: unknown): boolean {
if (!(error instanceof NativeSearchError)) return false
if (error.status === 'reconnect') return error.httpStatus === 403
return (
error instanceof NativeSearchError &&
error.status === 'unavailable' &&
error.diagnosticCode !== 'request_budget_exceeded' &&
(error.httpStatus === undefined || error.httpStatus < 500)
)
}
Expand Down
Loading