Tom Blench
02/16/2026, 3:58 PMTom Blench
02/16/2026, 3:59 PMToolSet implementation for each conversation, and passing in the user's jwt as a parameter, but it feels a bit clunkyAndrey Bragin
02/17/2026, 9:55 AMToolSet and Tool classes for DI is one of intended use-cases, so I can’t think of any better option currently than what you’re doing already. Can you elaborate why does it feel clunky? Do you have any ideas on how to make it more convenient?Tom Blench
02/17/2026, 9:56 AMToolSet injected by spring across the lifetime of the app, but obviously that doesn't work since the tool call has no concept of any contextJakub Amanowicz
02/17/2026, 11:04 AMToolSet instance and managing request scoped jwt tokens.
What you need is to get data (jwt) into execution phase of your ToolSet without passing it from LLM of course.
In Spring a lot things is solved with ThreadLocal - check out SecurityContextHolder. It can give you SecurityContext that provides getCredentials method - that's where you can take your current user's jwt from (see this SO answer).
You could do something like this:
// implement this using SecurityContextHolder
interface AuthProvider {
fun getAuthentication(): Authentication
}
class AuthAwareTool(private val authProvider: AuthProvider): ToolSet {
// use auth.getAuthentication
}Jakub Amanowicz
02/17/2026, 11:05 AMTom Blench
02/17/2026, 2:29 PMTom Blench
02/17/2026, 2:30 PMTom Blench
02/17/2026, 2:31 PMJakub Amanowicz
02/18/2026, 9:50 AMthe thread serving the spring request is different from the one executing the tool callIn this case my suggestion won't work, you're right