Skip to content

refactor(ai): reuse formatTelemetryError and the recordModel resolution - #800

Merged
HugoRCD merged 1 commit into
mainfrom
refactor/ai-dedupe-error-and-model
Oct 9, 2026
Merged

HugoRCD merged 1 commit into
mainfrom
refactor/ai-dedupe-error-and-model

Conversation

@evlogai

@evlogai evlogai Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Dedupe batch from the 2026-10-09 simplification sweep (revision a34dffd), packages/evlog/src/ai/index.ts, findings code-1 and code-2.

  • recordError resolved the provider and model a second time to build its stepsUsage entry. recordModel now returns the pair it resolves, and recordError reuses it.
  • The inline error instanceof Error ? error.message : String(error) expression is repeated at two sites. Both now call formatTelemetryError, which already holds that exact expression and is already used by the integration.

Behavior is unchanged. No changeset: this is an internal refactor with no consumer-visible change.

Evidence

-  recordModel(state, model.provider, model.modelId)
+  const resolved = recordModel(state, model.provider, model.modelId)
   state.lastFinishReason = 'error'
-  state.lastError = error instanceof Error ? error.message : String(error)
+  state.lastError = formatTelemetryError(error)
 
-  const resolved = resolveProviderAndModel(model.provider, model.modelId)
   state.stepsUsage.push({
...
-            streamError = chunk.error instanceof Error ? chunk.error.message : String(chunk.error)
+            streamError = formatTelemetryError(chunk.error)

Checks, run in /workspace/repo at 0ce5885 (sandbox cache enabled, read-only):

  • pnpm --filter evlog exec vitest run test/ai: 103 of 103 passed.
  • pnpm --filter evlog exec vitest run: 96 files, 2014 of 2014 tests passed.
  • pnpm --filter evlog run lint: exit 0.
  • pnpm --filter evlog run build: exit 0. That package's typecheck script is echo 'Typecheck handled by build', so the build is the typecheck.
  • tsc --noEmit -p packages/evlog/tsconfig.json: reports errors only in test files and other source files, none in src/ai/index.ts. That tsconfig includes the test directory. I did not run it on main for a baseline comparison.
ELI5

The AI logger had two spots that did the same small job twice: one that figured out the model name a second time, and one that turned an error into text in three places. This change does each job once and reuses the result. What gets logged stays exactly the same.

recordError resolved the provider and model a second time to build the
stepsUsage entry, and the error message expression was repeated in three
places in the AI logger. recordModel now returns the resolved pair, and
the two error-message sites call formatTelemetryError like the other
call sites already do. Behavior is unchanged.
@vercel

vercel Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
evi Ready Ready Preview Oct 9, 2026 6:37pm UTC
evlog-telemetry Ready Ready Preview Oct 9, 2026 6:37pm UTC
3 Skipped Deployments
Project Deployment Actions Updated
evlog-docs Skipped Skipped v0 Oct 9, 2026 6:37pm UTC
evlog-render-lab Skipped Skipped Oct 9, 2026 6:37pm UTC
just-use-evlog Skipped Skipped Oct 9, 2026 6:37pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4f1ea95b-d970-4b26-827c-4cc109d91bd0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions
github-actions Bot requested a review from HugoRCD October 9, 2026 18:35
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

Thank you for following the naming conventions! 🙏

@pkg-pr-new

pkg-pr-new Bot commented Oct 9, 2026

Copy link
Copy Markdown
@evlog/cli

npm i https://pkg.pr.new/@evlog/cli@800

evlog

npm i https://pkg.pr.new/evlog@800

@evlog/nuxthub

npm i https://pkg.pr.new/@evlog/nuxthub@800

@evlog/signals

npm i https://pkg.pr.new/@evlog/signals@800

@evlog/telemetry

npm i https://pkg.pr.new/@evlog/telemetry@800

commit: 0ce5885

@HugoRCD
HugoRCD merged commit 2426e7f into main Oct 9, 2026
20 checks passed
@HugoRCD
HugoRCD deleted the refactor/ai-dedupe-error-and-model branch October 9, 2026 20:18

This branch was successfully deployed

2 active and 3 inactive deployments
Preview – evlog-telemetry — 0ce58859 Deployed Oct 9, 2026 by vercel[bot]
Preview – evi — 0ce58859 Deployed Oct 9, 2026 by vercel[bot]
Preview – just-use-evlog — 0ce58859 Deployed Oct 9, 2026 by vercel[bot]
Preview – evlog-render-lab — 0ce58859 Deployed Oct 9, 2026 by vercel[bot]
Preview – evlog-docs — 0ce58859 Deployed Oct 9, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant