-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathCustomAgentConfig.java
More file actions
212 lines (187 loc) · 5.48 KB
/
CustomAgentConfig.java
File metadata and controls
212 lines (187 loc) · 5.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
package com.github.copilot.sdk.json;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Configuration for a custom agent in a Copilot session.
* <p>
* Custom agents extend the capabilities of the base Copilot assistant with
* specialized behavior, tools, and prompts. Each agent can be referenced in
* messages using the {@code @agent-name} mention syntax.
*
* <h2>Example Usage</h2>
*
* <pre>{@code
* var agent = new CustomAgentConfig().setName("code-reviewer").setDisplayName("Code Reviewer")
* .setDescription("Reviews code for best practices").setPrompt("You are a code review expert...")
* .setTools(List.of("read_file", "search_code"));
*
* var config = new SessionConfig().setCustomAgents(List.of(agent));
* }</pre>
*
* @see SessionConfig#setCustomAgents(List)
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CustomAgentConfig {
@JsonProperty("name")
private String name;
@JsonProperty("displayName")
private String displayName;
@JsonProperty("description")
private String description;
@JsonProperty("tools")
private List<String> tools;
@JsonProperty("prompt")
private String prompt;
@JsonProperty("mcpServers")
private Map<String, Object> mcpServers;
@JsonProperty("infer")
private Boolean infer;
/**
* Gets the unique identifier name for this agent.
*
* @return the agent name used for {@code @mentions}
*/
public String getName() {
return name;
}
/**
* Sets the unique identifier name for this agent.
* <p>
* This name is used to mention the agent in messages (e.g.,
* {@code @code-reviewer}).
*
* @param name
* the agent identifier (alphanumeric and hyphens)
* @return this config for method chaining
*/
public CustomAgentConfig setName(String name) {
this.name = name;
return this;
}
/**
* Gets the human-readable display name.
*
* @return the display name shown to users
*/
public String getDisplayName() {
return displayName;
}
/**
* Sets the human-readable display name.
*
* @param displayName
* the friendly name for the agent
* @return this config for method chaining
*/
public CustomAgentConfig setDisplayName(String displayName) {
this.displayName = displayName;
return this;
}
/**
* Gets the agent description.
*
* @return the description of what this agent does
*/
public String getDescription() {
return description;
}
/**
* Sets a description of the agent's capabilities.
* <p>
* This helps users understand when to use this agent.
*
* @param description
* the agent description
* @return this config for method chaining
*/
public CustomAgentConfig setDescription(String description) {
this.description = description;
return this;
}
/**
* Gets the list of tool names available to this agent.
*
* @return the list of tool identifiers
*/
public List<String> getTools() {
return tools;
}
/**
* Sets the tools available to this agent.
* <p>
* These can reference both built-in tools and custom tools registered in the
* session.
*
* @param tools
* the list of tool names
* @return this config for method chaining
*/
public CustomAgentConfig setTools(List<String> tools) {
this.tools = tools;
return this;
}
/**
* Gets the system prompt for this agent.
*
* @return the agent's system prompt
*/
public String getPrompt() {
return prompt;
}
/**
* Sets the system prompt that defines this agent's behavior.
* <p>
* This prompt is used to customize the agent's responses and capabilities.
*
* @param prompt
* the system prompt
* @return this config for method chaining
*/
public CustomAgentConfig setPrompt(String prompt) {
this.prompt = prompt;
return this;
}
/**
* Gets the MCP server configurations for this agent.
*
* @return the MCP servers map
*/
public Map<String, Object> getMcpServers() {
return mcpServers;
}
/**
* Sets MCP (Model Context Protocol) servers available to this agent.
*
* @param mcpServers
* the MCP server configurations
* @return this config for method chaining
*/
public CustomAgentConfig setMcpServers(Map<String, Object> mcpServers) {
this.mcpServers = mcpServers;
return this;
}
/**
* Gets whether inference mode is enabled.
*
* @return the infer flag, or {@code null} if not set
*/
public Boolean getInfer() {
return infer;
}
/**
* Sets whether to enable inference mode for this agent.
*
* @param infer
* {@code true} to enable inference mode
* @return this config for method chaining
*/
public CustomAgentConfig setInfer(Boolean infer) {
this.infer = infer;
return this;
}
}