MCPcopy Create free account
hub / github.com/openai/plugins / summarizeCodexEvents

Function summarizeCodexEvents

plugins/plugin-eval/src/core/benchmark-events.js:180–233  ·  view source on GitHub ↗
(events)

Source from the content-addressed store, hash-verified

178}
179
180export function summarizeCodexEvents(events) {
181 const errorMessages = [];
182 const toolNames = [];
183 const shellCommands = [];
184 const failedShellCommands = [];
185 let threadId = null;
186 let turnFailed = false;
187
188 for (const event of events) {
189 if (!threadId && typeof event.thread_id === "string") {
190 threadId = event.thread_id;
191 }
192
193 const errorMessage = collectErrorMessage(event);
194 if (errorMessage) {
195 errorMessages.push(errorMessage);
196 }
197
198 if (isToolEvent(event)) {
199 toolNames.push(extractToolName(event) || event.type || "tool");
200 }
201
202 if (isShellEvent(event)) {
203 const command = extractShellCommand(event) || event.type || "shell";
204 shellCommands.push(command);
205 if (isFailureEvent(event)) {
206 failedShellCommands.push(command);
207 }
208 }
209
210 if (event.type === "turn.failed") {
211 turnFailed = true;
212 }
213 }
214
215 const usage = extractLatestUsage(events);
216 const completed = events.some((event) => event.type === "turn.completed");
217 const failed = turnFailed || events.some((event) => event.type === "turn.cancelled");
218
219 return {
220 threadId,
221 eventCount: events.length,
222 ignoredLineCount: 0,
223 finalStatus: failed ? "failed" : completed ? "completed" : "unknown",
224 errorMessages,
225 toolCallCount: toolNames.length,
226 shellCommandCount: shellCommands.length,
227 failedShellCommandCount: failedShellCommands.length,
228 toolNames,
229 shellCommands,
230 usage,
231 usageAvailability: usage ? "present" : "unavailable",
232 };
233}

Callers 2

runBenchmarkFunction · 0.90

Calls 7

collectErrorMessageFunction · 0.85
isToolEventFunction · 0.85
extractToolNameFunction · 0.85
isShellEventFunction · 0.85
extractShellCommandFunction · 0.85
isFailureEventFunction · 0.85
extractLatestUsageFunction · 0.85

Tested by

no test coverage detected