Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

refactor: unify the two Anthropic-likeness classifiers (hoist vs cache-control)

未关闭
#891 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
42/100
Issue 类型
重构
描述清晰度
基本清楚
活跃度
冷清
技术栈
typescript
领域
backend

调研方向

先阅读 packages/opencode/src/provider/family.ts 中的 familyVendor,然后将其在 packages/opencode/src/session/prompt.ts 中的使用方式与 packages/opencode/src/provider/transform.ts:284-295 中的内联 cache-control 检查进行比较。定义共享 predicate 对 gateway 的显式处理,分别验证 hoist 和 cache-control 的行为,并确认 gateway 的 cache-hit 率不会发生回退。

由索引模型根据 Issue 内容生成。

描述

Found during v0.8.3 release review (CTO persona). Deferred because it touches a hot path and changes cache-control behavior for gateway traffic — needs design + careful testing (>30 min), not for a patch release.

Context

There are now two independent predicates deciding whether a model is "Anthropic-like":

  1. isAnthropicLikeModel in packages/opencode/src/session/prompt.ts — gates the <system-reminder> system-role hoist (added in #888). Built on familyVendor + providerID + api.id/npm heuristics.
  2. The inline cache-control check in packages/opencode/src/provider/transform.ts:284-295 — gates Anthropic cache_control injection. Hard-codes model.providerID === "altimate-backend" as Anthropic-for-caching.

These deliberately diverge today: transform.ts treats the altimate-backend gateway as Anthropic-for-caching, while isAnthropicLikeModel classifies the same gateway (family: openai) as non-Anthropic. The divergence is correct for the #888 fix, but the two classifiers will drift further apart as gateway models expand, and a future maintainer could unify them wrongly.

Suggested fix

Extract a single shared predicate (built on familyVendor) used by both the hoist decision and the cache-control decision, with explicit handling of the gateway case so the two behaviors can't silently drift. Verify cache-hit rates on gateway traffic don't regress.

Scope

packages/opencode/src/session/prompt.ts, packages/opencode/src/provider/transform.ts, packages/opencode/src/provider/family.ts.

主要语言
TypeScript
星标
813
派生
134
平均合并
2 天 3 小时
30 天内合并 PR
65

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

AltimateAI/altimate-code 的其他 Issue

查看 AltimateAI/altimate-code 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。