Skip to content

Expose tool call id to tool function for corellating with streaming items #412

@chernetsov

Description

@chernetsov

To optimize latency we are hooking up to streaming tool call parameter items from the model to frontload some processing (e.g. if tool arguments have an array we could process items from this array as they stream in). To correlate this processing back to tool call function invocation happening later we would need tool call id which is currently not exposed to tool call function.

Could we please expose call id as a third FunctionTool.invoke argument?

export type FunctionTool<
  Context = UnknownContext,
  TParameters extends ToolInputParameters = undefined,
  Result = unknown,
> = {

...

  /**
   * The function to invoke when the tool is called.
   */
  invoke: (
    runContext: RunContext<Context>,
    input: string,
    callId: string,
  ) => Promise<string | Result>;

...

};

I am happy to draft a PR, but wanted to discuss first. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions