feat: add agent parameter to session creation for pre-selecting custom agents#722
feat: add agent parameter to session creation for pre-selecting custom agents#722
agent parameter to session creation for pre-selecting custom agents#722Conversation
e745d22 to
ba658f9
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds an optional agent field to session configuration across all four SDK languages (Node.js, Python, Go, .NET), enabling users to pre-select a custom agent when creating or resuming a session. This eliminates the need for a separate session.rpc.agent.select() call after session creation, matching the CLI's --agent flag functionality.
Changes:
- Added
agentfield toSessionConfigandResumeSessionConfigtypes in all four SDKs, wired into thesession.createandsession.resumeRPC payloads - Added unit tests in Node.js verifying
agentis forwarded in bothsession.createandsession.resumerequests - Updated documentation with a new "Selecting an Agent at Session Creation" section in
custom-agents.md, plus updates tosession-persistence.mdandgetting-started.md
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
nodejs/src/types.ts |
Added agent?: string to SessionConfig and included it in ResumeSessionConfig Pick type |
nodejs/src/client.ts |
Wired config.agent into session.create and session.resume RPC payloads |
nodejs/test/client.test.ts |
Added unit tests for agent forwarding in create and resume requests |
python/copilot/types.py |
Added agent: str to SessionConfig and ResumeSessionConfig TypedDicts |
python/copilot/client.py |
Wired agent into session.create and session.resume payloads |
go/types.go |
Added Agent string to SessionConfig, ResumeSessionConfig, and wire format request structs |
go/client.go |
Wired config.Agent into CreateSession and ResumeSessionWithOptions |
dotnet/src/Types.cs |
Added Agent property to SessionConfig and ResumeSessionConfig with copy constructors |
dotnet/src/Client.cs |
Added Agent to CreateSessionRequest/ResumeSessionRequest records and call sites |
docs/guides/custom-agents.md |
New section with examples in all 4 languages for agent pre-selection |
docs/guides/session-persistence.md |
Added agent to resume options table |
docs/getting-started.md |
Added tip about agent parameter in custom agents section |
ba658f9 to
d77ec60
Compare
Cross-SDK Consistency Review ✅I've reviewed this PR for consistency across all four SDK implementations (Node.js, Python, Go, and .NET). ✅ Excellent consistency in implementation:All four SDKs properly implement the
|
…m agents Add an optional `agent` field to SessionConfig and ResumeSessionConfig across all four SDKs (Node.js, Python, Go, .NET) that allows specifying which custom agent should be active when the session starts. Previously, users had to create a session and then make a separate `session.rpc.agent.select()` call to activate a specific custom agent. This change allows setting the agent directly in the session config, equivalent to passing `--agent <name>` in the Copilot CLI. The `agent` value must match the `name` of one of the agents defined in `customAgents`. Changes: - Node.js: Added `agent?: string` to SessionConfig and ResumeSessionConfig, wired in client.ts for both session.create and session.resume RPC calls - Python: Added `agent: str` to SessionConfig and ResumeSessionConfig, wired in client.py for both create and resume payloads - Go: Added `Agent string` to SessionConfig and ResumeSessionConfig, wired in client.go for both request types - .NET: Added `Agent` property to SessionConfig and ResumeSessionConfig, updated copy constructors, CreateSessionRequest/ResumeSessionRequest records, and CreateSessionAsync/ResumeSessionAsync call sites - Docs: Added "Selecting an Agent at Session Creation" section with examples in all 4 languages to custom-agents.md, updated session-persistence.md and getting-started.md - Tests: Added unit tests verifying agent parameter is forwarded in both session.create and session.resume RPC calls Closes #317, closes #410, closes #547 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
d77ec60 to
c61475f
Compare
✅ Cross-SDK Consistency Review: APPROVEDThis PR demonstrates excellent cross-SDK consistency. The Verified ConsistencyAPI Design ✅All SDKs expose the same functionality with proper naming conventions:
Feature Parity ✅All SDKs implement the feature identically:
Documentation ✅
Language-Specific Implementation NotesThe PR properly accounts for each language's idioms:
SummaryNo consistency issues found. This PR maintains perfect feature parity across all SDK implementations and follows established patterns in the codebase. The implementation is ready from a cross-SDK consistency perspective. 🎯
|
Summary
Adds an optional
agentfield toSessionConfigandResumeSessionConfigacross all four SDKs that allows specifying which custom agent should be active when a session starts.Problem
Users had to create a session and then make a separate
session.rpc.agent.select()call to activate a specific custom agent. The CLI supports--agent MyAgentbut the SDK had no equivalent. This was a frequently requested feature.Solution
Add
agent?: stringto session config in all 4 SDKs. The value must match thenameof one of the agents incustomAgents. The runtime will select the specified agent when the session starts, equivalent to callingsession.rpc.agent.select()after creation.Example (TypeScript)
Changes
SDK (all 4 languages)
agentfield toSessionConfigandResumeSessionConfigagentintosession.createandsession.resumeRPC payloadsagent?: stringinSessionConfig, passed inclient.tsagent: strinSessionConfig, passed inclient.pyAgent stringinSessionConfig, passed inclient.goAgentproperty inSessionConfig, updated records and call sites inClient.csDocumentation
docs/guides/custom-agents.mdagentparameterdocs/guides/session-persistence.mdresume options tabledocs/getting-started.mdwith a tip about the new parameterTests
agentis forwarded in bothsession.createandsession.resumeRPC callsRuntime note
The runtime side (
copilot-agent-runtime) needs a corresponding change to read theagentfield fromSessionCreateRequest/SessionResumeRequestand callselectCustomAgent()during session initialization. Until then, the SDK will send the field but the runtime will ignore it. This is backward-compatible — the field is optional and unknown fields are safely ignored by JSON-RPC.Closes #317
Closes #410
Closes #547