-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathCustomAgentConfig.java.html
More file actions
286 lines (254 loc) · 10.4 KB
/
Copy pathCustomAgentConfig.java.html
File metadata and controls
286 lines (254 loc) · 10.4 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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang=""><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>CustomAgentConfig.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">GitHub Copilot SDK :: Java</a> > <a href="index.source.html" class="el_package">com.github.copilot.rpc</a> > <span class="el_source">CustomAgentConfig.java</span></div><h1>CustomAgentConfig.java</h1><pre class="source lang-java linenums">/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------------------------------------------*/
package com.github.copilot.rpc;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.Optional;
/**
* 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)
* @since 1.0.0
*/
@JsonInclude(JsonInclude.Include.NON_NULL)
<span class="fc" id="L37">public class CustomAgentConfig {</span>
@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, McpServerConfig> mcpServers;
@JsonProperty("infer")
private Boolean infer;
@JsonProperty("skills")
private List<String> skills;
@JsonProperty("model")
private String model;
/**
* Gets the unique identifier name for this agent.
*
* @return the agent name used for {@code @mentions}
*/
public String getName() {
<span class="fc" id="L72"> return name;</span>
}
/**
* 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) {
<span class="fc" id="L86"> this.name = name;</span>
<span class="fc" id="L87"> return this;</span>
}
/**
* Gets the human-readable display name.
*
* @return the display name shown to users
*/
public String getDisplayName() {
<span class="fc" id="L96"> return displayName;</span>
}
/**
* 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) {
<span class="fc" id="L107"> this.displayName = displayName;</span>
<span class="fc" id="L108"> return this;</span>
}
/**
* Gets the agent description.
*
* @return the description of what this agent does
*/
public String getDescription() {
<span class="fc" id="L117"> return description;</span>
}
/**
* 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) {
<span class="fc" id="L130"> this.description = description;</span>
<span class="fc" id="L131"> return this;</span>
}
/**
* Gets the list of tool names available to this agent.
*
* @return the list of tool identifiers
*/
public List<String> getTools() {
<span class="fc bfc" id="L140" title="All 2 branches covered."> return tools == null ? null : Collections.unmodifiableList(tools);</span>
}
/**
* 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) {
<span class="fc" id="L154"> this.tools = tools;</span>
<span class="fc" id="L155"> return this;</span>
}
/**
* Gets the system prompt for this agent.
*
* @return the agent's system prompt
*/
public String getPrompt() {
<span class="fc" id="L164"> return prompt;</span>
}
/**
* 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) {
<span class="fc" id="L177"> this.prompt = prompt;</span>
<span class="fc" id="L178"> return this;</span>
}
/**
* Gets the MCP server configurations for this agent.
*
* @return the MCP servers map
*/
public Map<String, McpServerConfig> getMcpServers() {
<span class="fc bfc" id="L187" title="All 2 branches covered."> return mcpServers == null ? null : Collections.unmodifiableMap(mcpServers);</span>
}
/**
* 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, McpServerConfig> mcpServers) {
<span class="fc" id="L198"> this.mcpServers = mcpServers;</span>
<span class="fc" id="L199"> return this;</span>
}
/**
* Gets whether inference mode is enabled.
*
* @return an {@link java.util.Optional} containing the infer flag, or
* {@link java.util.Optional#empty()} if not set
*/
@JsonIgnore
public Optional<Boolean> getInfer() {
<span class="fc" id="L210"> return Optional.ofNullable(infer);</span>
}
/**
* 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) {
<span class="fc" id="L221"> this.infer = infer;</span>
<span class="fc" id="L222"> return this;</span>
}
/**
* Clears the infer setting, reverting to the default behavior.
*
* @return this instance for method chaining
*/
public CustomAgentConfig clearInfer() {
<span class="fc" id="L231"> this.infer = null;</span>
<span class="fc" id="L232"> return this;</span>
}
/**
* Gets the list of skill names to preload into this agent's context.
*
* @return the list of skill names, or {@code null} if not set
*/
public List<String> getSkills() {
<span class="fc bfc" id="L241" title="All 2 branches covered."> return skills == null ? null : Collections.unmodifiableList(skills);</span>
}
/**
* Sets the list of skill names to preload into this agent's context.
* <p>
* When set, the full content of each listed skill is eagerly injected into the
* agent's context at startup. Skills are resolved by name from the session's
* configured skill directories
* ({@link SessionConfig#setSkillDirectories(List)}). When omitted, no skills
* are injected (opt-in model).
*
* @param skills
* the list of skill names to preload
* @return this config for method chaining
*/
public CustomAgentConfig setSkills(List<String> skills) {
<span class="fc" id="L258"> this.skills = skills;</span>
<span class="fc" id="L259"> return this;</span>
}
/**
* Gets the model identifier for this agent.
*
* @return the model identifier, or {@code null} if not set
*/
public String getModel() {
<span class="fc" id="L268"> return model;</span>
}
/**
* Sets the model identifier for this agent.
* <p>
* When set, the runtime will attempt to use this model for the agent, falling
* back to the parent session model if unavailable.
*
* @param model
* the model identifier (e.g., "claude-haiku-4.5")
* @return this config for method chaining
*/
public CustomAgentConfig setModel(String model) {
<span class="fc" id="L282"> this.model = model;</span>
<span class="fc" id="L283"> return this;</span>
}
}
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.14.202510111229</span></div></body></html>