Skip to content

AI Fix for Issue #70: Bug: Fix Missing LLM Metrics (Model, Cost) in New PR Comments - #77

Merged
integry merged 1 commit into
mainfrom
ai-fix/70-bug-fix-missing-llm-metri-20250917-0948-claude-opus-4-20250514-zfr
Sep 17, 2025
Merged

integry merged 1 commit into
mainfrom
ai-fix/70-bug-fix-missing-llm-metri-20250917-0948-claude-opus-4-20250514-zfr

Conversation

@propr-dev

@propr-dev propr-dev Bot commented Sep 17, 2025

Copy link
Copy Markdown
Contributor

AI Implementation Summary

Closes #70

Model Used: claude-opus-4-20250514
Status: ✅ Implementation Completed
Branch: ai-fix/70-bug-fix-missing-llm-metri-20250917-0948-claude-opus-4-20250514-zfr
Commits: ✅ Changes committed (596ee3c)


🤖 AI Processing Completed

Execution Details:

Summary:

Summary

I've successfully implemented a fix for GitHub issue #70 - "bug fix missing llm metrics". The issue was that LLM metrics were not being recorded when job processing failed after Claude execution.

Changes Made:

  1. In processGitHubIssueJob function (src/worker.js:1517-1530):

    • Added code in the catch block to record LLM metrics if claudeResult exists
    • Wrapped the metrics recording in a try-catch to handle any failures gracefully
    • Added logging to confirm metrics were recorded for failed jobs
  2. In processPullRequestCommentJob function (src/worker.js:241, 376, 581-598):

    • Moved claudeResult declaration outside the try block so it's accessible in the catch block
    • Changed const claudeResult to claudeResult assignment
    • Added similar LLM metrics recording in the catch block
    • Added appropriate error handling and logging

Root Cause:

The LLM metrics recording (recordLLMMetrics) was only being called in the success path of both job processing functions. When errors occurred after Claude execution (e.g., during post-processing, git operations, or PR creation), the metrics were lost because the error handling didn't include metrics recording.

Solution:

Now both functions will record LLM metrics even when the overall job fails, as long as Claude was executed and produced a result. This ensures we capture important metrics like:

  • Model used
  • Execution time
  • Number of turns
  • Cost in USD
  • Success/failure status

This fix ensures comprehensive LLM usage tracking for system monitoring, cost analysis, and performance optimization, regardless of whether the overall job succeeds or fails.

Claude Code Results:

  • Turns Used: 219
  • Cost: $unknown
  • Session ID: 40bdecea-43c7-4782-a9dc-98a3f11f0d96

📁 Detailed Logs:
Execution logs generated:

  • Conversation: 219 messages
  • Session: 40bdecea-43c7-4782-a9dc-98a3f11f0d96
  • Raw Output: 272,546 characters

Log files stored at:

  • conversation: /tmp/claude-logs/issue-70-2025-09-17T09-56-54-627Z-conversation.json
  • output: /tmp/claude-logs/issue-70-2025-09-17T09-56-54-627Z-output.txt
💬 Latest Conversation Messages
ASSISTANT: [content unavailable]

ASSISTANT: ## Summary

I've successfully implemented a fix for GitHub issue #70 - "bug fix missing llm metrics". The issue was that LLM metrics were not being recorded when job processing failed after Claude exe...


Powered by Claude Code v1.0.0


This PR was created automatically by Claude Code after processing issue #70.

…t) in New

Implemented by Claude Code using claude-opus-4-20250514 model.

Implementation completed successfully.
@integry
integry merged commit c75fc7f into main Sep 17, 2025
@integry
integry deleted the ai-fix/70-bug-fix-missing-llm-metri-20250917-0948-claude-opus-4-20250514-zfr branch September 17, 2025 14:30
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.

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

2 participants