AdkApp: user_id always defaults to 'default-user-id' when called from Google Agentspace
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 45/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- google-cloud, python
- Domain
- api, authentication, cloud
Research direction
Start in vertexai/agent_engines/templates/adk.py, reading _StreamRunRequest and streaming_agent_run_with_events() around the referenced lines. Trace how the incoming request JSON and authenticated request context are represented before the default user ID is assigned. Done means the Agentspace user identity reaches the ADK session and analytics path, with regression coverage for requests that omit user_id.
Written by the indexing model from the issue text.
Description
Environment
| Component | Value |
|---|---|
| Package | google-cloud-aiplatform |
| File | vertexai/agent_engines/templates/adk.py |
| Python | 3.12 |
| Deployment | Vertex AI Agent Engine via Agentspace |
Description
When ADK agents are deployed to Google Agentspace and users interact through the Agentspace UI, user_id is always "default-user-id" for all sessions and events. The real user identity (IAM principal/email) is never propagated, making per-user analytics impossible.
Root cause
In vertexai/agent_engines/templates/adk.py, line 97:
_DEFAULT_USER_ID = "default-user-id"
The _StreamRunRequest constructor (lines 198-200) falls back to this default:
self.user_id: Optional[str] = kwargs.get("user_id") or kwargs.get(
"userId", _DEFAULT_USER_ID
)
When Agentspace calls streaming_agent_run_with_events(request_json) (line 1166), the incoming JSON does not include a user_id or userId field. The authenticated user's identity — which Agentspace does know (confirmed by useriamprincipal in discoveryengine.googleapis.com audit logs) — is not passed through to the Agent Engine request payload.
This "default-user-id" then propagates through the entire ADK stack:
_StreamRunRequest.user_id ("default-user-id")
→ Runner.run_async(user_id=...)
→ Session.user_id
→ InvocationContext.user_id
→ BigQueryAgentAnalyticsPlugin logs it to BQ
Expected behavior
When a user accesses an agent through Agentspace, the user_id field in the request should contain the authenticated user's identity (IAM principal or email). The identity is already available in the Agentspace request context — it just needs to be included in the streaming_agent_run_with_events request JSON.
Possible fixes
- Agentspace side: Include the authenticated user's identity in the
user_idfield of the request JSON sent to Agent Engine - Vertex AI SDK side: In
streaming_agent_run_with_events()or_StreamRunRequest, extract user identity from HTTP request headers or IAM metadata as a fallback, rather than using a hardcoded"default-user-id"
Impact
- All ADK agents deployed to Agentspace are affected
BigQueryAgentAnalyticsPluginlogs"default-user-id"for all events, breaking per-user analytics (token usage, session counts, agent adoption)- Any downstream system relying on
session.user_idgets the placeholder value
Related
- Originally reported as google/adk-python#5189 — closed with a pointer to this issue since the root cause is in the Vertex AI SDK, not in ADK
- Dominant language
- Python
- Stars
- 907
- Forks
- 467
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 40
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from googleapis/python-aiplatform
-
api: vertex-ai
Difficulty 1/5 Under an hour Newbie friendliness 85/100
googleapis/python-aiplatform#7132 ·
-
api: vertex-ai
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
googleapis/python-aiplatform#7097 ·
-
CustomContainerTrainingJob.run drops max_wait_duration=0 instead of requesting indefinite DWS wait Openapi: vertex-ai
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
googleapis/python-aiplatform#7067 · 1 comment ·
-
api: vertex-ai
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
googleapis/python-aiplatform#6877 ·
-
api: vertex-ai
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
googleapis/python-aiplatform#6865 · 1 comment ·
All issues in googleapis/python-aiplatform
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
anthropics/skills#1811 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
speaches-ai/speaches#678 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
datalayer/mcp-compose#42 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
conda-forge/spacy-feedstock#177 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
UKGovernmentBEIS/inspect_evals#2523 ·