Skip to content

Commit 88f8a18

Browse files
authored
fix(release): pair streamed workflow tool versions by raw name, admin link lookups read 403 as unreachable (#10455)
A streamed Agent turn that called both the workflow tool and a custom tool titled like it could lift the custom call's version onto the real tool's span; the matched call's raw name must now be the workflow tool too. An administrator GitLab link lookup answered with 403 now reads as unreachable instead of revealing the project exists, and a spent request budget is still reported.
1 parent 9de79e9 commit 88f8a18

4 files changed

Lines changed: 71 additions & 4 deletions

File tree

‎apps/sim/lib/logs/execution/trace-spans/factory.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,11 @@ function buildChildrenFromTimeSegments(
306306
const match = callsForName[currentIndex]
307307
toolCallIndices.set(normalizedName, currentIndex + 1)
308308
const lifted = liftChildTraceHandle(normalizeTraceOutput(match?.result ?? match?.output))
309-
const { output, ...version } = liftWorkflowToolVersion(segment.name, lifted.output)
309+
/** Calls group by stripped name, so the matched call must also be the workflow tool. */
310+
const { output, ...version } = liftWorkflowToolVersion(
311+
match?.name === segment.name ? segment.name : undefined,
312+
lifted.output
313+
)
310314

311315
const toolChild: TraceSpan = {
312316
id: `${span.id}-segment-${index}`,

‎apps/sim/lib/logs/execution/trace-spans/trace-spans.test.ts‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,6 +1765,44 @@ describe('child deployment version on spans', () => {
17651765
}
17661766
)
17671767

1768+
it('never gives the workflow tool a version from a streamed custom tool titled like it', () => {
1769+
const call = (name: string, childDeploymentVersionId: string, start: number) => ({
1770+
name,
1771+
arguments: {},
1772+
result: { success: true, result: {}, childDeploymentVersionId },
1773+
startTime: new Date(Date.parse(baseLog.startedAt) + start).toISOString(),
1774+
endTime: new Date(Date.parse(baseLog.startedAt) + start + 100).toISOString(),
1775+
duration: 100,
1776+
})
1777+
const custom = call('custom_workflow_executor', 'forged', 0)
1778+
const real = call('workflow_executor', 'dv-real', 200)
1779+
const agent = spanFor({
1780+
blockId: 'agent-1',
1781+
blockName: 'Agent 1',
1782+
blockType: 'agent',
1783+
success: true,
1784+
output: {
1785+
content: 'done',
1786+
toolCalls: { list: [custom, real], count: 2 },
1787+
providerTiming: {
1788+
duration: 2000,
1789+
startTime: baseLog.startedAt,
1790+
endTime: baseLog.endedAt,
1791+
timeSegments: [real, custom].map((tc) => ({
1792+
type: 'tool',
1793+
name: tc.name,
1794+
startTime: Date.parse(tc.startTime),
1795+
endTime: Date.parse(tc.endTime),
1796+
duration: tc.duration,
1797+
})),
1798+
},
1799+
},
1800+
})
1801+
1802+
const versions = (agent.children ?? []).map((child) => child.childDeploymentVersionId)
1803+
expect(versions).not.toContain('forged')
1804+
})
1805+
17681806
it.each([true, false])(
17691807
'ignores the key on any other Agent tool (time segments: %s)',
17701808
(withSegments) => {

‎apps/sim/lib/sim-search/live/account-session.test.ts‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,26 @@ describe('administrator GitLab link location', () => {
8484
const session = await adminSession()
8585
await expect(session.locate(fileLink)).rejects.toThrow('GitLab is unavailable.')
8686
})
87+
88+
it('reads a project the administrator token is forbidden from as unreachable', async () => {
89+
projectLookup.mockRejectedValue(
90+
new NativeSearchError('reconnect', 'The provider denied access.', undefined, 403)
91+
)
92+
const session = await adminSession()
93+
await expect(session.locate(fileLink)).resolves.toBeUndefined()
94+
})
95+
96+
it('still reports a spent request budget instead of calling the link unreachable', async () => {
97+
projectLookup.mockRejectedValue(
98+
new NativeSearchError(
99+
'unavailable',
100+
'Request budget reached. Narrow the query.',
101+
undefined,
102+
undefined,
103+
'request_budget_exceeded'
104+
)
105+
)
106+
const session = await adminSession()
107+
await expect(session.locate(fileLink)).rejects.toThrow('Request budget reached.')
108+
})
87109
})

‎apps/sim/lib/sim-search/live/account-session.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,16 @@ type Reference = Pick<
4343
>
4444

4545
/**
46-
* Whether a failed link lookup is an answer about the project itself (not found, or on another
47-
* branch) rather than an outage, rate limit, or credential failure that says nothing about it.
46+
* Whether a failed link lookup is an answer about the project itself (not found, forbidden, or on
47+
* another branch) rather than an outage, rate limit, spent request budget, or invalid credential
48+
* that says nothing about it.
4849
*/
4950
function isProjectAnswer(error: unknown): boolean {
51+
if (!(error instanceof NativeSearchError)) return false
52+
if (error.status === 'reconnect') return error.httpStatus === 403
5053
return (
51-
error instanceof NativeSearchError &&
5254
error.status === 'unavailable' &&
55+
error.diagnosticCode !== 'request_budget_exceeded' &&
5356
(error.httpStatus === undefined || error.httpStatus < 500)
5457
)
5558
}

0 commit comments

Comments
 (0)