t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: `t3 thread list|show` issue a full-access session for a read, and a killed CLI leaves it active for 30 days

Open Eugene3dotdev opened this issue 2 weeks ago • 0 comments

Before submitting

  • [x] I searched existing issues and did not find a duplicate.
  • [x] I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. On a machine that runs the T3 Code background service, run t3 auth session list --json and note the sessions.
  2. In another terminal, run t3 thread show <threadId> (or t3 thread list), and list sessions again while it runs. There is a new session labelled t3 thread cli, with full access.
  3. Run t3 thread show <threadId> again and kill it with SIGKILL before it returns.
  4. List sessions again. The t3 thread cli session from step 3 is still active, and it stays active until it expires 30 days later.

Expected behavior

  • A read does not write to the auth store. If a session is needed, list and show issue a read-only one. EnvironmentAuth.issueMcpClientSession already accepts access: "read-only", which mcpClientScopes maps to [orchestration:read].
  • A CLI session that is never revoked does not outlive the command by much. A TTL measured in minutes, not 30 days, would limit the harm of a killed CLI.

Actual behavior

withThreadTools in apps/server/src/cli/thread.ts (lines 231-242 on main at 2dd207a) runs for every t3 thread subcommand (list, show, send, start). It issues an MCP client session with access: "full-access", then revokes it in the release step of Effect.acquireRelease. The issued session:

  • carries orchestration:read, orchestration:operate, settings:write and source-control:write;
  • has the 30-day MCP_CLIENT_SESSION_TTL (apps/server/src/auth/EnvironmentAuth.ts:79).

So every read creates a full-access session and then revokes it. A CLI that is killed, or that loses its machine, before the release step runs leaves a full-access credential active for 30 days. On two machines we found 12 such t3 thread cli sessions, each left behind by an earlier CLI run.

Impact

Minor bug or occasional failure

Version or commit

0.1.9-nightly.20261110.4465 (7171fdd). The same code is on main at 2dd207a.

Environment

Linux (systemd user service) and macOS (desktop app), headless CLI use from agents.

Workaround

Callers revoke leftover t3 thread cli sessions with t3 auth session revoke <id>. Agents that only read use a read-only MCP client session instead of the CLI.

Eugene3dotdev avatar Nov 13 '26 06:11 Eugene3dotdev