You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How do I pass authorization header to LlmAgent tool? #1816
I have an instance that has a Runner object as a dependency. I want to pass the request "authorization" header value to the runner agent tool. As I understand, the correct way is to do it via session service (per #267). However, this doesn't work when I prefix the key with temp: (since I don't want to persist tokens).
I agree that the temp session key is fairly misleading. The way I've done this is just to make it user: specific. You could do some redis acrobatics with TTL to have it truly temporary or even write an empty value to it in the agent when you have retrieved it.
Let me know if you have any other suggestions/fixed I may have missed.
I think another option would be to use the credential service. The Runner instance could call save_credentials, then the LLM tool could call load_credentials with tool_context._invocation_context.credential_service.load_credential(...). That's not super clean, but I guess it's more secure than persisting the token in the session service (even if only for a short while).
the key prefixed with temp: won't be added to the session state. One thing you can do is that each time your tool read it your tool can remove it from the session state.
@seanzhou1023 Could you please help with reviewing/merging #1829? It would really help to use credential service for secrets instead of session service 🙏
Activity
sindrigunnars commentedon Jul 7, 2025
I agree that the temp session key is fairly misleading. The way I've done this is just to make it user: specific. You could do some redis acrobatics with TTL to have it truly temporary or even write an empty value to it in the agent when you have retrieved it.
Let me know if you have any other suggestions/fixed I may have missed.
matino commentedon Jul 8, 2025
I think another option would be to use the credential service. The
Runnerinstance could callsave_credentials, then the LLM tool could callload_credentialswithtool_context._invocation_context.credential_service.load_credential(...). That's not super clean, but I guess it's more secure than persisting the token in the session service (even if only for a short while).sindrigunnars commentedon Jul 8, 2025
But does this solve the problem in the context of MCP tools?
matino commentedon Jul 8, 2025
I haven't used MCP tools, so can't really tell :/
seanzhou1023 commentedon Jul 8, 2025
the key prefixed with
temp:won't be added to the session state. One thing you can do is that each time your tool read it your tool can remove it from the session state.seanzhou1023 commentedon Jul 8, 2025
feel free to reopen if the above suggestion still doesn't work for you.
matino commentedon Jul 9, 2025
@seanzhou1023 Could you please help with reviewing/merging #1829? It would really help to use credential service for secrets instead of session service 🙏
refactor: Add save_credential and load_credential in callback context…
refactor: Use CallbackContext in credential service for saving/loadin…
refactor: Use CallbackContext in credential service for saving/loadin…
refactor: Add save_credential and load_credential in callback context…
refactor: Add save_credential and load_credential in callback context…
refactor: Use CallbackContext in credential service for saving/loadin…
refactor: Add save_credential and load_credential in callback context…
refactor: Use CallbackContext in credential service for saving/loadin…
refactor: Add save_credential and load_credential in callback context…
refactor: Use CallbackContext in credential service for saving/loadin…
refactor: Add save_credential and load_credential in callback context…