From 124b857d4c06f57ff1f83bb3747fff968985cf80 Mon Sep 17 00:00:00 2001 From: Kanat Date: Fri, 20 Nov 2026 16:05:19 +0100 Subject: [PATCH 1/7] [AI-3410] .NET connections: a device refuses to name a user; pin the acting-user wire A Connections call that names a user on a client holding a user's token (AsUser, or Token with UserId) now throws ConfigurationException before any request (AI-3412). Tests pin that a user given replaces the user the client was made for with a server token behind the proxy, which is what the router needs; Go differs (AI-3410). Co-Authored-By: Claude Sonnet 5.5 --- .claude/skills/sdk/SKILL.md | 1 + CHANGELOG.md | 2 + sdks/dotnet/README.md | 9 ++ .../src/GetStream.VisionAgents/Connections.cs | 16 +++- .../ConnectionsTests.cs | 89 +++++++++++++++++++ 5 files changed, 116 insertions(+), 1 deletion(-) diff --git a/.claude/skills/sdk/SKILL.md b/.claude/skills/sdk/SKILL.md index 3ac4a7df6..c5d9f9fd0 100644 --- a/.claude/skills/sdk/SKILL.md +++ b/.claude/skills/sdk/SKILL.md @@ -943,3 +943,4 @@ Connections in PHP (AI-3381, AI-3387): `$client->connections` (`sdks/php/src/Con Ruby connections and the user parameter (AI-3380, AI-3387): `Client#connections` has `create(connector, label:, user_id:)`, `authorize(id, return_url:, user_id:)`, `get(id, user_id:)`, `list(connector:, user_id:)` (every page, `owner_type` app or user) and `delete(id, user_id:)`; a `user_id` is the owner on create and `X-Stream-User-Id` on every call, none is the app's connection with no header. `Client#get`, `post`, `put`, `patch`, `delete` and `socket` take an optional `user_id:` last (nil keeps whoever the backend acts for, empty drops it), and `Backend#acting_for` keeps working with a `@deprecated` tag pointing at it; `Dispatch#answer` acts through `Backend#acting` (`@api private`). Other SDKs follow the same rule (AI-3378..AI-3383). A screened turn carries its guardrail check: `TimelineEntry.guardrail` and the `guardrail` field of the session socket's `turn` frame, a `GuardrailCheck` (`kind`, `model`, `probability`, `threshold`, `allowed`, `latency_ms`, `held_ms`, `mode`, `failed`), absent when no check ran; a written aside (`Agent.Ask`) is no turn, so its check is not recorded. A `type: decision_model` guardrail.md takes a `question:` key, and a guardrail webhook's body has `conversation`, the lines said before the turn. Go has the regenerated client and `agents.GuardrailAsk.Conversation`. The generated clients are regenerated for Go, JavaScript types and Python `plugins/stream`. Other SDKs need to update: Ruby, PHP, .NET and Rust should regenerate for `GuardrailCheck`, and add `conversation` to their guardrail webhook body where they have one; Swift, Kotlin and Dart read `guardrail` off the `turn` frame once they show one (Swift's client was not regenerated here: its generator needs the chat repo's `tools/openapi`). Acting for a user (AI-3396): Go deprecated `Backend.ActingFor`: name the user on the call where it takes one (`UserID` of `client.Connections()` options, `XStreamUserId` of a generated call's params such as `CreateScheduledTaskParams`, or an `X-Stream-User-Id` set on one request with an `acceleration.RequestEditorFn`); `client.Agent(...)` calls take no per-call user yet, so `ActingFor` stays how they act for one. `ActingFor` keeps working and sends what it always did. Other SDKs need to update: JavaScript (#2110), Python (#2103), Ruby (#2102) and PHP (#2101) deprecate their own helper in their open PRs, each with an optional per-call user; .NET (#2099) and Rust (#2100) add the per-call user and have no public helper to deprecate. Until those merge, none of them is deprecated. +Acting for another user in .NET connections (AI-3410, AI-3412): a `Connections` call that names a user sends the client's server credential and `X-Stream-User-Id`, and drops the user the client was made for (`Backend.Acting` sets `UserId` to empty, `Backend.cs:254`). Behind the proxy that is a `server: true` token, as Python (`_backend.py:463`), JavaScript (`speakingFor`, `backend.ts:575`), PHP (`Backend.php:198`), Ruby (`backend.rb:301`) and Rust (`client.rs:174`) send; **Go differs**: a `Backend` with `UserID` and `ActingFor` signs `{"user_id": }` and adds the header (`stream/backend.go:250-253`, `:273`), a user token the router answers as a device (403 `server_side_only`), so a Go client made for a user cannot name another on a connections call; Go should drop `UserID` for the call, as the others do. A client holding a user's token (a device: `AsUser`, or `Token` with `UserId`) naming a user on a connections call throws `ConfigurationException` before any request, as JavaScript's `connections.ts:137-146` does; a customer-id client (`ServerSide` true) is unchanged. Other SDKs need to update: Go (the call's user replaces `UserID`), Python, Ruby and Rust (refuse a device's user before sending, AI-3412). diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bac99866..10f8273b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ `VisionAgentsClient.Connections` creates, authorizes, reads, lists and deletes connections: `CreateAsync("linear", new NewConnectionOptions { UserId = "alice" })`, `AuthorizeAsync(id, new AuthorizeOptions { ReturnUrl = ..., UserId = ... })` for the consent's launch URL, handoff token and expiry, `GetAsync(id, userId)`, `ListAsync(new ConnectionFilter { ConnectorId = ..., UserId = ... })` reading every page, and `DeleteAsync(id, userId)`; a user given is sent as the owner and as `X-Stream-User-Id`, and none is the app's own connection (#2099). +A `Connections` call that names a user on a client holding a user's token instead of the secret (`AsUser`, or `Token` with `UserId`) throws a `ConfigurationException` before any request, rather than the router's 403. + ### The JavaScript SDK connects a user's own accounts `api.connections` creates, authorizes, reads, lists and deletes connections: `create("linear", { userId })`, `authorize(id, { returnUrl, userId })` for the consent's launch URL, handoff token and expiry, `get(id, { userId })`, `list({ connectorId, userId })` and `delete(id, { userId })`; without `userId` they are the app's own. `Backend.actingFor` is deprecated in favour of the `userId` parameter and works as before (#2110). diff --git a/sdks/dotnet/README.md b/sdks/dotnet/README.md index 012bad57e..f673fca0b 100644 --- a/sdks/dotnet/README.md +++ b/sdks/dotnet/README.md @@ -406,6 +406,15 @@ An app's connection is reached by every call of a backend, one naming a user inc `ListAsync` with a `UserId` lists only that user's. Leave the user out for the app's own connection, which any of its agents may be bound to. Connections are server side only. +A user given replaces the one the client was made for (`VisionAgentsOptions.UserId`), and the +request keeps the server credential: behind the proxy it is a server token, not a token for the +client's own user, which is what the router needs to let a backend act for somebody. A client +that holds a user's token instead of the secret (`AsUser`, or `Token` with `UserId`) is a +device. It cannot act for another user, so a call naming one throws a `ConfigurationException` +before any request, and a call naming none is sent as before. The Go SDK differs here: a +`client.Client` made for a user (`UserID` with the secret) keeps signing that user's own token +when a call names another, which the router answers as the device it is. + ## Working on this package Everything runs in Docker; nothing is installed on the host. diff --git a/sdks/dotnet/src/GetStream.VisionAgents/Connections.cs b/sdks/dotnet/src/GetStream.VisionAgents/Connections.cs index 1d0840a24..d02dd2a44 100644 --- a/sdks/dotnet/src/GetStream.VisionAgents/Connections.cs +++ b/sdks/dotnet/src/GetStream.VisionAgents/Connections.cs @@ -45,7 +45,9 @@ public sealed record ConnectionFilter /// UserId of the options. A user given is sent as the /// owner and as X-Stream-User-Id alike, so the two never differ. A user's connection is /// reached only by a call naming that user; the app's is reached by every call, one naming a -/// user included. No user is the app's own connection. +/// user included. No user is the app's own connection. A user given replaces the one the client +/// was made for, with the server credential; a client holding a user's token (a device) refuses +/// a user with a before sending. /// public sealed class Connections { @@ -149,6 +151,11 @@ private static string Path(string id) => string.IsNullOrEmpty(id) /// Sends with this client acting for the user, or as it is when no user is given, whoever it /// acts for otherwise. /// + /// + /// A user given replaces the one the client was made for () + /// and the request keeps the server credential, never a token minted for that one user: the router + /// answers a user token as the device it is, and a device may not name another user. + /// private async Task SendAsync(string? userId, Func> send) { userId = VisionAgentsClient.Blank(userId); @@ -156,6 +163,13 @@ private async Task SendAsync(string? userId, Func seen.Headers[Header])); } + [Fact] + public async Task ABackendMadeForAUserBehindTheProxyNamesAnotherWithAServerTokenAndNoneWithItsOwn() + { + await using var router = await Answering(); + using var ada = new VisionAgentsClient(new VisionAgentsOptions + { + Url = router.Url, ApiKey = "key", ApiSecret = Fixtures.Secret, UserId = "ada", Authenticate = true, + }); + var cancel = TestContext.Current.CancellationToken; + + await ada.Connections.GetAsync("conn-1", "alice", cancel); + await ada.Connections.GetAsync("conn-1", cancellationToken: cancel); + + var (naming, plain) = (router.Requests[0], router.Requests[1]); + Assert.Equal(("alice", "jwt"), (naming.Headers[Header], naming.Headers["stream-auth-type"])); + var named = Fixtures.Claims(naming.Headers["Authorization"]); + Assert.True(named["server"]!.GetValue()); + Assert.Null(named["user_id"]); + Assert.False(plain.Headers.ContainsKey(Header)); + var own = Fixtures.Claims(plain.Headers["Authorization"]); + Assert.Equal("ada", own["user_id"]!.GetValue()); + Assert.Null(own["server"]); + } + + [Theory] + [InlineData(false)] + [InlineData(true)] + public async Task ADeviceHoldingAUsersTokenRefusesToNameAUserBeforeAnythingIsSent(bool authenticate) + { + await using var router = await Answering(); + using var device = new VisionAgentsClient(new VisionAgentsOptions + { + Url = router.Url, ApiKey = "key", Token = "ada-token", UserId = "ada", Authenticate = authenticate, + }); + using var derived = new VisionAgentsClient(new VisionAgentsOptions + { + Url = router.Url, ApiKey = "key", ApiSecret = Fixtures.Secret, Authenticate = authenticate, + }).AsUser("ada", "ada-token"); + var cancel = TestContext.Current.CancellationToken; + + foreach (var client in new[] { device, derived }) + { + var connections = client.Connections; + Assert.False(client.ServerSide); + await Assert.ThrowsAsync(() => connections.CreateAsync("linear", new NewConnectionOptions { UserId = "alice" }, cancel)); + await Assert.ThrowsAsync(() => connections.AuthorizeAsync("conn-1", new AuthorizeOptions { UserId = "alice" }, cancel)); + await Assert.ThrowsAsync(() => connections.GetAsync("conn-1", "alice", cancel)); + await Assert.ThrowsAsync(() => connections.ListAsync(new ConnectionFilter { UserId = "alice" }, cancel)); + await Assert.ThrowsAsync(() => connections.DeleteAsync("conn-1", "alice", cancel)); + } + + Assert.Empty(router.Requests); + } + + [Theory] + [InlineData(null)] + [InlineData("")] + public async Task ADeviceWithNoUserOnACallSendsItsOwnTokenAsBefore(string? userId) + { + await using var router = await Answering(); + using var device = new VisionAgentsClient(new VisionAgentsOptions { Url = router.Url, ApiKey = "key", Token = "ada-token", UserId = "ada" }); + var cancel = TestContext.Current.CancellationToken; + + await device.Connections.GetAsync("conn-1", userId, cancel); + await device.Connections.ListAsync(new ConnectionFilter { UserId = userId }, cancel); + + Assert.Equal(2, router.Requests.Count); + Assert.All(router.Requests, seen => + { + Assert.Equal(("Bearer ada-token", "jwt", "key"), (seen.Headers["Authorization"], seen.Headers["Stream-Auth-Type"], seen.Headers["X-Api-Key"])); + Assert.False(seen.Headers.ContainsKey(Header)); + }); + } + + [Fact] + public async Task ACustomerIdClientMadeForAUserStillNamesAnotherOnATrustingRouter() + { + await using var router = await Answering(); + using var ada = Fixtures.Client(router).AsUser("ada", "ada-token"); + var cancel = TestContext.Current.CancellationToken; + + Assert.True(ada.ServerSide); + await ada.Connections.GetAsync("conn-1", "alice", cancel); + + var seen = router.Only("GET", "/v1/agents/connections/conn-1"); + Assert.Equal(("alice", "examples"), (seen.Headers[Header], seen.Headers["X-Customer-Id"])); + Assert.False(seen.Headers.ContainsKey("Authorization")); + } + [Fact] public async Task EmptyOptionalStringsAreLeftOutAndTheOwnerIsTheUserGiven() { From 6cf1e075d0a58e5a483bfef3702907a8777e95ea Mon Sep 17 00:00:00 2001 From: Kanat Date: Fri, 20 Nov 2026 16:20:32 +0100 Subject: [PATCH 2/7] AI-3410: the proxy, not the router, refuses a device naming another user SKILL.md and the README said the router answers Go's request with 403 server_side_only. Stream's proxy refuses it first (proxy.go:277, a user token naming another user, 403), so the router never sees it. --- .claude/skills/sdk/SKILL.md | 2 +- sdks/dotnet/README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.claude/skills/sdk/SKILL.md b/.claude/skills/sdk/SKILL.md index c5d9f9fd0..cbd8d03e4 100644 --- a/.claude/skills/sdk/SKILL.md +++ b/.claude/skills/sdk/SKILL.md @@ -943,4 +943,4 @@ Connections in PHP (AI-3381, AI-3387): `$client->connections` (`sdks/php/src/Con Ruby connections and the user parameter (AI-3380, AI-3387): `Client#connections` has `create(connector, label:, user_id:)`, `authorize(id, return_url:, user_id:)`, `get(id, user_id:)`, `list(connector:, user_id:)` (every page, `owner_type` app or user) and `delete(id, user_id:)`; a `user_id` is the owner on create and `X-Stream-User-Id` on every call, none is the app's connection with no header. `Client#get`, `post`, `put`, `patch`, `delete` and `socket` take an optional `user_id:` last (nil keeps whoever the backend acts for, empty drops it), and `Backend#acting_for` keeps working with a `@deprecated` tag pointing at it; `Dispatch#answer` acts through `Backend#acting` (`@api private`). Other SDKs follow the same rule (AI-3378..AI-3383). A screened turn carries its guardrail check: `TimelineEntry.guardrail` and the `guardrail` field of the session socket's `turn` frame, a `GuardrailCheck` (`kind`, `model`, `probability`, `threshold`, `allowed`, `latency_ms`, `held_ms`, `mode`, `failed`), absent when no check ran; a written aside (`Agent.Ask`) is no turn, so its check is not recorded. A `type: decision_model` guardrail.md takes a `question:` key, and a guardrail webhook's body has `conversation`, the lines said before the turn. Go has the regenerated client and `agents.GuardrailAsk.Conversation`. The generated clients are regenerated for Go, JavaScript types and Python `plugins/stream`. Other SDKs need to update: Ruby, PHP, .NET and Rust should regenerate for `GuardrailCheck`, and add `conversation` to their guardrail webhook body where they have one; Swift, Kotlin and Dart read `guardrail` off the `turn` frame once they show one (Swift's client was not regenerated here: its generator needs the chat repo's `tools/openapi`). Acting for a user (AI-3396): Go deprecated `Backend.ActingFor`: name the user on the call where it takes one (`UserID` of `client.Connections()` options, `XStreamUserId` of a generated call's params such as `CreateScheduledTaskParams`, or an `X-Stream-User-Id` set on one request with an `acceleration.RequestEditorFn`); `client.Agent(...)` calls take no per-call user yet, so `ActingFor` stays how they act for one. `ActingFor` keeps working and sends what it always did. Other SDKs need to update: JavaScript (#2110), Python (#2103), Ruby (#2102) and PHP (#2101) deprecate their own helper in their open PRs, each with an optional per-call user; .NET (#2099) and Rust (#2100) add the per-call user and have no public helper to deprecate. Until those merge, none of them is deprecated. -Acting for another user in .NET connections (AI-3410, AI-3412): a `Connections` call that names a user sends the client's server credential and `X-Stream-User-Id`, and drops the user the client was made for (`Backend.Acting` sets `UserId` to empty, `Backend.cs:254`). Behind the proxy that is a `server: true` token, as Python (`_backend.py:463`), JavaScript (`speakingFor`, `backend.ts:575`), PHP (`Backend.php:198`), Ruby (`backend.rb:301`) and Rust (`client.rs:174`) send; **Go differs**: a `Backend` with `UserID` and `ActingFor` signs `{"user_id": }` and adds the header (`stream/backend.go:250-253`, `:273`), a user token the router answers as a device (403 `server_side_only`), so a Go client made for a user cannot name another on a connections call; Go should drop `UserID` for the call, as the others do. A client holding a user's token (a device: `AsUser`, or `Token` with `UserId`) naming a user on a connections call throws `ConfigurationException` before any request, as JavaScript's `connections.ts:137-146` does; a customer-id client (`ServerSide` true) is unchanged. Other SDKs need to update: Go (the call's user replaces `UserID`), Python, Ruby and Rust (refuse a device's user before sending, AI-3412). +Acting for another user in .NET connections (AI-3410, AI-3412): a `Connections` call that names a user sends the client's server credential and `X-Stream-User-Id`, and drops the user the client was made for (`Backend.Acting` sets `UserId` to empty, `Backend.cs:254`). Behind the proxy that is a `server: true` token, as Python (`_backend.py:463`), JavaScript (`speakingFor`, `backend.ts:575`), PHP (`Backend.php:198`), Ruby (`backend.rb:301`) and Rust (`client.rs:174`) send; **Go differs**: a `Backend` with `UserID` and `ActingFor` signs `{"user_id": }` and adds the header (`stream/backend.go:250-253`, `:273`), a user's token, which Stream's proxy refuses with a 403 when it names another user (`proxy.go:277` in `chat/projects/stream-accelerate`), so a Go client made for a user cannot name another on a connections call; Go should drop `UserID` for the call, as the others do. A client holding a user's token (a device: `AsUser`, or `Token` with `UserId`) naming a user on a connections call throws `ConfigurationException` before any request, as JavaScript's `connections.ts:137-146` does; a customer-id client (`ServerSide` true) is unchanged. Other SDKs need to update: Go (the call's user replaces `UserID`), Python, Ruby and Rust (refuse a device's user before sending, AI-3412). diff --git a/sdks/dotnet/README.md b/sdks/dotnet/README.md index f673fca0b..72e0e8d1e 100644 --- a/sdks/dotnet/README.md +++ b/sdks/dotnet/README.md @@ -413,7 +413,7 @@ that holds a user's token instead of the secret (`AsUser`, or `Token` with `User device. It cannot act for another user, so a call naming one throws a `ConfigurationException` before any request, and a call naming none is sent as before. The Go SDK differs here: a `client.Client` made for a user (`UserID` with the secret) keeps signing that user's own token -when a call names another, which the router answers as the device it is. +when a call names another, which Stream's proxy refuses with a 403. ## Working on this package From 7db125d4953adea7dd6db91ddbd1f8b307c587c2 Mon Sep 17 00:00:00 2001 From: Kanat Date: Fri, 20 Nov 2026 16:20:45 +0100 Subject: [PATCH 3/7] AI-3410: a device's user is an API key holding a user's token, not AsUser AsUser of a customer-id client is not refused (ServerSide is true, pinned by ACustomerIdClient), so 'AsUser throws' was wrong in the README, CHANGELOG, the Connections doc comment and the sdk skill. The refusal is for a client with an API key holding a user's token. --- .claude/skills/sdk/SKILL.md | 2 +- CHANGELOG.md | 2 +- sdks/dotnet/README.md | 10 +++++----- sdks/dotnet/src/GetStream.VisionAgents/Connections.cs | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.claude/skills/sdk/SKILL.md b/.claude/skills/sdk/SKILL.md index cbd8d03e4..27fbebe4d 100644 --- a/.claude/skills/sdk/SKILL.md +++ b/.claude/skills/sdk/SKILL.md @@ -943,4 +943,4 @@ Connections in PHP (AI-3381, AI-3387): `$client->connections` (`sdks/php/src/Con Ruby connections and the user parameter (AI-3380, AI-3387): `Client#connections` has `create(connector, label:, user_id:)`, `authorize(id, return_url:, user_id:)`, `get(id, user_id:)`, `list(connector:, user_id:)` (every page, `owner_type` app or user) and `delete(id, user_id:)`; a `user_id` is the owner on create and `X-Stream-User-Id` on every call, none is the app's connection with no header. `Client#get`, `post`, `put`, `patch`, `delete` and `socket` take an optional `user_id:` last (nil keeps whoever the backend acts for, empty drops it), and `Backend#acting_for` keeps working with a `@deprecated` tag pointing at it; `Dispatch#answer` acts through `Backend#acting` (`@api private`). Other SDKs follow the same rule (AI-3378..AI-3383). A screened turn carries its guardrail check: `TimelineEntry.guardrail` and the `guardrail` field of the session socket's `turn` frame, a `GuardrailCheck` (`kind`, `model`, `probability`, `threshold`, `allowed`, `latency_ms`, `held_ms`, `mode`, `failed`), absent when no check ran; a written aside (`Agent.Ask`) is no turn, so its check is not recorded. A `type: decision_model` guardrail.md takes a `question:` key, and a guardrail webhook's body has `conversation`, the lines said before the turn. Go has the regenerated client and `agents.GuardrailAsk.Conversation`. The generated clients are regenerated for Go, JavaScript types and Python `plugins/stream`. Other SDKs need to update: Ruby, PHP, .NET and Rust should regenerate for `GuardrailCheck`, and add `conversation` to their guardrail webhook body where they have one; Swift, Kotlin and Dart read `guardrail` off the `turn` frame once they show one (Swift's client was not regenerated here: its generator needs the chat repo's `tools/openapi`). Acting for a user (AI-3396): Go deprecated `Backend.ActingFor`: name the user on the call where it takes one (`UserID` of `client.Connections()` options, `XStreamUserId` of a generated call's params such as `CreateScheduledTaskParams`, or an `X-Stream-User-Id` set on one request with an `acceleration.RequestEditorFn`); `client.Agent(...)` calls take no per-call user yet, so `ActingFor` stays how they act for one. `ActingFor` keeps working and sends what it always did. Other SDKs need to update: JavaScript (#2110), Python (#2103), Ruby (#2102) and PHP (#2101) deprecate their own helper in their open PRs, each with an optional per-call user; .NET (#2099) and Rust (#2100) add the per-call user and have no public helper to deprecate. Until those merge, none of them is deprecated. -Acting for another user in .NET connections (AI-3410, AI-3412): a `Connections` call that names a user sends the client's server credential and `X-Stream-User-Id`, and drops the user the client was made for (`Backend.Acting` sets `UserId` to empty, `Backend.cs:254`). Behind the proxy that is a `server: true` token, as Python (`_backend.py:463`), JavaScript (`speakingFor`, `backend.ts:575`), PHP (`Backend.php:198`), Ruby (`backend.rb:301`) and Rust (`client.rs:174`) send; **Go differs**: a `Backend` with `UserID` and `ActingFor` signs `{"user_id": }` and adds the header (`stream/backend.go:250-253`, `:273`), a user's token, which Stream's proxy refuses with a 403 when it names another user (`proxy.go:277` in `chat/projects/stream-accelerate`), so a Go client made for a user cannot name another on a connections call; Go should drop `UserID` for the call, as the others do. A client holding a user's token (a device: `AsUser`, or `Token` with `UserId`) naming a user on a connections call throws `ConfigurationException` before any request, as JavaScript's `connections.ts:137-146` does; a customer-id client (`ServerSide` true) is unchanged. Other SDKs need to update: Go (the call's user replaces `UserID`), Python, Ruby and Rust (refuse a device's user before sending, AI-3412). +Acting for another user in .NET connections (AI-3410, AI-3412): a `Connections` call that names a user sends the client's server credential and `X-Stream-User-Id`, and drops the user the client was made for (`Backend.Acting` sets `UserId` to empty, `Backend.cs:254`). Behind the proxy that is a `server: true` token, as Python (`_backend.py:463`), JavaScript (`speakingFor`, `backend.ts:575`), PHP (`Backend.php:198`), Ruby (`backend.rb:301`) and Rust (`client.rs:174`) send; **Go differs**: a `Backend` with `UserID` and `ActingFor` signs `{"user_id": }` and adds the header (`stream/backend.go:250-253`, `:273`), a user's token, which Stream's proxy refuses with a 403 when it names another user (`proxy.go:277` in `chat/projects/stream-accelerate`), so a Go client made for a user cannot name another on a connections call; Go should drop `UserID` for the call, as the others do. A client with an API key holding a user's token (a device: `Token` with `UserId`, or `AsUser` of a client with an API key) naming a user on a connections call throws `ConfigurationException` before any request, as JavaScript's `connections.ts:137-146` does; a customer-id client (`ServerSide` true) is unchanged. Other SDKs need to update: Go (the call's user replaces `UserID`), Python, Ruby and Rust (refuse a device's user before sending, AI-3412). diff --git a/CHANGELOG.md b/CHANGELOG.md index 10f8273b8..f2d8c6795 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ `VisionAgentsClient.Connections` creates, authorizes, reads, lists and deletes connections: `CreateAsync("linear", new NewConnectionOptions { UserId = "alice" })`, `AuthorizeAsync(id, new AuthorizeOptions { ReturnUrl = ..., UserId = ... })` for the consent's launch URL, handoff token and expiry, `GetAsync(id, userId)`, `ListAsync(new ConnectionFilter { ConnectorId = ..., UserId = ... })` reading every page, and `DeleteAsync(id, userId)`; a user given is sent as the owner and as `X-Stream-User-Id`, and none is the app's own connection (#2099). -A `Connections` call that names a user on a client holding a user's token instead of the secret (`AsUser`, or `Token` with `UserId`) throws a `ConfigurationException` before any request, rather than the router's 403. +A `Connections` call that names a user on a client with an API key holding a user's token throws a `ConfigurationException` before any request, rather than the 403 Stream's proxy answers. ### The JavaScript SDK connects a user's own accounts diff --git a/sdks/dotnet/README.md b/sdks/dotnet/README.md index 72e0e8d1e..653a6129b 100644 --- a/sdks/dotnet/README.md +++ b/sdks/dotnet/README.md @@ -409,11 +409,11 @@ connection, which any of its agents may be bound to. Connections are server side A user given replaces the one the client was made for (`VisionAgentsOptions.UserId`), and the request keeps the server credential: behind the proxy it is a server token, not a token for the client's own user, which is what the router needs to let a backend act for somebody. A client -that holds a user's token instead of the secret (`AsUser`, or `Token` with `UserId`) is a -device. It cannot act for another user, so a call naming one throws a `ConfigurationException` -before any request, and a call naming none is sent as before. The Go SDK differs here: a -`client.Client` made for a user (`UserID` with the secret) keeps signing that user's own token -when a call names another, which Stream's proxy refuses with a 403. +with an API key holding a user's token is a device. It cannot act for another user, so a call +naming one throws a `ConfigurationException` before any request, and a call naming none is sent +as before. The Go SDK differs here: a `client.Client` made for a user (`UserID` with the secret) +keeps signing that user's own token when a call names another, which Stream's proxy refuses +with a 403. ## Working on this package diff --git a/sdks/dotnet/src/GetStream.VisionAgents/Connections.cs b/sdks/dotnet/src/GetStream.VisionAgents/Connections.cs index d02dd2a44..ec24afcd4 100644 --- a/sdks/dotnet/src/GetStream.VisionAgents/Connections.cs +++ b/sdks/dotnet/src/GetStream.VisionAgents/Connections.cs @@ -46,8 +46,8 @@ public sealed record ConnectionFilter /// owner and as X-Stream-User-Id alike, so the two never differ. A user's connection is /// reached only by a call naming that user; the app's is reached by every call, one naming a /// user included. No user is the app's own connection. A user given replaces the one the client -/// was made for, with the server credential; a client holding a user's token (a device) refuses -/// a user with a before sending. +/// was made for, with the server credential; a client with an API key holding a user's token (a +/// device) refuses a user with a before sending. /// public sealed class Connections { From ce1d8262f2afb0ad53306b02f5af924d62913a22 Mon Sep 17 00:00:00 2001 From: Kanat Date: Fri, 20 Nov 2026 16:20:49 +0100 Subject: [PATCH 4/7] AI-3410: the changelog entry names its PR (#2155) AGENTS.md Changelog: every entry references its PR. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2d8c6795..264914688 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ `VisionAgentsClient.Connections` creates, authorizes, reads, lists and deletes connections: `CreateAsync("linear", new NewConnectionOptions { UserId = "alice" })`, `AuthorizeAsync(id, new AuthorizeOptions { ReturnUrl = ..., UserId = ... })` for the consent's launch URL, handoff token and expiry, `GetAsync(id, userId)`, `ListAsync(new ConnectionFilter { ConnectorId = ..., UserId = ... })` reading every page, and `DeleteAsync(id, userId)`; a user given is sent as the owner and as `X-Stream-User-Id`, and none is the app's own connection (#2099). -A `Connections` call that names a user on a client with an API key holding a user's token throws a `ConfigurationException` before any request, rather than the 403 Stream's proxy answers. +A `Connections` call that names a user on a client with an API key holding a user's token throws a `ConfigurationException` before any request, rather than the 403 Stream's proxy answers (#2155). ### The JavaScript SDK connects a user's own accounts From ead1ee5c777d0f24bab03d8197490d53e9aa54e1 Mon Sep 17 00:00:00 2001 From: Kanat Date: Fri, 20 Nov 2026 16:22:41 +0100 Subject: [PATCH 5/7] AI-3410: cite the proxy's refusal at its master lines proxy.go:430 and errors.go:223-225 on chat master; the earlier :277 was a line of another branch. --- .claude/skills/sdk/SKILL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.claude/skills/sdk/SKILL.md b/.claude/skills/sdk/SKILL.md index 27fbebe4d..8db4b0e8c 100644 --- a/.claude/skills/sdk/SKILL.md +++ b/.claude/skills/sdk/SKILL.md @@ -943,4 +943,4 @@ Connections in PHP (AI-3381, AI-3387): `$client->connections` (`sdks/php/src/Con Ruby connections and the user parameter (AI-3380, AI-3387): `Client#connections` has `create(connector, label:, user_id:)`, `authorize(id, return_url:, user_id:)`, `get(id, user_id:)`, `list(connector:, user_id:)` (every page, `owner_type` app or user) and `delete(id, user_id:)`; a `user_id` is the owner on create and `X-Stream-User-Id` on every call, none is the app's connection with no header. `Client#get`, `post`, `put`, `patch`, `delete` and `socket` take an optional `user_id:` last (nil keeps whoever the backend acts for, empty drops it), and `Backend#acting_for` keeps working with a `@deprecated` tag pointing at it; `Dispatch#answer` acts through `Backend#acting` (`@api private`). Other SDKs follow the same rule (AI-3378..AI-3383). A screened turn carries its guardrail check: `TimelineEntry.guardrail` and the `guardrail` field of the session socket's `turn` frame, a `GuardrailCheck` (`kind`, `model`, `probability`, `threshold`, `allowed`, `latency_ms`, `held_ms`, `mode`, `failed`), absent when no check ran; a written aside (`Agent.Ask`) is no turn, so its check is not recorded. A `type: decision_model` guardrail.md takes a `question:` key, and a guardrail webhook's body has `conversation`, the lines said before the turn. Go has the regenerated client and `agents.GuardrailAsk.Conversation`. The generated clients are regenerated for Go, JavaScript types and Python `plugins/stream`. Other SDKs need to update: Ruby, PHP, .NET and Rust should regenerate for `GuardrailCheck`, and add `conversation` to their guardrail webhook body where they have one; Swift, Kotlin and Dart read `guardrail` off the `turn` frame once they show one (Swift's client was not regenerated here: its generator needs the chat repo's `tools/openapi`). Acting for a user (AI-3396): Go deprecated `Backend.ActingFor`: name the user on the call where it takes one (`UserID` of `client.Connections()` options, `XStreamUserId` of a generated call's params such as `CreateScheduledTaskParams`, or an `X-Stream-User-Id` set on one request with an `acceleration.RequestEditorFn`); `client.Agent(...)` calls take no per-call user yet, so `ActingFor` stays how they act for one. `ActingFor` keeps working and sends what it always did. Other SDKs need to update: JavaScript (#2110), Python (#2103), Ruby (#2102) and PHP (#2101) deprecate their own helper in their open PRs, each with an optional per-call user; .NET (#2099) and Rust (#2100) add the per-call user and have no public helper to deprecate. Until those merge, none of them is deprecated. -Acting for another user in .NET connections (AI-3410, AI-3412): a `Connections` call that names a user sends the client's server credential and `X-Stream-User-Id`, and drops the user the client was made for (`Backend.Acting` sets `UserId` to empty, `Backend.cs:254`). Behind the proxy that is a `server: true` token, as Python (`_backend.py:463`), JavaScript (`speakingFor`, `backend.ts:575`), PHP (`Backend.php:198`), Ruby (`backend.rb:301`) and Rust (`client.rs:174`) send; **Go differs**: a `Backend` with `UserID` and `ActingFor` signs `{"user_id": }` and adds the header (`stream/backend.go:250-253`, `:273`), a user's token, which Stream's proxy refuses with a 403 when it names another user (`proxy.go:277` in `chat/projects/stream-accelerate`), so a Go client made for a user cannot name another on a connections call; Go should drop `UserID` for the call, as the others do. A client with an API key holding a user's token (a device: `Token` with `UserId`, or `AsUser` of a client with an API key) naming a user on a connections call throws `ConfigurationException` before any request, as JavaScript's `connections.ts:137-146` does; a customer-id client (`ServerSide` true) is unchanged. Other SDKs need to update: Go (the call's user replaces `UserID`), Python, Ruby and Rust (refuse a device's user before sending, AI-3412). +Acting for another user in .NET connections (AI-3410, AI-3412): a `Connections` call that names a user sends the client's server credential and `X-Stream-User-Id`, and drops the user the client was made for (`Backend.Acting` sets `UserId` to empty, `Backend.cs:254`). Behind the proxy that is a `server: true` token, as Python (`_backend.py:463`), JavaScript (`speakingFor`, `backend.ts:575`), PHP (`Backend.php:198`), Ruby (`backend.rb:301`) and Rust (`client.rs:174`) send; **Go differs**: a `Backend` with `UserID` and `ActingFor` signs `{"user_id": }` and adds the header (`stream/backend.go:250-253`, `:273`), a user's token, which Stream's proxy refuses with a 403 when it names another user (`chat/projects/stream-accelerate/proxy.go:430` on master; the 403 is `chat/lib/core/errors/errors.go:223-225`), so a Go client made for a user cannot name another on a connections call; Go should drop `UserID` for the call, as the others do. A client with an API key holding a user's token (a device: `Token` with `UserId`, or `AsUser` of a client with an API key) naming a user on a connections call throws `ConfigurationException` before any request, as JavaScript's `connections.ts:137-146` does; a customer-id client (`ServerSide` true) is unchanged. Other SDKs need to update: Go (the call's user replaces `UserID`), Python, Ruby and Rust (refuse a device's user before sending, AI-3412). From 41a0deabbd8aab5b839cd4ab396c0640e43366b0 Mon Sep 17 00:00:00 2001 From: Kanat Date: Fri, 20 Nov 2026 16:29:42 +0100 Subject: [PATCH 6/7] AI-3410: dotnet format the new connections tests Co-Authored-By: Claude Opus 5.5 --- .../ConnectionsTests.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/sdks/dotnet/tests/GetStream.VisionAgents.Tests/ConnectionsTests.cs b/sdks/dotnet/tests/GetStream.VisionAgents.Tests/ConnectionsTests.cs index 20a1a277c..3acc6b82b 100644 --- a/sdks/dotnet/tests/GetStream.VisionAgents.Tests/ConnectionsTests.cs +++ b/sdks/dotnet/tests/GetStream.VisionAgents.Tests/ConnectionsTests.cs @@ -158,7 +158,11 @@ public async Task ABackendMadeForAUserBehindTheProxyNamesAnotherWithAServerToken await using var router = await Answering(); using var ada = new VisionAgentsClient(new VisionAgentsOptions { - Url = router.Url, ApiKey = "key", ApiSecret = Fixtures.Secret, UserId = "ada", Authenticate = true, + Url = router.Url, + ApiKey = "key", + ApiSecret = Fixtures.Secret, + UserId = "ada", + Authenticate = true, }); var cancel = TestContext.Current.CancellationToken; @@ -184,11 +188,18 @@ public async Task ADeviceHoldingAUsersTokenRefusesToNameAUserBeforeAnythingIsSen await using var router = await Answering(); using var device = new VisionAgentsClient(new VisionAgentsOptions { - Url = router.Url, ApiKey = "key", Token = "ada-token", UserId = "ada", Authenticate = authenticate, + Url = router.Url, + ApiKey = "key", + Token = "ada-token", + UserId = "ada", + Authenticate = authenticate, }); using var derived = new VisionAgentsClient(new VisionAgentsOptions { - Url = router.Url, ApiKey = "key", ApiSecret = Fixtures.Secret, Authenticate = authenticate, + Url = router.Url, + ApiKey = "key", + ApiSecret = Fixtures.Secret, + Authenticate = authenticate, }).AsUser("ada", "ada-token"); var cancel = TestContext.Current.CancellationToken; From 2999041bd8766116150adfd12527b30a552ebf4e Mon Sep 17 00:00:00 2001 From: Kanat Date: Fri, 20 Nov 2026 16:34:31 +0100 Subject: [PATCH 7/7] AI-3410: the .NET README describes .NET only #2156 changes the Go behaviour this sentence described. Co-Authored-By: Claude Opus 5.5 --- sdks/dotnet/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sdks/dotnet/README.md b/sdks/dotnet/README.md index 653a6129b..b85f1e1a8 100644 --- a/sdks/dotnet/README.md +++ b/sdks/dotnet/README.md @@ -411,9 +411,7 @@ request keeps the server credential: behind the proxy it is a server token, not client's own user, which is what the router needs to let a backend act for somebody. A client with an API key holding a user's token is a device. It cannot act for another user, so a call naming one throws a `ConfigurationException` before any request, and a call naming none is sent -as before. The Go SDK differs here: a `client.Client` made for a user (`UserID` with the secret) -keeps signing that user's own token when a call names another, which Stream's proxy refuses -with a 403. +as before. ## Working on this package