Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/patch-canonical-copilot-event-log.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions .github/workflows/smoke-copilot-aoai-entra.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions actions/setup/js/log_parser_bootstrap.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ async function runLogParser(options) {
// Generate lightweight plain text summary for core.info and Copilot CLI style for step summary
if (logEntries && Array.isArray(logEntries) && logEntries.length > 0) {
// Extract model from init entry if available
const initEntry = logEntries.find(entry => entry.type === "system" && entry.subtype === "init");
const model = initEntry?.model || null;
const initEntry = logEntries.find(entry => (entry.type === "system" && entry.subtype === "init") || entry.type === "session.init");
const model = initEntry?.model || initEntry?.data?.model || null;

const plainTextSummary = generatePlainTextSummary(logEntries, {
model,
Expand Down
27 changes: 20 additions & 7 deletions actions/setup/js/log_parser_format.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
* @property {(text: string) => number} estimateTokens
* @property {(ms: number) => string} formatDuration
* @property {(text: string) => string} unfenceMarkdown
* @property {(entries: Array<any>) => boolean} isCopilotEventLogEntries
* @property {(entries: Array<any>) => Array<any>} convertCopilotEventsToLegacyLogEntries
* @property {number} MAX_AGENT_TEXT_LENGTH
* @property {string} SIZE_LIMIT_WARNING
*/
Expand Down Expand Up @@ -48,12 +50,21 @@ function createLogParserFormatters(deps) {
estimateTokens,
formatDuration,
unfenceMarkdown,
isCopilotEventLogEntries,
convertCopilotEventsToLegacyLogEntries,
MAX_AGENT_TEXT_LENGTH,
SIZE_LIMIT_WARNING,
} = deps;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice extraction of normalizeEntriesForRendering — keeps the conversion concern in one place.

const INTERNAL_TOOLS = ["Read", "Write", "Edit", "MultiEdit", "LS", "Grep", "Glob", "TodoWrite"];

function normalizeEntriesForRendering(logEntries) {
if (isCopilotEventLogEntries(logEntries)) {
return convertCopilotEventsToLegacyLogEntries(logEntries);
}
return logEntries;
}

/**
* Generates markdown summary from conversation log entries
* This is the core shared logic between Claude and Copilot log parsers
Expand All @@ -70,8 +81,9 @@ function createLogParserFormatters(deps) {
*/
function generateConversationMarkdown(logEntries, options) {
const { formatToolCallback, formatInitCallback, summaryTracker } = options;
const renderEntries = normalizeEntriesForRendering(logEntries);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call normalizing once before collectToolUsePairs; avoids repeated conversion downstream.


const toolUsePairs = collectToolUsePairs(logEntries);
const toolUsePairs = collectToolUsePairs(renderEntries);

let markdown = "";
let sizeLimitReached = false;
Expand All @@ -85,7 +97,7 @@ function createLogParserFormatters(deps) {
return true;
}

const initEntry = logEntries.find(entry => entry.type === "system" && entry.subtype === "init");
const initEntry = renderEntries.find(entry => entry.type === "system" && entry.subtype === "init");

if (initEntry && formatInitCallback) {
if (!addContent("## 🚀 Initialization\n\n")) {
Expand All @@ -110,7 +122,7 @@ function createLogParserFormatters(deps) {
return { markdown, commandSummary: [], sizeLimitReached };
}

for (const entry of logEntries) {
for (const entry of renderEntries) {
if (sizeLimitReached) break;

if (entry.type === "assistant" && entry.message?.content) {
Expand Down Expand Up @@ -158,7 +170,7 @@ function createLogParserFormatters(deps) {

const commandSummary = [];

for (const entry of logEntries) {
for (const entry of renderEntries) {
if (entry.type === "assistant" && entry.message?.content) {
for (const content of entry.message.content) {
if (content.type === "tool_use") {
Expand Down Expand Up @@ -522,8 +534,9 @@ function createLogParserFormatters(deps) {
}

function generateSummaryLines(logEntries) {
const renderEntries = normalizeEntriesForRendering(logEntries);
const lines = [];
const toolUsePairs = collectToolUsePairs(logEntries);
const toolUsePairs = collectToolUsePairs(renderEntries);

const state = {
conversationLineCount: 0,
Expand All @@ -532,7 +545,7 @@ function createLogParserFormatters(deps) {
traceEventCount: 0,
};

for (const entry of logEntries) {
for (const entry of renderEntries) {
if (state.conversationLineCount >= state.maxConversationLines) {
state.conversationTruncated = true;
break;
Expand Down Expand Up @@ -569,7 +582,7 @@ function createLogParserFormatters(deps) {
lines.push("");
}

appendStatistics(lines, logEntries, toolUsePairs);
appendStatistics(lines, renderEntries, toolUsePairs);

return lines;
}
Expand Down
Loading
Loading