Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: T3 Connect relay returns 401 (DPoP url_mismatch) when opening subagent threads #15772

Closeditsjeremyjohnson(GitHub profile, opens in a new tab) opened this issue 1 comment

What happens

When an environment is reached through the T3 Connect relay, opening a subagent (delegated-task) thread fails with 401. The server logs ServerAuthInvalidCredentialError with environment.dpop.failure_code: url_mismatch. Ordinary threads with UUID IDs load normally.

Observed on 0.0.46-nightly.20261003.2632, with a Mac browser connected to a Linux server through *.t3coderelay.com. All 28 relay GET /api/orchestration/threads/:threadId/bounded requests for delegated-task thread IDs returned 401, for example:

https://prod-….t3coderelay.com/api/orchestration/threads/thread%3Adelegated-task%3Acommand%253Amcp%253A<uuid>%253Adelegate-task%253A<request-id>/bounded

Cause

The client signs a different URL from the one it requests:

  • packages/client-runtime/src/state/boundedThreadSnapshotHttp.ts:38 builds the URL that gets signed by interpolating the raw ID: `/api/orchestration/threads/${input.threadId}/bounded`.
  • The request itself, client.threadBoundedSnapshot({ params: { threadId } }), percent-encodes the path parameter.

For a UUID the two strings are identical. A delegated-task ID such as thread:delegated-task:command%3Amcp%3A… contains : and %. In the signed URL, new URL() leaves : and the existing %3A alone. On the wire the path carries thread%3A…command%253Amcp…. normalizeDpopHtu on the server then compares two different strings, and verification fails with url_mismatch.

The same pattern appears in threadSnapshotHttp.ts:69 and threadHistoryHttp.ts:31.

Suggested fix

Encode the ID in the signed URL the same way the request path is encoded, for example `/api/orchestration/threads/${encodeURIComponent(input.threadId)}/bounded`. Apply it at all three call sites. A better fix is to derive the signed URL from the request the HTTP client actually builds, so the two can't diverge again.

How to reproduce

  1. Connect to an environment through the T3 Connect relay.
  2. In a thread, run delegate_task so a subagent child thread exists.
  3. Open the child thread. The bounded snapshot request returns 401 url_mismatch. Opening a normal thread works.
  1. Note

    Grok responding on behalf of Julius.

    Triage

    Thanks for tracking this down so precisely, @itsjeremyjohnson! The example URL and the call-site pointers made it quick to confirm.

    What I found

    Confirmed on main (4ee6bfd50e).

    Why the URLs don't match

    The DPoP proof URL and the request URL are built separately.

    • Signed URL: fetchEnvironmentBoundedThreadSnapshot, fetchEnvironmentThreadSnapshot, and fetchEnvironmentThreadHistoryPage put the raw thread id into the path given to environmentEndpointUrl. Assigning it to URL.pathname leaves : and any existing %3A untouched.
    • Request URL: the HTTP client (Effect's HttpApiClient path compiler) sends encodeURIComponent(threadId).
    • Result: verifyDpopProof compares the two after stripping only the query and fragment, so any thread id containing : or % fails with url_mismatch.

    Who's affected

    • Thread ids with no characters that need encoding sign and send the same path.
    • Ids like thread:<uuid> from IdAllocatorV2 and provider child threads (thread:provider:…) can hit this too, not only delegated-task threads.
    • Only relay (DPoP) connections are affected; local and bearer connections don't sign a URL.
    • Web and mobile share this client-runtime path, and desktop uses the web client.

    What happens on a failure

    • The bounded-snapshot loader treats the 401 as unavailable and falls back to the socket subscription.
    • The auth helper retries once, so each open shows two 401s.
    • Older-history paging has no socket fallback, so that request fails in the UI.
    • environmentHttpAuth.test.ts only uses thread-v2, which has no reserved characters, so tests stay green.

    Likely fix area

    Some options:

    • Encode the thread id with encodeURIComponent in the three signed paths so they match what the client requests.
    • Build the proof URL with makeEnvironmentHttpApiUrlBuilder, the same builder the request uses, so the two can't drift apart again.
    • Either way, add a test with a thread id that contains : and %.

    A maintainer will decide on the fix direction.

  2. juliusmarminge added labelsbug

  3. juliusmarminge added labelsvia-triage

  4. juliusmarminge closed this

Sign in to join this conversation.