Skip to content

Bug: Fix Missing LLM Metrics (Model, Cost) in New PR Comments #70

Closed

Description

@integry

🎯 Goal

Fix the bug where new Pull Requests and log comments show incomplete or "unknown" LLM metrics (e.g., Cost: $unknown, missing model name). All metrics should be displayed correctly, similar to how they appear in follow-up comments.

📝 Context

This task is related to #69, which ensures metrics are stored persistently. This issue focuses on displaying them in GitHub.

The claudeResult object passed to completePostProcessing in src/worker.js already contains the model, conversationId, and finalResult (with cost/turns). The functions in src/githubService.js are just not using them correctly.

We should enhance generatePRBody and generateClaudeLogsComment to be as detailed as generateCompletionComment (in src/worker.js), which already has logic for this.

🚀 Implementation Steps

  1. File: src/githubService.js

    • Action: Modify the generatePRBody function (around line 128).
    • Logic: Add the LLM Model and Conversation ID, and make cost/turn parsing more robust.
    • Suggestion:
      // ... inside generatePRBody ...
      body += `- **Execution Time**: ${executionTime}s\n`;
      body += `- **Generated**: ${timestamp}\n`;
      
      // ADD THIS:
      if (claudeResult?.model) {
          body += `- **LLM Model**: ${claudeResult.model}\n`;
      }
      
      if (claudeResult?.finalResult) {
          const result = claudeResult.finalResult;
          // Use '??' for robust fallback
          body += `- **Claude Turns**: ${result.num_turns ?? 'unknown'}\n`;
          body += `- **Cost**: $${result.cost_usd ?? 'unknown'}\n`; 
          body += `- **Session ID**: \`${claudeResult.sessionId || 'unknown'}\`\n`;
          // ADD THIS:
          if (claudeResult.conversationId) {
              body += `- **Conversation ID**: \`${claudeResult.conversationId}\`\n`;
          }
      }
      // ...
  2. File: src/githubService.js

    • Action: Modify the generateClaudeLogsComment function (around line 190).
    • Logic: Add the LLM Model and Conversation ID to the statistics section.
    • Suggestion:
      // ... inside generateClaudeLogsComment ...
      comment += `**Session ID**: \`${claudeResult?.sessionId || 'unknown'}\`\n`;
      // ADD THIS:
      if (claudeResult?.conversationId) {
          comment += `**Conversation ID**: \`${claudeResult.conversationId}\`\n`;
      }
      comment += `**Timestamp**: ${new Date().toISOString()}\n\n`;
      
      // Add execution details
      if (claudeResult?.finalResult) {
          // ...
          comment += `### 📊 Execution Statistics\n\n`;
          comment += `- **Success**: ${claudeResult.success ? 'Yes' : 'No'}\n`;
          // ADD THIS:
          if (claudeResult?.model) {
              comment += `- **LLM Model**: ${claudeResult.model}\n`;
          }
          comment += `- **Total Turns**: ${result.num_turns ?? 'unknown'}\n`;
          // ...
          comment += `- **Cost**: $${result.cost_usd ?? 'unknown'}\n`;
      // ...

Activity

  1. propr-dev commented on Sep 17, 2025

    @propr-dev
    Contributor

    🤖 AI processing has started for this issue using claude-opus-4-20250514 model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Model: claude-opus-4-20250514
    • Branch: ai-fix/70-bug-fix-missing-llm-metri-20250917-0948-claude-opus-4-20250514-zfr
    • Base Branch: main
    • Worktree: issue-70-20250917-0948-claude-opus-4-20250514-zfr
  2. added a commit that references this issue on Sep 17, 2025
  3. added a commit that references this issue on Sep 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions