Skip to content

Pass down ToolCall.id to the tool function #10201

@datbth

Description

@datbth

Is your feature request related to a problem? Please describe.
I'm displaying a tree of tool calls (i.e. a tool can call its sub-tools or sub-agents), so I need a way for sub-tool calls to refer to their parent tool call.
While there are various ways to generate a UUID and pass it down to tool functions, it is not feasible to persist those IDs into the ChatMessages => It's not feasible to reconstruct the conversation UI from the result ChatMessages.

Imagine a UI that displays:

  1. User message
  2. Assistant message 1
  3. Tool 1
    i. Tool 1a
    ii. Tool 1b
  4. Assistant message 2
  5. Tool 2

=> Need a way to persist Tool 1a and Tool 1b that can

  • Link them to their parent: Tool 1
  • Reconstruct the whole conversation (including User message, Assistant message 1, Assistant message 2) in the correct order

Describe the solution you'd like
Either

  • Pass down the LLM's tool call id to the tool function
    • As direct argument. Here is my monkey-patch: Image
    • Or as context variable
  • Or provide a way for the tool function to save additional details to the ChatMessage's meta

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions