Skip to content

How do I pass authorization header to LlmAgent tool? #1816

@matino

Description

@matino

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).

        state_changes = {
            "temp:token": "<my token>",
        }
        actions_with_update = EventActions(state_delta=state_changes)
        system_event = Event(
            invocation_id="inv_login_update",
            author="system",  # Or 'agent', 'tool' etc.
            actions=actions_with_update,
        )

        await self.runner.session_service.append_event(session, system_event)

If I change the key from temp:token to user:token, the state is visible in the LlmAgent tool inside the ToolContext state.

Can somebody suggest a better approach?

Metadata

Metadata

Assignees

Labels

bot triaged[Bot] This issue is triaged by ADK botservices[Component] This issue is related to runtime services, e.g. sessions, memory, artifacts, etc

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions