Repository navigation
fix: apply v3.4.0 code-review follow-ups (usage layering, endpoint tables, tool-result media) - #47
Merged
Merged
Conversation
…pers The core layer kept parsing provider payloads itself — a raw `total_tokens`/`cached_tokens` read in streaming/common.ts — against the CLAUDE.md architecture rule. Both field lists move into providers/usage/openai.ts, the capture stores the mapped total, and the dead withCacheTokens/argsOf paths are removed.
toAnthropicRequest and toAnthropicRequestFromChat still JSON.stringify'd tool-output block arrays — the exact ~1.37M-character screenshot mistake toolResultContent() documents for the other direction. A new toolResultBlocks() maps Chat/Responses text and image parts back to Anthropic tool_result blocks. The count_tokens token estimator moves from server.ts into convert/shared.ts alongside the payload logic it reads.
The per-endpoint finish/failure ternary cascades become protocol-keyed lookup tables (failures shared via one map), the resolved spec reads as endpointSpec, and json.ts's parse accessor is renamed parseJson to match its call sites. Docs and comments (retry status set, new endpoints, concurrency gate) are synced with the shipped behavior.
…elds input/model/provider traveled together through proxyRequest and all nine endpoint payload builders, so every signature re-stated the same route. Binding them into a RequestContext lets the payload seam pass one value and proxyRequest hand its caller back the same context it resolved.
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
落地 v3.4.0(PR #45)双轴 code review 中 Standards 轴的全部可修项;Spec 轴无发现,发布元数据无需改动。
streaming/common.ts不再直接读total_tokens/cached_tokens;字段表全部归还providers/usage/openai.ts,usageCapture经协议映射器存total/cached(CLAUDE.md 架构约束)forwardWithRetry注释补 408;docs/architecture.md补GET /v1/models/{id}、POST /v1/messages/count_tokens、并发闸、408 重试码;CLAUDE.md/accessor 名同步withCacheTokens、argsOf、cacheTokensOf与UsageCapture.rawENDPOINT_SPECS的finish/failure三元链改为 protocol 键映射表(failure 三端点共用一张FAILURE_BY_PROTOCOL)estimateInputTokens/IMAGE_TOKEN_ESTIMATE从server.ts移入convert/shared.tstoolResultBlocks(),toAnthropicRequest与toAnthropicRequestFromChat的 tool 输出块数组不再JSON.stringify成文本,图片映射回 Anthropictool_resultimage blocks,并补 3 个回归测试specFor→endpointSpec;json.ts 的parse访问器更名为parseJson(含文档引用)有意跳过:
(input, model, provider)Data Clump——会波及convert/全部公开函数签名与既有测试,属判断题级churn,收益不抵风险。Test plan
npm run typecheck通过npm run lint通过npm test399/399 通过(含 3 个新增 tool_result 图片回归测试)🤖 Generated with Claude Code via Qoder