Repository navigation
Report sub-agent failures, resolved models, and per-agent spend #66961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
8c945ad
Initial plan
Copilot 341915e
Report sub-agent failures and resolve model identities
Copilot 45c482b
Apply remaining changes
Copilot 7670436
Merge branch 'main' into copilot/audit-fix-sub-agent-rows
SivaKesava1 bc0ca7f
Plan review follow-up fixes
Copilot 6cc1063
Merge remote-tracking branch 'origin/main' into copilot/audit-fix-sub…
Copilot b1b16c6
Fix sub-agent attribution review findings
Copilot 7f4a8b4
Merge remote-tracking branch 'origin/main' into copilot/audit-fix-sub…
Copilot 3583930
Fix sub-agent attribution feedback
Copilot 3a009fa
Merge remote-tracking branch 'origin/main' into copilot/audit-fix-sub…
Copilot c1e4bb5
Fix subagent parser regressions
Copilot 23ff5ba
Merge remote-tracking branch 'origin/main' into copilot/audit-fix-sub…
Copilot 14ccbbd
Attribute sub-agent usage from unified sessions
Copilot 2d42908
Retain metrics-only sub-agent attribution
Copilot 12ae4a1
Merge remote-tracking branch 'origin/main' into copilot/audit-fix-sub…
Copilot 07b8af6
Keep metrics when sub-agent identity is missing
Copilot 22e8862
Avoid duplicate sub-agent instances from metrics
Copilot fd35d48
Restore requested sub-agent instance behavior
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,156 @@ | ||
| package cli | ||
|
|
||
| import ( | ||
| "encoding/json" | ||
| "os" | ||
| "path" | ||
| "regexp" | ||
| "strings" | ||
|
|
||
| "github.com/github/gh-aw/pkg/workflow" | ||
| ) | ||
|
|
||
| var ( | ||
| modelDateSuffix = regexp.MustCompile(`-[0-9]{4}(?:-[0-9]{2}-[0-9]{2}|[0-9]{4})$`) | ||
| claudeModelVersionSpelling = regexp.MustCompile(`^(claude-.+)-([0-9]+)-([0-9]+)$`) | ||
| ) | ||
|
|
||
| type modelIdentityResolver struct { | ||
| aliases map[string][]string | ||
| } | ||
|
|
||
| func newModelIdentityResolver(runDir string) *modelIdentityResolver { | ||
| aliases := workflow.BuiltinModelAliases() | ||
| infoPath := findAwInfoPath(runDir) | ||
| if infoPath != "" { | ||
| content, err := os.ReadFile(infoPath) | ||
| if err == nil { | ||
| var info struct { | ||
| Models []struct { | ||
| Model string `json:"model"` | ||
| Patterns []string `json:"patterns"` | ||
| } `json:"sub_agent_models"` | ||
| } | ||
| if json.Unmarshal(content, &info) == nil { | ||
| for _, model := range info.Models { | ||
| if model.Model != "" && len(model.Patterns) > 0 { | ||
| aliases[model.Model] = append([]string(nil), model.Patterns...) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| return &modelIdentityResolver{aliases: aliases} | ||
| } | ||
|
|
||
| func normalizeModelIdentity(model string) string { | ||
| model, _, _ = strings.Cut(strings.ToLower(strings.TrimSpace(model)), "?") | ||
| model = modelDateSuffix.ReplaceAllString(model, "") | ||
| return claudeModelVersionSpelling.ReplaceAllString(model, "$1-$2.$3") | ||
| } | ||
|
|
||
| func (resolver *modelIdentityResolver) resolve(model, provider string, observed []string) string { | ||
| normalized := normalizeModelIdentity(model) | ||
| patterns := resolver.patternsFor(normalized) | ||
| if len(patterns) == 0 { | ||
| return normalized | ||
| } | ||
| for _, candidate := range observed { | ||
| for _, pattern := range patterns { | ||
| if modelPatternMatches(pattern, candidate, provider) { | ||
| return normalizeModelIdentity(modelNameWithoutProvider(candidate)) | ||
| } | ||
| } | ||
| } | ||
| return normalized | ||
| } | ||
|
|
||
| func (resolver *modelIdentityResolver) matches(pattern, observed, provider string) bool { | ||
| patterns := resolver.patternsFor(normalizeModelIdentity(pattern)) | ||
| if len(patterns) == 0 { | ||
| patterns = []string{pattern} | ||
| } | ||
| for _, candidatePattern := range patterns { | ||
| if modelPatternMatches(candidatePattern, observed, provider) { | ||
| return true | ||
| } | ||
| } | ||
| return modelPatternMatches(pattern, observed, provider) | ||
| } | ||
|
|
||
| func (resolver *modelIdentityResolver) patternsFor(model string) []string { | ||
| var patterns []string | ||
| visited := make(map[string]bool) | ||
| var expand func(string) | ||
| expand = func(alias string) { | ||
| alias = normalizeModelIdentity(alias) | ||
| if visited[alias] { | ||
| return | ||
| } | ||
| visited[alias] = true | ||
| for _, pattern := range resolver.aliases[alias] { | ||
| nested := normalizeModelIdentity(pattern) | ||
| if !strings.ContainsAny(pattern, "/*?") && len(resolver.aliases[nested]) > 0 { | ||
| expand(nested) | ||
| continue | ||
| } | ||
| patterns = append(patterns, pattern) | ||
| } | ||
| } | ||
| expand(model) | ||
| return patterns | ||
| } | ||
|
|
||
| func modelPatternMatches(pattern, observed, provider string) bool { | ||
| pattern, _, _ = strings.Cut(strings.ToLower(pattern), "?") | ||
| observed, _, _ = strings.Cut(strings.ToLower(observed), "?") | ||
| originalObserved := observed | ||
| patternProvider, patternModel, patternQualified := strings.Cut(pattern, "/") | ||
| observedProvider, observedModel, observedQualified := strings.Cut(observed, "/") | ||
| if patternQualified { | ||
| if provider == "" && observedQualified { | ||
| provider = observedProvider | ||
| } | ||
| if provider != "" && normalizeModelProvider(patternProvider) != normalizeModelProvider(provider) { | ||
| return false | ||
| } | ||
| pattern = patternModel | ||
| } | ||
| if observedQualified { | ||
| if provider != "" && normalizeModelProvider(observedProvider) != normalizeModelProvider(provider) { | ||
| return modelPatternMatches(patternModel, originalObserved, "") | ||
| } | ||
| observed = observedModel | ||
| } | ||
| patterns := []string{pattern, normalizeModelIdentity(pattern)} | ||
| observedModels := []string{observed, normalizeModelIdentity(observed)} | ||
| for _, candidatePattern := range patterns { | ||
| for _, candidate := range observedModels { | ||
| if matched, err := path.Match(candidatePattern, candidate); err == nil && matched { | ||
| return true | ||
| } | ||
| } | ||
| } | ||
| return false | ||
| } | ||
|
|
||
| func normalizeModelProvider(provider string) string { | ||
| switch provider { | ||
| case "github", "copilot", "github-copilot": | ||
| return "github-copilot" | ||
| case "codex", "openai": | ||
| return "openai" | ||
| case "gemini", "google": | ||
| return "google" | ||
| default: | ||
| return provider | ||
| } | ||
| } | ||
|
|
||
| func modelNameWithoutProvider(model string) string { | ||
| _, name, qualified := strings.Cut(model, "/") | ||
| if qualified { | ||
| return name | ||
| } | ||
| return model | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.