MCPcopy Create free account
hub / github.com/github/gh-aw / TestExtractToolName

Function TestExtractToolName

pkg/cli/copilot_agent_test.go:237–320  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

235}
236
237func TestExtractToolName(t *testing.T) {
238 tests := []struct {
239 name string
240 line string
241 expected string
242 }{
243 {
244 name: "extracts from 'tool:' pattern",
245 line: "Using tool: github_search",
246 expected: "github_search",
247 },
248 {
249 name: "extracts from 'calling' pattern",
250 line: "Calling: write_file",
251 expected: "write_file",
252 },
253 {
254 name: "extracts from 'executing' pattern",
255 line: "Executing: bash_command",
256 expected: "bash_command",
257 },
258 {
259 name: "extracts from 'using tool' pattern",
260 line: "Using tool: read_operation",
261 expected: "read_operation",
262 },
263 {
264 name: "returns empty for no match",
265 line: "Just a regular log line",
266 expected: "",
267 },
268 // False positive prevention: common English words near "tool" without colon separator
269 {
270 name: "does not extract 'calls' from 'tool calls' in prose",
271 line: "The agent tool calls a command",
272 expected: "",
273 },
274 {
275 name: "does not extract 'call' from 'tool call' without colon",
276 line: "Making a tool call to the API",
277 expected: "",
278 },
279 {
280 name: "does not extract 'or' from 'tool or' in prose",
281 line: "The tool or alternative approach",
282 expected: "",
283 },
284 {
285 name: "does not extract 'for' from 'tool for' in prose",
286 line: "Use a tool for building the project",
287 expected: "",
288 },
289 {
290 name: "does not extract word from 'calling' without colon",
291 line: "The agent is calling a function here",
292 expected: "",
293 },
294 // Bullet point format

Callers

nothing calls this directly

Calls 3

extractToolNameFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected