(runDir string)
| 960 | } |
| 961 | |
| 962 | func extractSubagentModelRequests(runDir string) []SubagentModelRequest { |
| 963 | agentStdioPath := findAgentStdioFile(runDir) |
| 964 | if agentStdioPath == "" { |
| 965 | return nil |
| 966 | } |
| 967 | |
| 968 | file, err := os.Open(agentStdioPath) |
| 969 | if err != nil { |
| 970 | return nil |
| 971 | } |
| 972 | defer file.Close() |
| 973 | |
| 974 | type key struct { |
| 975 | agent string |
| 976 | model string |
| 977 | } |
| 978 | counts := make(map[key]int) |
| 979 | |
| 980 | reader := bufio.NewReader(file) |
| 981 | for { |
| 982 | line, readErr := reader.ReadString('\n') |
| 983 | line = strings.TrimSpace(line) |
| 984 | if line != "" { |
| 985 | matches := subagentDispatchPattern.FindAllStringSubmatch(line, -1) |
| 986 | for _, m := range matches { |
| 987 | if len(m) < 3 { |
| 988 | continue |
| 989 | } |
| 990 | agentName := strings.TrimSpace(m[1]) |
| 991 | requestedModel := strings.TrimSpace(m[2]) |
| 992 | if agentName == "" || requestedModel == "" { |
| 993 | continue |
| 994 | } |
| 995 | counts[key{agent: agentName, model: requestedModel}]++ |
| 996 | } |
| 997 | } |
| 998 | |
| 999 | if readErr == io.EOF { |
| 1000 | break |
| 1001 | } |
| 1002 | if readErr != nil { |
| 1003 | return nil |
| 1004 | } |
| 1005 | } |
| 1006 | |
| 1007 | rows := make([]SubagentModelRequest, 0, len(counts)) |
| 1008 | for k, n := range counts { |
| 1009 | rows = append(rows, SubagentModelRequest{ |
| 1010 | AgentName: k.agent, |
| 1011 | RequestedModel: k.model, |
| 1012 | InvocationCount: n, |
| 1013 | }) |
| 1014 | } |
| 1015 | slices.SortStableFunc(rows, func(a, b SubagentModelRequest) int { |
| 1016 | if a.AgentName != b.AgentName { |
| 1017 | if a.AgentName < b.AgentName { |
| 1018 | return -1 |
| 1019 | } |
no test coverage detected