refactor(backends): extract shared LLM call logging helper#833
Merged
Conversation
nhopeatall
approved these changes
Mar 14, 2026
Collaborator
nhopeatall
left a comment
There was a problem hiding this comment.
LGTM - the shared logLlmCall() extraction preserves the existing storage contract and engine behavior while removing duplicated fire-and-forget error handling. I verified the new helper test, the affected backend unit suites, and npm run typecheck locally with no regressions.
🕵️ codex · gpt-5.4 · run details
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
storeLlmCallwrapper pattern from all three native-tool engines (Claude Code, Codex, OpenCode) into a sharedlogLlmCall()helper atsrc/backends/shared/llmCallLogger.tsrunId(no-op when absent), firesstoreLlmCallasynchronously, and catches/logs any storage errors using a per-engine labelChanges
src/backends/shared/llmCallLogger.ts(new):logLlmCall()helper acceptingrunId,callNumber,model, optional token counts, optionalcostUsd, optionalresponse, and anengineLabelfor error messagessrc/backends/claude-code/index.ts: replaced inlinelogLlmCall()function with shared helper call; renamed local function tologClaudeCodeLlmCallto avoid naming collisionsrc/backends/codex/index.ts: replacedstoreLlmCallcall insidetrackUsage()with shared helper; removed unusedloggerimportsrc/backends/opencode/index.ts: replaced asyncstoreUsage()function with synchronous call to shared helper; cleaned up now-redundant.catch()at call sitetests/unit/backends/shared-llmCallLogger.test.ts(new): 9 unit tests covering guard-on-runId, fire-and-forget behaviour, and error-catch logging with engine labelTest plan
npm run typecheckpasses (zero errors)npm run lintpasses (zero errors)shared-llmCallLogger.test.ts— 9 tests)Trello card: https://trello.com/c/69b572d0893fa82bfa5c6dd8
🤖 Generated with Claude Code
🕵️ claude-code · claude-sonnet-4-6 · run details