Skip to content

feat(cli): add agentkit list sessions --harness <name>#86

Open
yaozheng-fang wants to merge 1 commit into
mainfrom
feat/cli-list-sessions
Open

feat(cli): add agentkit list sessions --harness <name>#86
yaozheng-fang wants to merge 1 commit into
mainfrom
feat/cli-list-sessions

Conversation

@yaozheng-fang

Copy link
Copy Markdown
Collaborator

What

Adds agentkit list sessions --harness <name> — lists a user's conversation sessions on a deployed harness runtime, by calling the runtime's ADK data-plane endpoint:

GET {harness_url}/apps/harness/users/{user_id}/sessions

user_id resolution

ADK's list endpoint takes user_id as a required path param (no cross-user listing), so user_id must be determinable:

  1. explicit --user-id <id>;
  2. otherwise the JWT sub of the harness credential — a custom_jwt harness uses the agentkit login id_token (or -ak), whose sub is the user;
  3. a key_auth harness's key is an opaque api key (not a JWT) → fast-fail asking for --user-id.

Harness addressing mirrors invoke harness (resolved from the harness.json registry, harness credential for auth) — a data-plane call, distinct from the control-plane list harness (AK/SK ListRuntimes).

Changes

  • agentkit/toolkit/cli/cli_list.pysessions command + _resolve_harness_endpoint + a local _user_id_from_token. Output: table (SessionId / Events / LastUpdate) plus json/yaml/--quiet.
  • docs/content/2.agentkit-cli/5.harness.md — new "list sessions" section.
  • tests/toolkit/cli/test_cli_list_sessions.py — 6 tests: explicit user_id, JWT-sub derivation, key_auth fast-fail (asserts no network call), unknown harness, quiet, json.

Note (follow-up)

_user_id_from_token is duplicated locally here because the equivalent helper in cli_invoke (from the in-flight invoke harness run_sse work) is not yet on main — keeping this PR self-contained and independently mergeable. Once that work lands, both should consolidate into one shared helper.

Testing

uv run pytest tests/toolkit/cli/test_cli_list_sessions.py -q
6 passed

Also verified end-to-end against a live key_auth harness (explicit --user-id).

🤖 Generated with Claude Code

List a user's conversation sessions on a deployed harness runtime via the
runtime's ADK data-plane endpoint GET /apps/harness/users/{user_id}/sessions.

ADK requires a user_id (no cross-user listing), so user_id is resolved as:
explicit --user-id > the JWT `sub` of the harness credential (custom_jwt uses
the `agentkit login` id_token or -ak) > fast-fail (e.g. a key_auth harness whose
opaque key is not a JWT). Harness addressing mirrors `invoke harness` (resolved
from the harness.json registry, harness credential for auth) — a data-plane call,
distinct from the control-plane `list harness` (AK/SK ListRuntimes).

Output: table (SessionId / Events / LastUpdate) plus json/yaml/--quiet.

A local `_user_id_from_token` mirrors the one in cli_invoke (not yet on main);
consolidate into one shared helper once the invoke run_sse work lands.

Docs: new "list sessions" section in docs harness page. Tests cover user_id
resolution (explicit, JWT sub, key_auth fast-fail), unknown harness, and output.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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