Skip to content

Ensure pydo never exposes tenant_id or team_id to callers of the hosted-agent session APIs. - #712

Merged
SSharma-10 merged 3 commits into
OHS_endpointsfrom
drop-session-tenant-id
Aug 19, 2026
Merged

Ensure pydo never exposes tenant_id or team_id to callers of the hosted-agent session APIs.#712
SSharma-10 merged 3 commits into
OHS_endpointsfrom
drop-session-tenant-id

Conversation

@mishraishika24-pixel

Copy link
Copy Markdown

Ensure pydo never exposes tenant_id or team_id to callers of the hosted-agent session APIs.

What changed

  • Updated _unwrap_harness_sse_chunk to handle both:
    • Canonical event frames: {event_id, type, data}
    • gRPC-gateway envelopes: {result, error}
  • Added _strip_tenant_fields to remove tenant_id and team_id before events are yielded.
  • The shared helper is also used by the async session API and high-level AgentSession / AsyncAgentSession surfaces.
  • Added regression coverage for session GET/LIST to ensure team_id is not exposed.

Tests

Added coverage for:

  • Sync event streams with tenant_id
  • gRPC-gateway result envelopes with tenant_id / team_id
  • Stream error envelopes
  • Async event streams
  • High-level AgentEvent handling
  • Session GET/LIST responses

Verification:

  • pytest tests/agents112 passed
  • Mocked suite — 328 passed, with one unrelated aiohttp/aioresponses version mismatch
  • Black and pylint checks remain clean with no new lint issues

Notes

The change is based on the OHS_endpoints branch because the hosted-agent implementation is not present on main.

Comment thread src/pydo/agents/custom_sessions.py Outdated
_DROPPED_EVENT_FIELDS = ("tenant_id", "team_id")


def _strip_tenant_fields(event: Any) -> Any:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Comment thread tests/agents/test_sessions.py Outdated
assert call.request.url.endswith("/v2/agents/sessions/x%2Fy")


def test_get_session_has_no_team_id():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread tests/agents/test_sessions.py Outdated
assert "name=my-session" in call.request.url


def test_list_sessions_have_no_team_id():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

mishraishika24-pixel and others added 2 commits August 19, 2026 18:01
… 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>
@SSharma-10
SSharma-10 merged commit 2bf196c into OHS_endpoints Aug 19, 2026
6 checks passed
@SSharma-10
SSharma-10 deleted the drop-session-tenant-id branch August 19, 2026 14:07
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.

2 participants