Class: AgentHarness::Providers::GithubCopilot
Constant Summary
collapse
- MODEL_PATTERN =
/^gpt-[\d.o-]+(?:-turbo)?(?:-mini)?$/i
- JSON_OUTPUT_MIN_VERSION =
Gem::Version.new("0.0.422").freeze
- SMOKE_TEST_CONTRACT =
{
prompt: "Reply with exactly OK.",
expected_output: "OK",
timeout: 30,
require_output: true,
success_message: "Smoke test passed"
}.freeze
Constants inherited
from Base
Base::COMMON_ERROR_PATTERNS, Base::DEFAULT_SMOKE_TEST_CONTRACT
Instance Attribute Summary
Attributes inherited from Base
#config, #executor, #logger
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#configure, #initialize, #sandboxed_environment?
Methods included from Adapter
#build_mcp_flags, #fetch_mcp_servers, #health_status, included, metadata_package_name, normalize_metadata_installation, normalize_metadata_source_type, normalize_metadata_version_requirement, #parse_rate_limit_reset, #smoke_test, #smoke_test_contract, #supported_mcp_transports, #supports_dangerous_mode?, #supports_mcp?, #supports_text_mode?, #supports_tool_control?, #validate_config, #validate_mcp_servers!
Class Method Details
.binary_name ⇒ Object
27
28
29
|
# File 'lib/agent_harness/providers/github_copilot.rb', line 27
def binary_name
"github-copilot-cli"
end
|
.discover_models ⇒ Object
71
72
73
74
75
76
77
78
79
|
# File 'lib/agent_harness/providers/github_copilot.rb', line 71
def discover_models
return [] unless available?
[
{name: "gpt-4o", family: "gpt-4o", tier: "standard", provider: "github_copilot"},
{name: "gpt-4o-mini", family: "gpt-4o-mini", tier: "mini", provider: "github_copilot"},
{name: "gpt-4-turbo", family: "gpt-4-turbo", tier: "advanced", provider: "github_copilot"}
]
end
|
.firewall_requirements ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/agent_harness/providers/github_copilot.rb', line 48
def firewall_requirements
{
domains: [
"copilot-proxy.githubusercontent.com",
"api.githubcopilot.com",
"copilot-telemetry.githubusercontent.com",
"default.exp-tas.com",
"copilot-completions.githubusercontent.com"
],
ip_ranges: []
}
end
|
.instruction_file_paths ⇒ Object
61
62
63
64
65
66
67
68
69
|
# File 'lib/agent_harness/providers/github_copilot.rb', line 61
def instruction_file_paths
[
{
path: ".github/copilot-instructions.md",
description: "GitHub Copilot agent instructions",
symlink: true
}
]
end
|
.model_family(provider_model_name) ⇒ Object
85
86
87
|
# File 'lib/agent_harness/providers/github_copilot.rb', line 85
def model_family(provider_model_name)
provider_model_name
end
|
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/agent_harness/providers/github_copilot.rb', line 36
def provider_metadata_overrides
{
auth: {
service: :github,
api_family: :github_copilot
},
identity: {
bot_usernames: ["github-copilot[bot]"]
}
}
end
|
.provider_model_name(family_name) ⇒ Object
89
90
91
|
# File 'lib/agent_harness/providers/github_copilot.rb', line 89
def provider_model_name(family_name)
family_name
end
|
.provider_name ⇒ Object
23
24
25
|
# File 'lib/agent_harness/providers/github_copilot.rb', line 23
def provider_name
:github_copilot
end
|
.smoke_test_contract ⇒ Object
81
82
83
|
# File 'lib/agent_harness/providers/github_copilot.rb', line 81
def smoke_test_contract
SMOKE_TEST_CONTRACT
end
|
.supports_model_family?(family_name) ⇒ Boolean
93
94
95
|
# File 'lib/agent_harness/providers/github_copilot.rb', line 93
def supports_model_family?(family_name)
MODEL_PATTERN.match?(family_name)
end
|
Instance Method Details
#auth_type ⇒ Object
150
151
152
|
# File 'lib/agent_harness/providers/github_copilot.rb', line 150
def auth_type
:oauth
end
|
#capabilities ⇒ Object
123
124
125
126
127
128
129
130
131
132
133
|
# File 'lib/agent_harness/providers/github_copilot.rb', line 123
def capabilities
{
streaming: false,
file_upload: false,
vision: false,
tool_use: true,
json_mode: false,
mcp: false,
dangerous_mode: true
}
end
|
#configuration_schema ⇒ Object
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/agent_harness/providers/github_copilot.rb', line 106
def configuration_schema
{
fields: [
{
name: :model,
type: :string,
label: "Model",
required: false,
hint: "Copilot model identifier (for example gpt-4o or gpt-4o-mini)",
accepts_arbitrary: true
}
],
auth_modes: [:oauth],
openai_compatible: false
}
end
|
#dangerous_mode_flags(probe_timeout: nil, env: {}) ⇒ Object
135
136
137
138
139
|
# File 'lib/agent_harness/providers/github_copilot.rb', line 135
def dangerous_mode_flags(probe_timeout: nil, env: {})
return [] unless supports_json_output_format?(probe_timeout: probe_timeout, env: env)
["--allow-all"]
end
|
#display_name ⇒ Object
102
103
104
|
# File 'lib/agent_harness/providers/github_copilot.rb', line 102
def display_name
"GitHub Copilot CLI"
end
|
#error_patterns ⇒ Object
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
# File 'lib/agent_harness/providers/github_copilot.rb', line 169
def error_patterns
{
auth_expired: [
/not.?authorized/i,
/access.?denied/i,
/permission.?denied/i,
/not.?enabled/i,
/subscription.?required/i
],
rate_limited: [
/usage.?limit/i,
/rate.?limit/i
],
transient: [
/connection.?error/i,
/timeout/i,
/try.?again/i
],
permanent: [
/invalid.?command/i,
/unknown.?flag/i
]
}
end
|
#execution_semantics ⇒ Object
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
# File 'lib/agent_harness/providers/github_copilot.rb', line 154
def execution_semantics
{
prompt_delivery: :arg,
output_format: :text,
sandbox_aware: false,
uses_subcommand: false,
non_interactive_flag: "-p",
legitimate_exit_codes: [0],
stderr_is_diagnostic: true,
parses_rate_limit_reset: false
}
end
|
#name ⇒ Object
98
99
100
|
# File 'lib/agent_harness/providers/github_copilot.rb', line 98
def name
"github_copilot"
end
|
#send_message(prompt:, **options) ⇒ Object
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
|
# File 'lib/agent_harness/providers/github_copilot.rb', line 198
def send_message(prompt:, **options)
log_debug("send_message_start", prompt_length: prompt.length, options: options.keys)
options = normalize_provider_runtime(options)
options = normalize_mcp_servers(options)
validate_mcp_servers!(options[:mcp_servers]) if options[:mcp_servers]&.any?
timeout = options[:timeout] || @config.timeout || default_timeout
raise TimeoutError, "Command timed out before execution started" if timeout <= 0
env = build_env(options)
options = options.merge(_version_probe_timeout: [timeout, 5].min, _command_env: env)
start_time = Time.now
command = build_command(prompt, options)
preparation = build_execution_preparation(options)
remaining_timeout = timeout - (Time.now - start_time)
raise TimeoutError, "Command timed out before execution started" if remaining_timeout <= 0
json_output_requested = command.include?("--output-format") && command.include?("json")
result = execute_with_timeout(
command,
timeout: remaining_timeout,
env: env,
preparation: preparation,
**command_execution_options(options)
)
duration = Time.now - start_time
response = parse_response(result, duration: duration, json_output_requested: json_output_requested)
runtime = options[:provider_runtime]
effective_runtime_model = normalized_model_name(runtime&.model)
if effective_runtime_model
response = Response.new(
output: response.output,
exit_code: response.exit_code,
duration: response.duration,
provider: response.provider,
model: effective_runtime_model,
tokens: response.tokens,
metadata: response.metadata,
error: response.error
)
end
track_tokens(response) if response.tokens
log_debug("send_message_complete", duration: duration, tokens: response.tokens)
response
rescue McpConfigurationError, McpUnsupportedError, McpTransportUnsupportedError
raise
rescue => e
handle_error(e, prompt: prompt, options: options)
end
|
#session_flags(session_id) ⇒ Object
145
146
147
148
|
# File 'lib/agent_harness/providers/github_copilot.rb', line 145
def session_flags(session_id)
return [] unless session_id && !session_id.empty?
["--resume", session_id]
end
|
#supports_sessions? ⇒ Boolean
141
142
143
|
# File 'lib/agent_harness/providers/github_copilot.rb', line 141
def supports_sessions?
true
end
|
#supports_token_counting? ⇒ Boolean
194
195
196
|
# File 'lib/agent_harness/providers/github_copilot.rb', line 194
def supports_token_counting?
supports_json_output_format?
end
|