Skip to content

Commit 1d9a7fe

Browse files
committed
Possible fix for max mode not showing which option selected
1 parent 5b04278 commit 1d9a7fe

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

cli/src/components/blocks/agent-branch-wrapper.tsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import type {
3636
ContentBlock,
3737
TextContentBlock,
3838
HtmlContentBlock,
39+
ToolContentBlock,
3940
} from '../../types/chat'
4041
import type { MarkdownPalette } from '../../utils/markdown-renderer'
4142

@@ -347,25 +348,28 @@ export const AgentBranchWrapper = memo(
347348
const isComplete = agentBlock.status === 'complete'
348349
if (isComplete && siblingBlocks) {
349350
const blocks = agentBlock.blocks ?? []
350-
const lastBlock = blocks[blocks.length - 1] as
351-
| { input: { implementationId: string; reason: string } }
352-
| undefined
353-
const implementationId = lastBlock?.input?.implementationId
351+
// Find the set_output tool call block (not necessarily the last block)
352+
const setOutputBlock = blocks.find(
353+
(b): b is ToolContentBlock =>
354+
b.type === 'tool' && b.toolName === 'set_output',
355+
)
356+
const implementationId = setOutputBlock?.input?.implementationId as string | undefined
354357
if (implementationId) {
355358
const letterIndex = implementationId.charCodeAt(0) - 65
356359
const implementors = siblingBlocks.filter(
357360
(b): b is AgentContentBlock =>
358361
b.type === 'agent' && isImplementorAgent(b),
359362
)
360363

364+
reason = setOutputBlock?.input?.reason as string | undefined
365+
361366
const selectedAgent = implementors[letterIndex]
362367
if (selectedAgent) {
363368
const index = getImplementorIndex(selectedAgent, siblingBlocks)
364369
statusText =
365370
index !== undefined
366371
? `Selected Strategy #${index + 1}`
367372
: 'Selected'
368-
reason = lastBlock?.input?.reason
369373
}
370374
}
371375
}

0 commit comments

Comments
 (0)