Add reportedClientSessionId to Rust session create/resume wire - #2366
Draft
em-gong wants to merge 1 commit into
Draft
Add reportedClientSessionId to Rust session create/resume wire#2366em-gong wants to merge 1 commit into
em-gong wants to merge 1 commit into
Conversation
Thread a new optional `reported_client_session_id` through `SessionConfig` and `ResumeSessionConfig` so callers can seed the runtime's client-session scalar (X-Client-Session-Id + telemetry) without changing the logical `session_id` used for resume-reattach, permission hooks, and the workspace filesystem. The field serializes as a flat top-level `reportedClientSessionId` sibling of `sessionId` on both `session.create` and `session.resume`, matching the runtime's UPDATE_OPTIONS_FORWARDED_KEYS allowlist. When absent it is omitted via skip_serializing_if, so the wire is byte-for-byte unchanged; the engine then falls back to `session_id`. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Threads a new optional
reported_client_session_idthrough the Rust SDK'sSessionConfigandResumeSessionConfig, serialized as a flat top-levelreportedClientSessionIdon both thesession.createandsession.resumeJSON-RPC wire.Part of a 4-repo fix for CCA (Cloud Copilot Coding Agent) per-session AI-credit attribution. On steering/resume runs the wrong session id lands on
X-Client-Session-Id, so AI-credit spend bills to the task session instead of the steering session. This field lets callers seed the runtime's client-session scalar (→X-Client-Session-Id+ telemetry) without touching the logical/registrysession_id, which keys resume-reattach, permission hooks, and the workspace filesystem.Semantics
reportedClientSessionId— flat top-level, sibling ofsessionId(not nested), on both create and resume.reported_client_session_id: Option<String>; builder:with_reported_client_session_id(impl Into<String>).#[serde(skip_serializing_if = "Option::is_none")]⇒ absent/Noneemits nothing and the wire is byte-for-byte identical to today; the engine then falls back tosession_id. Non-empty wins.Flat top-level is required because the runtime consumer (
copilot-agent-runtime#16469) forwards this via its standalone-jsonrpcUPDATE_OPTIONS_FORWARDED_KEYSallowlist, which reads a flat top-level param on bothcreate_sessionandresume_session. Nesting it under a sub-object would break pickup.Changes (Rust only)
SessionConfig+ResumeSessionConfig: newreported_client_session_idfield (docs;Default/newinitialize toNone; included in the customDebugimpls).with_reported_client_session_id(..)builder on each (mirrorswith_client_name).SessionCreateWire+SessionResumeWire: new field,skip_serializing_if = Option::is_none, camelCase, flat top-level sibling ofsessionId.into_wire().reportedClientSessionIdomitted; present ⇒ appears top-level on create and resume (withsessionIdunchanged).Scope: Rust-only (TS intentionally out of scope)
CCA drives copilotd via copilotd bootstrap env vars → copilot-host (Rust) → this Rust SDK builder → closed wire. It does not convey this identity through the TS
CopilotClient.createSession/resumeSessionJSON-RPC param path, so a TSreportedClientSessionIdoption would be permanent dead surface for this use case. Any non-CCA TS parity is a separate future PR.Consumer / release ordering
copilot-agent-runtime#16469..with_reported_client_session_id(..).Validation
cargo test --all-features— new tests pass.cargo +nightly-2026-04-14 fmt --check— clean.cargo clippy --all-features --all-targets -- -D warnings— clean.