Scope grouped background verdicts by execution step

This commit is contained in:
Marco Beretta 2026-09-06 03:40:46 +02:00
parent 5f9315e944
commit e3806c338d
No known key found for this signature in database
GPG key ID: D918033D8E74CC11
2 changed files with 54 additions and 2 deletions

View file

@ -149,11 +149,15 @@ function getToolMeta(
* folds that marker in as `extraError`, so without it here the group
* reported no failed action beside a card showing failure. Correlated the
* same way the child is, since provider tool-call ids repeat across agents
* in handoff responses. */
* and execution steps in handoff responses. */
const backgroundFailed =
parseBackgroundHandle(tc.output) != null &&
splitBackgroundAttachments(
filterAttachmentsForPart(attachmentsByToolCallId?.[tc.id ?? ''], tc.agentId),
filterAttachmentsForPart(
attachmentsByToolCallId?.[tc.id ?? ''],
tc.agentId,
toolCall.stepId,
),
tc.id,
).backgroundStatus === 'error';
return {

View file

@ -824,6 +824,54 @@ describe('ToolCallGroup image hoisting', () => {
).toBeInTheDocument();
});
it('counts background failures per step when provider call IDs repeat', () => {
const executions = [
{ stepId: 'step-success', status: 'completed' },
{ stepId: 'step-failure', status: 'error' },
];
const groupAttachments = executions.map(({ stepId, status }) => ({
type: 'background_task_status',
messageId: 'message-1',
toolCallId: 'call_0',
agentId: 'agent-a',
stepId,
status,
})) as unknown as TAttachment[];
const props = {
...baseProps,
groupAttachments,
parts: executions.map(({ stepId }, idx) => ({
idx,
part: {
type: ContentTypes.TOOL_CALL,
[ContentTypes.TOOL_CALL]: {
id: 'call_0',
name: 'execute_code',
args: '{}',
agentId: 'agent-a',
stepId,
runStepStatus: 'completed',
output: JSON.stringify({
background_task_id: stepId,
tool: 'execute_code',
status: 'running',
message: 'Use check_background_task to poll.',
}),
},
} as unknown as TMessageContentParts,
})),
};
const { rerender } = renderGroup(props);
expect(screen.getByRole('button', { name: /· 1 failed$/ })).toBeInTheDocument();
rerender(
<RecoilRoot>
<ToolCallGroup {...props} groupAttachments={[...groupAttachments].reverse()} />
</RecoilRoot>,
);
expect(screen.getByRole('button', { name: /· 1 failed$/ })).toBeInTheDocument();
});
it('honors a terminal failed run step whose output reads as benign', () => {
const closedFailure = {
type: ContentTypes.TOOL_CALL,