Repository navigation
Closed
Labels
Description
🎯 Goal
Update the WorkerStateManager to persistently store key LLM metrics (model, cost, turns, conversation ID) from Claude's execution. This data is required for display in a future web UI to monitor task details.
📝 Context
Currently, the claudeResult object (which contains all necessary metrics like model, finalResult.cost_usd, finalResult.num_turns, and conversationId) is correctly returned from claudeService.js to worker.js.
However, the worker only saves a partial subset of this data to the Redis state manager.
src/utils/workerStateManager.jsin theupdateTaskStatefunction only savessuccess,sessionId, andexecutionTime(lines 109-115).src/worker.jsinprocessGitHubIssueJobnever callsupdateTaskStatewith theclaudeResultobject after Claude execution finishes (around line 220).
This issue will address both shortcomings.
🚀 Implementation Steps
-
File:
src/utils/workerStateManager.js- Action: Modify the
updateTaskStatefunction. - Logic: Expand the
if (metadata.claudeResult)block (around line 109) to capture the full metrics. - Suggestion:
// ... inside updateTaskState ... if (metadata.claudeResult) { state.claudeResult = { success: metadata.claudeResult.success, sessionId: metadata.claudeResult.sessionId, executionTime: metadata.claudeResult.executionTime, // Add these new fields: model: metadata.claudeResult.model || null, conversationId: metadata.claudeResult.conversationId || null, finalResult: metadata.claudeResult.finalResult ? { num_turns: metadata.claudeResult.finalResult.num_turns || null, cost_usd: metadata.claudeResult.finalResult.cost_usd || null, subtype: metadata.claudeResult.finalResult.subtype || null } : null }; } // ...
- Action: Modify the
-
File:
src/worker.js- Action: Modify the
processGitHubIssueJobfunction. - Logic: After
claudeResultis received fromexecuteClaudeCode(around line 220), add a call tostateManager.updateTaskStateto persist these metrics. - Suggestion:
// ... inside processGitHubIssueJob ... // (Around line 220) claudeResult = await executeClaudeCode({ worktreePath: worktreeInfo.worktreePath, issueRef: issueRef, githubToken: githubToken.token }); // ADD THIS BLOCK: try { await stateManager.updateTaskState(taskId, TaskStates.CLAUDE_EXECUTION, { reason: 'Claude execution completed', claudeResult: claudeResult // Pass the full result object }); } catch (stateError) { correlatedLogger.warn({ taskId, error: stateError.message }, 'Failed to update task state with Claude results'); } // END ADDED BLOCK correlatedLogger.info({ // ... (rest of the log message)
- Action: Modify the
Activity
propr-dev commentedon Sep 16, 2025
🤖 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:
claude-opus-4-20250514ai-fix/69-feat-store-llm-metrics-mo-20250916-1334-claude-opus-4-20250514-3wnmainissue-69-20250916-1334-claude-opus-4-20250514-3wnfix(ai): Resolve issue #69 - Feat: Store LLM Metrics (Model, Cost, Tu…
Merge pull request #71 from integry/ai-fix/69-feat-store-llm-metrics-…