Sign in

Sessions API — ADK

API reference for ADK session management: listing sessions, reading events, compaction, metadata, and test-session review endpoints

adk
apiadksessionseventsmetadatatesting

Updated 2026-11-03

Verified 2026-11-03

API reference for reading and managing ADK conversation sessions. For architecture and configuration, see ADK.

All paths are relative to the ADK service root (port 8103 locally) under /api/v1/adk. Authentication, required headers, and the error envelope follow the API conventions. X-Project-Id is optional and, when sent, must match the session's project for project-scoped reads.

Non-superusers only see their own sessions: list and read routes filter by the authenticated user.

Data Model

Session (SessionsList)

FieldDescription
idSession ID
app_nameApp code: agent_<uuid> or app_<uuid>, with hyphens replaced by underscores
user_idSession owner
stateSession state accumulated across turns; _execution_scope (including project_id) is server-owned
metadataCustom metadata such as a title
create_time, update_timeTimestamps
test_session_schema_version, test_session_titleSet only for test sessions in list results

Event (EventsList): id, app_name, user_id, session_id, invocation_id, author, timestamp, branch, content, long_running_tool_ids_json, grounding_metadata, custom_metadata, usage_metadata, citation_metadata, partial, turn_complete, error_code, error_message, interrupted.

Endpoints

MethodPathDescription
GET/sessions/List the caller's sessions
GET/sessions/{session_id}/events/List session events
POST/sessions/{session_id}/compactCompact a session on demand
PATCH/sessions/{session_id}/metadataMerge session metadata
GET/sessions/{session_id}/test-snapshot/Test-session snapshot
GET/sessions/{session_id}/trace-access/Caller's role for a test-session trace
GET/sessions/{session_id}/visible-messages/Visible test-session messages
POST/sessions/{session_id}/evaluateStart a test-session evaluation
GET/sessions/{session_id}/evaluations/List test-session evaluations
GET/sessions/{session_id}/evaluations/{run_id}Evaluation result and metrics
GET/sessions/{session_id}/messages/{message_id}/suggestions/Suggested follow-ups for a test message
PUT, GET/sessions/{session_id}/messages/{message_id}/feedback/Rate a test message, or read the caller's rating

List Sessions

GET /api/v1/adk/sessions/

ParameterDefaultDescription
user_idcallerNon-superusers may only pass their own ID; another ID returns 403
app_id—App UUID, converted to the app_<uuid> app code
agent_id—Agent UUID, converted to the agent_<uuid> app code
skip0Offset
limit201 to 100

Returns an array of sessions. Test sessions appear only to their owner and are redacted: state is {"test_session_schema_version": 1}, metadata is empty, and test_session_title carries the test name (links replaced with [link]).

bash
curl "http://localhost:8103/api/v1/adk/sessions/?agent_id=AGENT_ID&limit=10" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "X-Org-Id: YOUR_ORG_ID"

List Session Events

GET /api/v1/adk/sessions/{session_id}/events/?skip=0&limit=100

Returns events in chronological order. Test sessions return 403 with "Use the redacted test-session trace endpoint". Cosmos Assistant sessions (channel: cosmos_assistant) are readable only by their owner and only in the session's project.

Compact Session

POST /api/v1/adk/sessions/{session_id}/compact

Runs compaction immediately instead of waiting for the automatic threshold. Name the summarizing model through an agent or an explicit provider and model.

FieldDefaultDescription
agent_id—Agent whose model writes the summary
agent_version"1.0"Agent version
provider_id, model_id—Explicit model instead of an agent
json
{"compacted": true, "events_compacted": 42, "start_timestamp": 1761700000.0, "end_timestamp": 1761703600.0, "reason": null}

When nothing is eligible, the response is {"compacted": false, "reason": "No events eligible for compaction"}. Returns 400 for an unusable model, 403 for test sessions, and 404 for unknown sessions.

Update Session Metadata

PATCH /api/v1/adk/sessions/{session_id}/metadata

Merges {"metadata": {...}} into the existing metadata and returns the updated session. Requires the adk.session.write permission. These keys are server-owned and return 422: analyzer_score, test_snapshot, test_feedback, test_turn_timings, test_output_pii, test_suggestions.

bash
curl -X PATCH "http://localhost:8103/api/v1/adk/sessions/SESSION_ID/metadata" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "X-Org-Id: YOUR_ORG_ID" \
  -H "Content-Type: application/json" \
  -d '{"metadata": {"title": "Weather chat"}}'

Test-Session Endpoints

Test sessions are created from the AI Testing Workspace with a V2 start event that includes test_session (see Converse API). ADK stores an immutable test_snapshot in session metadata.

Access rules. The session owner can use every route. In a project-scoped test session, another user needs cosmos.project.read and observer.session_trace.review on the project to act as a reviewer. Service tokens must name a delegated user. A mismatched X-Project-Id returns 403; missing or inconsistent scope data returns 503.

RouteResponse
GET .../test-snapshot/{session_id, snapshot}
GET .../trace-access/{session_id, project_id, role} where role is owner or reviewer
GET .../visible-messages/?skip=0&limit=50Owner only. {schema_version: 1, session_id, status, messages, has_more}; status is available or unavailable; each message has id, role, text, timestamp, complete, and redacted when masked. limit is 1 to 100.
GET .../messages/{message_id}/suggestions/{session_id, message_id, status, suggestions} with status pending or ready
PUT .../messages/{message_id}/feedback/Body {"rating": "up" or "down", "reason": "..."} (reason up to 500 characters). Only visible assistant messages can be rated (422 otherwise).
GET .../messages/{message_id}/feedback/The caller's rating: {session_id, message_id, rating, reason, updated_at}

Evaluation

Evaluation routes return 503 unless ADK_TEST_EVALUATE_ENABLED=true.

  • POST .../evaluate requires adk.analyzer.run and an agent version with an attached analyzer (analyzer_id and analyzer_version); otherwise it returns 422. It returns 201 with {session_id, quality_run_id, status}.
  • GET .../evaluations/ returns up to 20 runs as {session_id, runs: [{quality_run_id, status, created_at}], has_more}.
  • GET .../evaluations/{run_id} returns {session_id, quality_run_id, status, metrics_schema_version, metrics}, combining the analyzer result with turn timing, PII, and cost metrics.
  • Converse API: conversation, streaming, and agent execution
  • ADK: architecture, configuration, and troubleshooting