fix(offload): tracing/token hardening — astral token fix, L1.5 null fallback, createRequire#463
fix(offload): tracing/token hardening — astral token fix, L1.5 null fallback, createRequire#463rainforest888 wants to merge 2 commits into
Conversation
…allback, createRequire + trace truncation
|
Thanks for splitting this out from #391! I have manually reviewed the changes, and everything looks exceptionally well done. A few key highlights from the review:
The code is exceptionally clean, focused, and has zero overlap with the other hardening PRs. Everything is in perfect shape and completely ready to merge. LGTM! 🚀 |
YOMXXX
left a comment
There was a problem hiding this comment.
Approved.
I verified this PR locally by applying the patch to its base commit and running:
pnpm test— passed: 4 files, 67 testspnpm build— passedgit diff --check --cached— passed- targeted token-estimator comparison for astral-plane samples — passed: single emoji / CJK extension-B samples drop from 5 to 3 estimated tokens, mixed samples also stop double-counting the low surrogate
The offload changes are focused and independent: the token estimator now skips the low surrogate in its existing charCodeAt-based loop, failed L1.5 judgment parsing now reaches the null/unavailable path, and Opik trace payloads are bounded while using createRequire for the CommonJS package load.
fix(offload): Tracing & Token Hardening
拆分自 #391,per YOMXXX review。
修复范围
聚焦
src/offload/层:token estimate、local LLM、Opik tracing。不涉及 store、runtime、gateway 层。具体修复
src/offload/fast-token-estimate.ts— Astral-平面 Token 修正i += 2),修正 ~2× token 高估src/offload/local-llm/index.ts— L1.5 Fallback 修正{taskCompleted: false, ...}— normalizeJudgment 把false当有效判断,永远不触发 "LLM 不可用" 重试{taskCompleted: null, ...},== null检查触发重试路径src/offload/opik-tracer.ts— ESM 兼容 + Trace 截断require("opik")为undefined,tracer 永久静默关闭createRequire(import.meta.url)验证