You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add agent parameter to session creation for pre-selecting custom agents (#722)
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>
Copy file name to clipboardExpand all lines: docs/features/custom-agents.md
+96Lines changed: 96 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -219,6 +219,102 @@ await using var session = await client.CreateSessionAsync(new SessionConfig
219
219
220
220
> **Tip:** A good `description` helps the runtime match user intent to the right agent. Be specific about the agent's expertise and capabilities.
221
221
222
+
In addition to per-agent configuration above, you can set `agent` on the **session config** itself to pre-select which custom agent is active when the session starts. See [Selecting an Agent at Session Creation](#selecting-an-agent-at-session-creation) below.
223
+
224
+
| Session Config Property | Type | Description |
225
+
|-------------------------|------|-------------|
226
+
|`agent`|`string`| Name of the custom agent to pre-select at session creation. Must match a `name` in `customAgents`. |
227
+
228
+
## Selecting an Agent at Session Creation
229
+
230
+
You can pass `agent` in the session config to pre-select which custom agent should be active when the session starts. The value must match the `name` of one of the agents defined in `customAgents`.
231
+
232
+
This is equivalent to calling `session.rpc.agent.select()` after creation, but avoids the extra API call and ensures the agent is active from the very first prompt.
> **Tip:** You can also set `agent: "pr-reviewer"` in the session config to pre-select this agent from the start. See the [Custom Agents guide](./guides/custom-agents.md#selecting-an-agent-at-session-creation) for details.
0 commit comments