Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .claude/skills/sdk-dart/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ is kept working. What the router writes is what it renders:
session holds; on a call, by an `AIToolApprovalCard` over `session.approvals`. A call the
router holds itself (a connector's under `require_approval`, the agent's scheduling tools for a repeating task, #2533) never
reaches `approvals`, so only `decideShown` answers it.
- An incognito session has no channel, and `chat()` throws. `Conversation` folds
`reasoning_delta`, `tool_started`, `tool_updated` and `tool_ran` into `Turn.steps` and
`Turn.isDone`, as Kotlin's does; `session.turnMessages` gives the channel's message shape, and
a waiting call asks `backend.userId`, not `Session.userId` (the agent's name on the call).
`flutter_demo`'s `AgentChat.unkept` shows it.
- `AIConversationView` lays the channel out in turns, `ChatComposer` asks and stops, and
`AIVoiceGlowView` / `AIVoiceWaveView` show the agent on a call.

Expand Down
2 changes: 1 addition & 1 deletion .claude/skills/sdk/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ Connections (AI-3376): Go has `client.Connections()` for the accounts the app an
Connections in Rust (AI-3383): `Client::connections()` (`sdks/rust/src/connections.rs`) follows Go's shape with the user as `user_id` of each call: `create(&NewConnection{connector, label, user_id})`, `authorize(id, &AuthorizeOptions{return_url, user_id})`, `get(id, user_id: Option<&str>)`, `list(&ConnectionFilter{connector, user_id})`, `delete(id, user_id: Option<&str>)`; options structs rather than adjacent `Option<&str>` so a label cannot be swapped for a user. A user given goes through `pub(crate) Client::acting_for`, so the header matches the call and replaces a `ClientOptions::user_id` the client was built with; no user (or an empty one) leaves the client as built, as Go's `UserID` does (92148e5fe). Rust had no public acting-for helper to deprecate for AI-3387: `Backend` and its `acting_for` field are crate-private (`sdks/rust/src/backend.rs`, not re-exported from `lib.rs`), and `Client::acting_for` is `pub(crate)`. No other SDK needs to change for this.
Connections in JavaScript (AI-3378, AI-3387): `api.connections` has `create(connectorId, { label, userId })`, `authorize(id, { returnUrl, userId })`, `get(id, { userId })`, `list({ connectorId, userId })` (every page, 200 a page, newest first) and `delete(id, { userId })`. The user is an optional parameter of each call, never a client of its own: given, it is sent as `owner.user_id` (create) and `X-Stream-User-Id` on every call, reads included, with the app's server credential (an internal `speakingFor(backend, userId)` in `backend.ts`, kept off `Backend`'s type, which Dispatch's `answer` also uses); left out or empty, the call is the app's (`owner.type: app`, `owner_type=app`, no header added). Optional parts are one options object, never adjacent positional strings. `Backend.actingFor` stays public and working, marked `@deprecated` (Chat's "deprecate, never break"), and a test pins its requests to the base commit's. A client built with `BackendOptions.userId` still sends that user on a call without `userId`, as on every other call; one built on the deprecated `actingFor` does not (the call is the app's). A `userId` on a client that is not server side (a device, or a page on a customer-id router) is a `ConfigurationError` before any request. Other SDKs need to update: Python, .NET, Ruby, Rust and PHP (AI-3379..AI-3383).
Connections in Python (AI-3379, no spec change): `plugins/stream` has `api.connections` with the Go shape: `create(connector_id, *, label=None, user_id=None)`, `authorize(id, *, return_url=None, user_id=None)` returning `Authorization`, `get(id, *, user_id=None)`, `list(*, connector_id=None, user_id=None)` reading every page, `delete(id, *, user_id=None)`; every option is keyword-only, so a user id cannot land in the label's or connector's slot. A user given is `owner.user_id` (create) and `X-Stream-User-Id` on every call, replacing whoever the client acts for and the user its backend was built for (which behind the proxy would sign that user's own token); none is the app's connection, sent as the client is otherwise (a client built for a user still names that user). AI-3387 in Python: `Client.for_user` is deprecated (`DeprecationWarning`, still working) in favour of a keyword-only `user_id=None`, last, on `Client.agent` and `Client.router`, on a client built with `team=`/`usage_categories=`; a device naming a user is refused before any request. Dispatch and `Accelerated` keep `Backend.acting_for` internally.
The session socket sends `reasoning_delta` (`turn_id`, `text`): the next piece of the model's thinking on a written reply, which a kept conversation also streams into the reply's Chat message and an incognito one has nowhere else to show. JavaScript folds it, with `tool_started`, `tool_updated` (not `verbatim`) and `tool_ran`, into each agent turn's `steps` in `sdks/js/src/conversation.ts`: a round of thinking `r1`, `r2`... opens on a delta after anything else and completes when the turn writes text or UI, calls a tool, answers or is cut off; a call runs until `tool_ran`, failed when it carries an `error`, its summary the last non-verbatim update. A turn is `done` on `responded` with no `pending_work`, or `interrupted`. `AgentChat` shows a session with no `conversationId` from these turns (`sdks/js/src/turn-messages.ts`): the agent's turns between two of the person's messages are one reply, shaped as the channel's messages (top level in stream-chat 9, under `custom` in 10) with `ai_reasoning` and `ai_tool_call` steps, rounds numbered across the reply, its whole thinking given to `reasoning`, and a call waiting in `approvals` shown `awaiting_approval` with its question and the session's `user_id` as `target_user_id`. The clients that carry the socket's description (JavaScript types, Python `plugins/stream`) are regenerated. Swift does the same: `Conversation` folds the frames into `Turn.steps` and `Turn.isDone`, and `TurnMessage.messages(of:approvals:userID:isConnected:)` (`session.turnMessages`) builds the replies, each step an attachment type and JSON payload for `AIMessagePart.parts(from:)`, the session's user now `Session.userID`; `swift_assistant`'s `AgentChat` shows an incognito session from them. Kotlin does the same: `Conversation` folds the frames into `Turn.steps` (`TurnStep.Reasoning`, `TurnStep.ToolCall`) and `Turn.isDone`, and `TurnMessage.messages(conversation, approvals, userId, isConnected)` (`AgentSession.turnMessages`, a `Flow`) builds the replies, each step an attachment type and plain-Kotlin fields for `AIMessagePart.parts`; its `target_user_id` is the user `setUser` named (`backend.user`), not the session's `user_id`, which is the name the agent joined the call as; `android_assistant`'s `AgentTransport` shows an incognito session from them. Other SDKs need to update: Dart, whose AI components read the same steps, should fold the same frames into their `Conversation` turns and show a session with no channel through their transports; the server SDKs need nothing.
The session socket sends `reasoning_delta` (`turn_id`, `text`): the next piece of the model's thinking on a written reply, which a kept conversation also streams into the reply's Chat message and an incognito one has nowhere else to show. JavaScript folds it, with `tool_started`, `tool_updated` (not `verbatim`) and `tool_ran`, into each agent turn's `steps` in `sdks/js/src/conversation.ts`: a round of thinking `r1`, `r2`... opens on a delta after anything else and completes when the turn writes text or UI, calls a tool, answers or is cut off; a call runs until `tool_ran`, failed when it carries an `error`, its summary the last non-verbatim update. A turn is `done` on `responded` with no `pending_work`, or `interrupted`. `AgentChat` shows a session with no `conversationId` from these turns (`sdks/js/src/turn-messages.ts`): the agent's turns between two of the person's messages are one reply, shaped as the channel's messages (top level in stream-chat 9, under `custom` in 10) with `ai_reasoning` and `ai_tool_call` steps, rounds numbered across the reply, its whole thinking given to `reasoning`, and a call waiting in `approvals` shown `awaiting_approval` with its question and the session's `user_id` as `target_user_id`. The clients that carry the socket's description (JavaScript types, Python `plugins/stream`) are regenerated. Swift does the same: `Conversation` folds the frames into `Turn.steps` and `Turn.isDone`, and `TurnMessage.messages(of:approvals:userID:isConnected:)` (`session.turnMessages`) builds the replies, each step an attachment type and JSON payload for `AIMessagePart.parts(from:)`, the session's user now `Session.userID`; `swift_assistant`'s `AgentChat` shows an incognito session from them. Kotlin does the same: `Conversation` folds the frames into `Turn.steps` (`TurnStep.Reasoning`, `TurnStep.ToolCall`) and `Turn.isDone`, and `TurnMessage.messages(conversation, approvals, userId, isConnected)` (`AgentSession.turnMessages`, a `Flow`) builds the replies, each step an attachment type and plain-Kotlin fields for `AIMessagePart.parts`; its `target_user_id` is the user `setUser` named (`backend.user`), not the session's `user_id`, which is the name the agent joined the call as; `android_assistant`'s `AgentTransport` shows an incognito session from them. Dart does the same (`Turn.steps`, `Turn.isDone`, `session.turnMessages`, each step the record `AIMessagePart.parseAll` takes), its `target_user_id` the agents' own user as in Kotlin; `flutter_demo`'s `AgentChat` shows an incognito session from them. The server SDKs need nothing.
An agent's UI instructions are kept apart from its instructions, so a session can turn UI off: `AgentConfig`, `AgentConfigRequest`, `AgentConfigPatch` and `SyncAgentRequest` have `ui_instructions` (an additive migration), and `CreateSessionRequest` has `ui`, a boolean a device may send. The router tells the model `ui_instructions` after the instructions (a backend's own session instructions included) unless the session was opened with `ui: false`, which reopening or forking it keeps (`agent_sessions.no_ui`). A sync sends the directory whole, so a sync without `ui_instructions` removes them; a PUT that leaves them out keeps them, so a client that does not know the field does not take the UI away. Go's `Load` compiles agent.yaml's `ui:` into `Folder.UIInstructions` and `syncFolder` sends it as `ui_instructions`; the folder's hash takes it in only when there is UI, so a directory without `ui:` is not synced again, and one with it is synced once more, which moves the UI out of the stored instructions. A router older than the field takes the sync and drops it, so `syncFolder` does not trust a stamp covering UI that the stored config lacks, and syncs again, and the router writes a sync of the same hash that declares UI the config lacks rather than finding it unchanged. Deploy the router before releasing an SDK that sends the field. JavaScript does the same: `loadFolder` puts the compiled `ui:` in `Folder.uiInstructions`, `Agent.sync` sends it as `ui_instructions` (left out without `ui:`, so such a directory keeps its fingerprint), and a stamp covering UI the stored config lacks is synced again. When a sync's answer has no `ui_instructions` though it sent them (a router older than the field), JavaScript syncs once more with the UI joined onto `instructions`, as before, under that body's own fingerprint and without writing the stamp, so the agent keeps its UI and the next sync moves it apart once the router knows the field. That fallback cannot honour `ui: false`: the UI is in `instructions` then, which every session is told, so the Interactive UI switch needs a router that knows the field and a sync it stored apart. Go only syncs again there, so an older router leaves a Go-synced agent with no UI, and Go should fall back the same way. `Agent`'s `instructions` option replaces instructions.md only: the folder's `ui:` is still sent as `ui_instructions`, as in Go. `react_assistant`'s settings have the same Interactive UI switch as `swift_assistant`'s, which opens new conversations with `ui: false`. The shared fixtures are unchanged: they are what the model is told, the instructions and the UI joined by a blank line, as the router joins them. Every generated client is regenerated (Go, JavaScript types, Python `plugins/stream`, Swift, Rust's `types.rs`); Rust compiling and sending `ui:` is still to do, below. Other SDKs need to update: Python, .NET, Ruby, Rust and PHP, when they read `ui:`, should send it as `ui_instructions` the same way; Swift has `SessionOptions.ui`, which `swift_assistant`'s Settings switch sets, and JavaScript's `sessions.create` passes `ui` through with the regenerated types, and Kotlin has `SessionOptions.ui`, which `Sessions.create` sends as it is (null left out); Python, Dart and the other server SDKs should offer `ui` on their create-session options, so an app that shows no UI can say so.
A tool call's state (`ToolCallState`, the `tool_call.started`, `tool_call.progress` and `tool_call.finished` frames) carries `display_title`: what the call is doing, as its tool was declared with (a session's own tool's `display_title`, or a hosted tool's), or "Searching the web" for the router's own search, the same default a Chat reply's tool step uses (`conversation.ToolTitle`). A worker's `host_tools` frame takes `display_title` on each tool, beside `interruptible` and `timeout_ms`. Go has `tools.DisplayTitle(title)`, sent on `host_tools` and on a session's own tools. The generated clients are regenerated (Go, JavaScript types, Python `plugins/stream`, Ruby, PHP, .NET); Swift's generates no `ToolCallState`, so it is unchanged. JavaScript needs nothing: its `host_tools` sends `tools.declared()`, `displayTitle` included, which the router now keeps. Every server SDK now declares one: Python `register(display_title=...)` (on `ToolPolicy`, sent by `plugins/stream`'s `_with_policy`), .NET `displayTitle:`, Ruby `display_title:`, PHP `displayTitle:` and Rust's `SessionTool.display_title`; Swift, Kotlin and Dart read it off the tool call state. Nothing is left to update.
Connections in PHP (AI-3381, AI-3387): `$client->connections` (`sdks/php/src/Connections.php`) has `create(NewConnection)`, `authorize(id, AuthorizeOptions)`, `get(id, userId)`, `list(ConnectionFilter)` (every page, `limit` 200, a repeated cursor ends it) and `delete(id, userId)`, Go's shape: the calls with more than one optional take an options object (`NewConnection`, `AuthorizeOptions`, `ConnectionFilter`, `sdks/php/src/`) like Go's `ConnectionRequest`, `AuthorizeOptions` and `ConnectionFilter`, so a user id cannot take the place of a label, return URL or connector (R1.1 of the review: `create('linear', 'ada')` had filed the user's account as the app's). `userId` is optional and last (a parameter of `get` and `delete`, a field of the options objects); given, it is `owner.user_id` and `X-Stream-User-Id` with the server credential (a server token behind the proxy, never a user token); left out or empty, `owner.type: app` and no header, whoever the backend otherwise acts for. `Connections` goes through `Backend::speakingFor` (`@internal`, PHP has no package visibility), which drops the backend's own user. `Dispatch::answer` goes through `Backend::writingFor` (`@internal`, `Dispatch.php:193`), which keeps the backend's own user when the writer has none, as `onBehalfOf` did before; `onBehalfOf` calls `writingFor`. `Backend::onBehalfOf` stays public and working, `@deprecated` in favour of the `userId` parameter; PHP's `Backend::actingFor` is unchanged and still signs a user token (the device path), so its name means something else than `actingFor` in Go and JavaScript. No other public PHP wrapper used `onBehalfOf`.
Expand Down
1 change: 1 addition & 0 deletions .claude/skills/sdk/notes/2026-11-23-target-user-id.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
An incognito session's tool call waiting for approval is shown as an `ai_tool_call` step with `target_user_id`: the user Stream's approver shows the card to. Kotlin and Dart send the person's user, the one the app signed in as (`backend.user` in Kotlin, `backend.userId` in Dart), which is what a kept reply's step uses (the conversation's owner, `parts.go`). `Session.user_id` is the name the agent joined the call as, not the session's owner. Other SDKs need to update: Swift (`TurnMessage.swift`) and JavaScript (`turn-messages.ts`) should send the person's user as `target_user_id`, as Kotlin and Dart do, not `Session.userId`. The server SDKs need nothing.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Unreleased

## Breaking Changes

- The Dart SDK's `AgentEventKind` gains `reasoningDelta`, so a `switch` over it with no default needs the case (#2200).

## Features

### A sync removes the pages its `knowledge/urls.yaml` no longer lists
Expand Down
Loading
Loading