-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[Custom Agents] Preselecting agent does not work #1018
Copy link
Copy link
Open
Labels
Description
Bug
When agent is provided in createSession config to pre-select a custom agent, the agent is not active from start.
Versions
- SDK:
@github/copilot-sdk 0.2.0/ 0.2.1 - Runtime:
@github/copilot1.0.17
Expected Behavior
Per the docs:
You can pass
agentin the session config to pre-select which custom agent should be active when the session starts. This is equivalent to callingsession.rpc.agent.select()after creation.
Both approaches should produce the same result — the selected agent's prompt is used as the active system prompt from the first message.
Actual Behavior
agent=in session config: The LLM receives thesystemMessagecontent (or the SDK default prompt). The agent'spromptis not injected. Confirmed by inspecting thesystemfield in the LLM API request.rpc.agent.select()after creation: The LLM receives the agent'spromptas expected. Confirmed by a marker string in the agent's prompt appearing in the LLM's first response.
Reproduction
session = await client.create_session(
on_permission_request=PermissionHandler.approve_all,
system_message={"mode": "replace", "content": "You are a helpful assistant."},
custom_agents=[
{
"name": "researcher",
"prompt": "You are a researcher. Begin every response with RESEARCHER_ACTIVE.",
},
],
agent="researcher", # Pre-select
)
response = await session.send_and_wait("Hello")
# Expected: response starts with "RESEARCHER_ACTIVE"
# Actual: response does NOT contain "RESEARCHER_ACTIVE" — agent prompt not injectedWorkaround
Call rpc.agent.select() after session creation:
session = await client.create_session(...)
await session.rpc.agent.select(SessionAgentSelectParams(name="researcher"))
response = await session.send_and_wait("Hello")
# Works: response starts with "RESEARCHER_ACTIVE"Notes
- This may be related to how systemMessage: { mode: "replace" } interacts with agent selection. It's possible replace mode overwrites the agent's prompt. However, the docs do not mention this interaction, and rpc.agent.select() correctly overrides the system message regardless of mode.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Fields
Give feedbackNo fields configured for issues without a type.