-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Description
Summary
Special tools (think, readPdfFile, readImageFile) currently block parallel tool call execution. When an LLM returns multiple tool calls including a special tool, only the special tool is executed and others are dropped.
Background
- Past constraint: Tool results couldn't include base64-encoded PDF/image data directly
- Current state: Vercel AI SDK 5.0+ and Anthropic API (Feb 2025) now support PDF/images in tool results
- Perstack version: Using AI SDK v5.0.104, which includes this support
Current Implementation Issues
calling-tool.ts: Special tools (think,readPdfFile,readImageFile) are prioritized and return early, dropping other parallel tool callsresolvingPdfFileLogic: Adds PDF touserMessageinstead oftoolMessage(legacy workaround)createToolMessage: Type doesn't includeFileInlinePartfor PDFstoolResultPartToCoreToolResultPart: No handling forfileInlinePart
Proposed Changes
1. Update message handling for PDF support
- Extend
createToolMessagetype to supportFileInlinePart - Update
toolResultPartToCoreToolResultPartto convertfileInlineParttomediatype - Modify
resolvingPdfFileLogicto include PDF intoolMessage(notuserMessage)
2. Simplify tool execution flow
Before:
attemptCompletion → single execution (others ignored)
think → single execution (others ignored)
readPdfFile → single execution (others ignored)
readImageFile → single execution (others ignored)
MCP tools → parallel execution
delegate/interactive → sequential after MCP
After:
attemptCompletion → single execution (others ignored, completion means done)
All other MCP tools (think, readPdfFile, readImageFile, etc.) → parallel execution
delegate/interactive → sequential after MCP parallel execution
3. Consider state machine simplification
With unified tool result handling, ResolvingPdfFile, ResolvingImageFile, and ResolvingThought states may be consolidatable into ResolvingToolResult.
Tasks
- Extend
createToolMessagetype to includeFileInlinePart - Update
toolResultPartToCoreToolResultPartforfileInlinePart - Refactor
resolvingPdfFileLogicto usetoolMessage - Modify
calling-tool.tsto parallelize all MCP tools exceptattemptCompletion - Update tests
- Evaluate state machine simplification (may be separate PR)
Related
- PR Add: Parallel tool call support #62 (Parallel tool call support)
- Vercel AI SDK PR #9733 (PDF/image support in tool results)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels