Skip to content

feat: add user_id in readonly context #1083

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

Conversation

nag763
Copy link

@nag763 nag763 commented Jun 1, 2025

Hey

I want to access a Firestore database where documents are retrieved given my user ID.

So far, it is a bit tedious to access the user ID calling a tool, while it could be simplified by adding a RO attribute on the ReadOnly parent context of most Callback/Tools.

If there are easier ways to access the caller's user ID, kindly let me know as a reply of this.

Thanks a lot!

EDIT: I did type this in a rush, rephrased

@nag763 nag763 marked this pull request as ready for review June 1, 2025 20:14
@nag763
Copy link
Author

nag763 commented Jun 2, 2025

pytest report

$ uv run pytest  tests/unittests/ 
=============================================== test session starts ===============================================
platform linux -- Python 3.11.12, pytest-8.3.5, pluggy-1.6.0
rootdir: /home/usr/workspace/adk-python
configfile: pyproject.toml
plugins: langsmith-0.3.43, asyncio-1.0.0, xdist-3.7.0, mock-3.14.1, anyio-4.9.0
asyncio: mode=Mode.AUTO, asyncio_default_fixture_loop_scope=function, asyncio_default_test_loop_scope=function
collected 1621 items        


...

================================= 1616 passed, 5 skipped, 170 warnings in 15.01s ==================================

Before on #8d36dbda520b1c0dec148e1e1d84e36ddcb9cb95 1614 passed, 5 skipped, 170 warnings in 14.66s

@nag763
Copy link
Author

nag763 commented Jun 3, 2025

Actually, the user id is not preserved while an agent uses another one as a toll, as it passes tmp_user instead of parent[session.user_id]

user_id='tmp_user',

Anyone can provide guidance on why it was implemented that way and what alternatives do exist at the moment to get user ID from a running tool ?

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.

1 participant