Ensure pydo never exposes tenant_id or team_id to callers of the hosted-agent session APIs. - #712
Conversation
| _DROPPED_EVENT_FIELDS = ("tenant_id", "team_id") | ||
|
|
||
|
|
||
| def _strip_tenant_fields(event: Any) -> Any: |
There was a problem hiding this comment.
This only runs from _unwrap_harness_sse_chunk, so it only affects SSE stream/history events.
get / list still return _parse_json(...) with no stripping. If the server includes tenant_id or team_id on the session object, callers still see it, which does not match “never exposes … to callers of the hosted-agent session APIs.”
Can we strip those fields on the JSON session responses too?
| assert call.request.url.endswith("/v2/agents/sessions/x%2Fy") | ||
|
|
||
|
|
||
| def test_get_session_has_no_team_id(): |
There was a problem hiding this comment.
This assertion cannot fail today: the mock body never includes team_id or tenant_id.
Please add both fields to the fixture (and the list test below). If we are actually stripping GET/LIST responses, the test should prove they are removed. If we are not stripping those paths, this test is not covering the claimed behavior and should be dropped
| assert "name=my-session" in call.request.url | ||
|
|
||
|
|
||
| def test_list_sessions_have_no_team_id(): |
There was a problem hiding this comment.
Same as GET: the listed sessions have no team_id in the fixture, so assert all("team_id" not in session …) is true even without any filter. Please include the fields in the mock or remove this test if LIST is out of scope.
… events SSharma-10 pointed out on PR #712 that _strip_tenant_fields only ran on SSE stream events; GET/LIST (and create/pause/resume, which share the same _parse_json helper) still passed tenant_id/team_id through untouched, and the existing tests couldn't have caught it since the fixtures never included those fields in the first place. - _strip_tenant_fields now recurses through dicts/lists so it can clean a whole {"sessions": [...]} body, not just a single event. - Both the sync and async _parse_json now run every response through it, covering get/list/create_from_manifest/pause/resume/etc. - Rewrote the GET/LIST tests (and added create/pause/resume, sync and async) to actually include team_id/tenant_id in the mock body so the assertions are meaningful. Co-authored-by: Cursor <cursoragent@cursor.com>
Resolve test_sessions.py conflict by keeping tenant/team stripping coverage alongside the multiline skills and size-cap regression tests. Co-authored-by: Cursor <cursoragent@cursor.com>
Ensure pydo never exposes tenant_id or team_id to callers of the hosted-agent session APIs.
What changed
{event_id, type, data}{result, error}_strip_tenant_fieldsto removetenant_idandteam_idbefore events are yielded.AgentSession/AsyncAgentSessionsurfaces.team_idis not exposed.Tests
Added coverage for:
tenant_idresultenvelopes withtenant_id/team_idAgentEventhandlingVerification:
pytest tests/agents— 112 passedaiohttp/aioresponsesversion mismatchNotes
The change is based on the
OHS_endpointsbranch because the hosted-agent implementation is not present onmain.