-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
What happened?
Firstly, great work on the SDK 👍
I'm trying to set a custom agent on my session following the custom agent documentation - https://copilot-community-sdk.github.io/copilot-sdk-java/snapshot/advanced.html#Custom_Agents
After creating a list of custom agents and settings on my session, the setAgent() doesn't appear to be taking and even after explicitly setting I don't see the agent prompt being applied.
Here's my jbang code and the output follows
//DEPS io.github.copilot-community-sdk:copilot-sdk:1.0.12-SNAPSHOT
import com.github.copilot.sdk.*;
import com.github.copilot.sdk.json.*;
import java.util.ArrayList;
import java.util.List;
class hello {
public static void main(String[] args) throws Exception {
List<CustomAgentConfig> customAgents = new ArrayList<>();
customAgents.add(new CustomAgentConfig()
.setName("test")
.setDescription("Test agent for trying out the agent framework.")
.setPrompt(
"""
You are a helpful assistant. Always start every response with the phrase "🤖 AGENT ACTIVE 🤖" on its own line, followed by a blank line. This must appear in every reply without exception.
"""));
try (var client = new CopilotClient()) {
client.start().get();
var session = client.createSession(new SessionConfig()
.setCustomAgents(customAgents)
.setAgent("test")
.setOnPermissionRequest(PermissionHandler.APPROVE_ALL)).get();
var availableAgents = session.listAgents().get();
System.out.println("Available agents:");
for (var agent : availableAgents) {
System.out.println("- name=" + agent.getName()
+ " displayName=" + agent.getDisplayName());
}
var current = session.getCurrentAgent().get();
System.out.println(
"Current agent after createSession: " + (current == null ? "<default>" : current.getName()));
var response1 = session.sendAndWait(new MessageOptions().setPrompt("Say hello!")).get().getData().content();
System.out.println("Response to 'Say hello!':\n" + response1);
// Try explicit select
var selected = session.selectAgent("test").get();
System.out.println("selectAgent(\"test\") returned: " + (selected == null ? "<null>" : selected.getName()));
current = session.getCurrentAgent().get();
System.out
.println("Current agent after selectAgent: " + (current == null ? "<default>" : current.getName()));
var response2 = session.sendAndWait(new MessageOptions().setPrompt("Say hello again!")).get().getData().content();
System.out.println("Response to 'Say hello again!':\n" + response2);
}
}
}
Output is the following:
[jbang] Building jar for hello-copilot.java...
Mar 13, 2026 10:45:49 AM com.github.copilot.sdk.CopilotClient lambda$1
INFO: Copilot client connected
Available agents:
- name=test displayName=test
Current agent after createSession: <default>
Response to 'Say hello!':
Hello! 👋 How can I help you today?
selectAgent("test") returned: test
Current agent after selectAgent: test
Response to 'Say hello again!':
Hello again! 😄 What can I help you with?
I'm expecting the response to contain the AGENT ACTIVE wording as I do in the vscode chat mode.
Versions
SDK 1.0.12-SNAPSHOT latest from main, needed for compatibility with CLI
GitHub Copilot CLI 1.0.5.
Relevant log output
[jbang] Building jar for hello-copilot.java...
Mar 13, 2026 10:45:49 AM com.github.copilot.sdk.CopilotClient lambda$1
INFO: Copilot client connected
Available agents:
- name=test displayName=test
Current agent after createSession: <default>
Response to 'Say hello!':
Hello! 👋 How can I help you today?
selectAgent("test") returned: test
Current agent after selectAgent: test
Response to 'Say hello again!':
Hello again! 😄 What can I help you with?Code of Conduct
- I agree to follow this project's Code of Conduct
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels