Skip to content

add tool call meta to handlers #5169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

add tool call meta to handlers #5169

wants to merge 2 commits into from

Conversation

IMax153
Copy link
Member

@IMax153 IMax153 commented Jul 5, 2025

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Allows for accessing tool call metadata within the tool call handler:

const DadJokeToolHandlers = DadJokeTools.toLayer(
  Effect.gen(function*() {
    const icanhazdadjoke = yield* ICanHazDadJoke
    return {
      GetDadJoke: ({ searchTerm }, meta) => {
        // At the moment, the `meta` contains the tool name and id, but
        // can be further augmented in the future
        console.log(meta)
        return icanhazdadjoke.search(searchTerm)
      }
    }
  })
).pipe(Layer.provide(ICanHazDadJoke.Default))

Related

  • Related Issue #
  • Closes #

@github-project-automation github-project-automation bot moved this to Discussion Ongoing in PR Backlog Jul 5, 2025
Copy link

changeset-bot bot commented Jul 5, 2025

⚠️ No Changeset found

Latest commit: aa383a2

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@@ -632,7 +632,7 @@ export const registerToolkit: <Tools extends AiTool.Any>(toolkit: AiToolkit.AiTo
yield* registry.addTool({
tool: mcpTool,
handle(payload) {
return built.handle(tool.name as any, payload).pipe(
return built.handle("", tool.name as any, payload).pipe(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In particular, this feels bad to me.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn’t the rpc request id be fine here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be if that's what we would like

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Discussion Ongoing
Development

Successfully merging this pull request may close these issues.

2 participants