Skip to content

Conversation

@ahmedrowaihi
Copy link

🎯 Changes

Supporting context in tool execution..

to make tools behaviour context aware, the only way is to reconstruct them everytime you want to invoke a new trigger..
this PR suggests supporting context.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.
  • I have tested this code locally with pnpm run test:lib.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

@ahmedrowaihi
Copy link
Author

this was my initial thought, feel free to suggest enhancement or if there is a better way

@AlemTuzlak AlemTuzlak requested a review from jherr December 5, 2025 14:47
Copy link
Collaborator

@jherr jherr left a comment

Choose a reason for hiding this comment

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

One small API change, otherwise I love it!

@ahmedrowaihi
Copy link
Author

hey @jherr , thanks for this suggestion ! yes it's much better to make this prop scalable..
now I think we can later on different PR add Tool Hooks ! that would be cool feature..
for example, compressing tool results hook ? yeah why not

@nx-cloud
Copy link

nx-cloud bot commented Dec 5, 2025

View your CI Pipeline Execution ↗ for commit c818617

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 1m 16s View ↗
nx run-many --targets=build --exclude=examples/** ✅ Succeeded 29s View ↗

☁️ Nx Cloud last updated this comment at 2025-12-05 15:40:42 UTC

@AlemTuzlak
Copy link
Contributor

I have 2 questions on my mind here:

  • do we want to send the context in between the two
  • how do we type the tools to have the context they need

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 5, 2025

Open in StackBlitz

@tanstack/ai

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai@93

@tanstack/ai-anthropic

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-anthropic@93

@tanstack/ai-client

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-client@93

@tanstack/ai-devtools-core

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-devtools-core@93

@tanstack/ai-gemini

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-gemini@93

@tanstack/ai-ollama

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-ollama@93

@tanstack/ai-openai

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-openai@93

@tanstack/ai-react

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-react@93

@tanstack/ai-react-ui

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-react-ui@93

@tanstack/ai-solid

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-solid@93

@tanstack/ai-solid-ui

npm i https://pkg.pr.new/TanStack/ai/@tanstack/ai-solid-ui@93

@tanstack/react-ai-devtools

npm i https://pkg.pr.new/TanStack/ai/@tanstack/react-ai-devtools@93

@tanstack/solid-ai-devtools

npm i https://pkg.pr.new/TanStack/ai/@tanstack/solid-ai-devtools@93

commit: c818617

@ahmedrowaihi
Copy link
Author

ahmedrowaihi commented Dec 5, 2025

  • do we want to send the context in between the two

hey @AlemTuzlak ..
was just removing this, seemed stale code...

.server() will have server context
.client() will have client context

isomorphic context :'D

@ahmedrowaihi
Copy link
Author

@AlemTuzlak , do you think we better also pass current serialisable_only within the request ?

@ahmedrowaihi
Copy link
Author

how do we type the tools to have the context they need

getToolDef.server<{ userId: string }> will make server.options.context.userId typesafe, same goes to client tools.

do we want to send the context in between the two

I think that was bad initial idea, or maybe not and we can make use of it but only serialisable will be sent

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants