Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 5, 2026

After artifact refactoring, files are uploaded to agent-artifacts/ without the tmp/gh-aw/ prefix. This caused two issues: (1) files weren't flattened to root where commands expect them, and (2) the logs command couldn't find agent_output.json for metrics extraction.

Changes

Artifact Flattening

  • Detect structure dynamically: Check if agent-artifacts/tmp/gh-aw/ exists to distinguish old vs new artifact layout
  • Flatten from appropriate source: Use tmp/gh-aw/ for old structure, agent-artifacts/ directly for new structure
  • Maintain backward compatibility: Old workflows continue working without modification
// Before: Hard-coded check for old structure
tmpGhAwPath := filepath.Join(agentArtifactsDir, "tmp", "gh-aw")
if _, err := os.Stat(tmpGhAwPath); os.IsNotExist(err) {
    return nil  // Exit early - new artifacts remain nested
}

// After: Detect and handle both structures
var sourcePath string
if _, err := os.Stat(tmpGhAwPath); err == nil {
    sourcePath = tmpGhAwPath  // Old structure
} else {
    sourcePath = agentArtifactsDir  // New structure
}

Agent Output File Detection

  • Updated metrics extraction: Modified extractMissingToolsFromRun and extractNoopsFromRun to first check for agent_output.json at root (new flattened structure) before falling back to agent-output directory (old structure)
  • Fixed file lookup: Changed from looking for artifact name (agent-output) to actual filename (agent_output.json)
// Now checks for flattened file first
agentOutputJSONPath := filepath.Join(runDir, "agent_output.json")
if stat, err := os.Stat(agentOutputJSONPath); err == nil && !stat.IsDir() {
    resolvedAgentOutputFile = agentOutputJSONPath  // New flattened structure
} else {
    // Fall back to old structure
    agentOutputPath := filepath.Join(runDir, constants.AgentOutputArtifactName)
    // ... existing logic
}

Files like aw_info.json and agent_output.json now correctly flatten to root and can be found by the logs command for metrics extraction regardless of artifact structure.

Original prompt

Review the download logs logic to account for the artifact refactoreing. See this output:

✓ Downloaded artifacts for run 20701642088 to .github/aw/logs/run-20701642088
🔍 Artifact file count: 160
🔍   • agent-artifacts/agent-stdio.log
🔍   • agent-artifacts/aw-prompts/prompt.txt
🔍   • agent-artifacts/aw_info.json
🔍   • agent-artifacts/mcp-logs/safeoutputs/server.log
🔍   • agent-artifacts/sandbox/firewall/logs/access.log
🔍   • agent-artifacts/sandbox/firewall/logs/cache.log
🔍   • agent_output.json
🔍   • cache-memory/README.md
🔍   • cache-memory/analysis/file_sizes.txt
🔍   • cache-memory/analysis/permissions.txt
🔍   • cache-memory/analysis/safe_outputs.txt
🔍   • cache-memory/analysis/tidy-permissions-investigation.md
🔍   … 148 more files omitted
🔍 Beginning metric extraction in .github/aw/logs/run-20701642088
ℹ Detected GitHub Copilot agent run, using specialized parser
⚠ No aw_info.json found at .github/aw/logs/run-20701642088/aw_info.json
ℹ No safe output artifact found at .github/aw/logs/run-20701642088/agent-output for run 20701642088

The file flattening is not working properly and the go logic cannot find aw_info.json and agent_output.json. Fix the file flatening.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Review download logs logic for artifact refactoring Fix artifact flattening for refactored artifact structure Jan 5, 2026
Copilot AI requested a review from pelikhan January 5, 2026 02:41
@pelikhan pelikhan marked this pull request as ready for review January 5, 2026 02:42
@pelikhan
Copy link
Contributor

pelikhan commented Jan 5, 2026

@copilot the logic to find the agent safe output also need to be updated. See This output:

🔍 Artifact file count: 160
🔍   • agent-stdio.log
🔍   • agent_output.json
🔍   • aw-prompts/prompt.txt
🔍   • aw_info.json
🔍   • cache-memory/README.md
🔍   • cache-memory/analysis/file_sizes.txt
🔍   • cache-memory/analysis/permissions.txt
🔍   • cache-memory/analysis/safe_outputs.txt
🔍   • cache-memory/analysis/tidy-permissions-investigation.md
🔍   • cache-memory/analysis/trigger_frequency.txt
🔍   • cache-memory/analysis/triggers.txt
🔍   • cache-memory/audits/2025-10-12-afternoon.json
🔍   … 148 more files omitted
🔍 Beginning metric extraction in .github/aw/logs/run-20701642088
ℹ Detected engine from aw_info.json: copilot
ℹ No safe output artifact found at .github/aw/logs/run-20701642088/agent-output for run 20701642088 

Copy link
Contributor Author

Copilot AI commented Jan 5, 2026

@copilot the logic to find the agent safe output also need to be updated. See This output:

🔍 Artifact file count: 160

...

Fixed in commit 5e960e8. The issue was that the code looked for agent-output (artifact name) instead of agent_output.json (actual flattened filename). Updated both extractMissingToolsFromRun and extractNoopsFromRun to first check for agent_output.json at root before falling back to old structure for backward compatibility.

Copilot AI changed the title Fix artifact flattening for refactored artifact structure Fix artifact flattening and file detection for refactored artifact structure Jan 5, 2026
@pelikhan pelikhan merged commit d28c10f into main Jan 5, 2026
88 of 90 checks passed
@pelikhan pelikhan deleted the copilot/review-download-logs-logic branch January 5, 2026 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants