Skip to content

Add toolCallId and toolName to stream part of type "error" #2578

Closed
@asasvirtuais

Description

@asasvirtuais

Feature Description

When iterating through TextStreamPart(s) and handling parts of type "error", I'd expect access to the toolCallId or the toolName from within the error chunk. Since those are not being passed down to the errors at:
run-tools-transformation.ts#L86-L202

Use Case

Simply to pass the toolCallId and toolName to a new message "tool-result" with isError set to true.

{
    type: 'tool-result',
    isError: true,
    toolCallId: error.toolCallId,
    toolName: error.toolName,
    result: part.error,
}

Additional context

If this makes sense for you, I am willing to help with the code edits.

Question:
Is chunk.toolName and chunk.toolCallId guaranteed in the context of the lines I highlighted?

If chunk has those attributes, can't we just wrap everything in a big try/catch with a generic ToolError? Or is that too stupid?

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai/corebugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions