Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,25 @@ NEW `tests/claude-integration/claude-context-accounting.test.ts` (registered in
- `bun run typecheck`
- focused files above + `tests/ci-workflows/skill-ocx.test.ts` (capability map) + `bun run skill:surface:check`
- `bun run structure:check`

## P amendment (wp3 entry, after wp2 review)

wp2 changed two interfaces this doc relied on; the policy threads through them instead:

- `withSubagentContextMarker(selector, windows, accounting200k = false)`: the marking mode is now
per selector (`subagentSelectorMode`: genuine 1M for Claude models, unpaired otherwise). Under
`200k` an unmarked selector stays bare; an explicit `[1m]` keeps following its selector mode
(kept when the window can carry it, stripped otherwise). `agents-inject.ts:100,133` and
`resolveSubagentForceModel` pass `resolveAutoContext(config.claudeCode).accounting200k === true`;
the `subagentMarkingMode` helper is not needed.
- Desktop eligibility is `claudeSurfaceSupportsOneMillion(provider, modelId, window)` /
`routeSupportsOneMillion(route, window)`; the policy only drops `prefer1m`, so those predicates
are unchanged.
- Discovery needs no change: `variantMode = auto.enabled ? UNPAIRED : OFF` already keeps the
>= 1M variants under `ACCOUNTING_200K` (enabled false).

Audit of the amendment (PASS) notes: the earlier `withSubagentContextMarker(..., mode = UNPAIRED_AUTO_CONTEXT)`
snippet and the `subagentMarkingMode` chain row above are **superseded** by this amendment; the
picker keeps its Claude-model guard and takes `ACCOUNTING_200K` first; `shouldMarkOneMillion`
checks `accounting200k` before its >= 1M early return. wp3 B also carries the docs-site sync the
layer 1 and layer 2 branches still owe (cascaded onto those branches).
14 changes: 14 additions & 0 deletions docs-site/src/content/docs/fr/guides/claude-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,20 @@ reste prioritaire pour le marquage des variables de lancement ; le proxy s'appu
Les lignes de découverte ignorent cet export et conservent le plancher fixe.
Les valeurs de configuration invalides définies manuellement reviennent à 829,800.

### Comptabilisation du contexte (1M par défaut, 200k sur option)

`claudeCode.contextAccounting` fixe ce qu'opencodex choisit par défaut. Absent (`1m`, valeur par défaut), les modèles à
longue fenêtre sont proposés à 1M dans les emplacements d'environnement du lancement, les sélecteurs Desktop, Desktop 3P
(`prefer1m`) et les sous-agents générés. Avec `200k`, rien n'est marqué `[1m]` automatiquement, `CLAUDE_CODE_AUTO_COMPACT_WINDOW`
n'est pas injecté et Desktop 3P retire `prefer1m` tout en gardant `supports1m`. Un sélecteur que vous marquez vous-même `[1m]`
reste disponible (les sous-agents générés ou forcés retirent toujours un marqueur que la fenêtre du modèle ne peut pas porter), et
la découverte liste toujours les lignes `· 1M` des modèles réellement à 1M. `200k` l'emporte sur le contexte automatique : une valeur
de compactage que vous exportez ne réactive pas le marquage automatique, mais opencodex laisse votre export en place.

```bash
ocx claude config set --context-accounting 200k
```

### Environnement effectif des modèles

`effectiveModelEnv` calcule six emplacements injectés par `ocx claude`, l'environnement système ou le fichier d'environnement du shell :
Expand Down
15 changes: 15 additions & 0 deletions docs-site/src/content/docs/guides/claude-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,21 @@ for launch-slot marking (the proxy uses YOUR value to decide which models are sa
Discovery rows ignore that export and keep the fixed floor. Invalid hand-edited config values
fall back to 829,800.

### Context accounting (1M by default, 200k opt-in)

`claudeCode.contextAccounting` decides what opencodex picks by default. Absent (`1m`, the
default), long-window models are offered at 1M in the launch env slots, the Desktop pickers,
Desktop 3P (`prefer1m`) and generated subagents. Set `200k` to opt out: nothing is marked `[1m]`
automatically, `CLAUDE_CODE_AUTO_COMPACT_WINDOW` is not injected, and Desktop 3P drops `prefer1m`
while keeping `supports1m`. A selector you mark `[1m]` yourself stays available (generated and
forced subagents still drop a marker the model's window cannot carry), and discovery still lists
the `· 1M` rows of genuine 1M models. `200k` wins over auto-context: a compact window you export no
longer turns automatic marking on, though opencodex leaves your own export in place.

```bash
ocx claude config set --context-accounting 200k
```

### Effective model environment

`effectiveModelEnv` computes six slots injected by `ocx claude` / system env / shell file:
Expand Down
13 changes: 13 additions & 0 deletions docs-site/src/content/docs/ja/guides/claude-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,19 @@ Claude Code は未知モデルのコンテキストを 200k トークンとし
1M 未満のネイティブ Anthropic モデルには自動で標識を付けません。自分で export した圧縮値は起動スロットの標識に優先し、プロキシは**ユーザーが指定した**値を基準にどのモデルに安全に標識を付けるか決定します。ディスカバリー行はその export を無視し、固定の下限を保ちます。
直接編集した設定値が不正な場合は 829,800 に戻ります。

### コンテキスト計算方式(既定は 1M、200k はオプトイン)

`claudeCode.contextAccounting` は opencodex が既定で選ぶ値を決めます。未設定(`1m`、既定)では、
長いコンテキストのモデルが起動環境スロット、Desktop ピッカー、Desktop 3P(`prefer1m`)、生成されたサブエージェントで 1M として扱われます。
`200k` にすると `[1m]` 標識を自動では付けず、`CLAUDE_CODE_AUTO_COMPACT_WINDOW` も注入せず、Desktop 3P は `supports1m` を残して
`prefer1m` だけを外します。自分で `[1m]` を付けた選択は引き続き使えます(生成されたサブエージェントと強制サブエージェントは、モデルのウィンドウが支えられない標識を引き続き外します)。
ディスカバリーには実際に 1M のモデルの `· 1M` 行が引き続き表示されます。`200k` は自動コンテキストより優先され、自分で export した圧縮値があっても自動標識は
再び有効になりません。その export 値自体は opencodex が変更しません。

```bash
ocx claude config set --context-accounting 200k
```

### 実モデル環境

`effectiveModelEnv` は `ocx claude` / システム環境 / シェルファイルが注入するスロット 6 つを計算します。
Expand Down
14 changes: 14 additions & 0 deletions docs-site/src/content/docs/ko/guides/claude-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,20 @@ Claude Code는 알 수 없는 모델의 컨텍스트를 200k 토큰으로 계산
디스커버리 행은 그 값을 무시하고 고정 하한을 유지해요.
직접 편집한 설정값이 잘못되면 829,800로 돌아가요.

### 컨텍스트 계산 방식 (기본 1M, 200k는 옵트인)

`claudeCode.contextAccounting`은 opencodex가 기본으로 고르는 값을 정해요. 설정하지 않으면(`1m`, 기본값)
긴 컨텍스트 모델이 실행 환경 슬롯, Desktop 선택기, Desktop 3P(`prefer1m`), 생성된 서브에이전트에서 1M으로
잡혀요. `200k`로 바꾸면 자동 `[1m]` 표식을 붙이지 않고 `CLAUDE_CODE_AUTO_COMPACT_WINDOW`도 넣지 않으며,
Desktop 3P는 `supports1m`은 남기고 `prefer1m`만 빼요. 직접 `[1m]`을 붙인 선택은 계속 쓸 수 있어요(생성된
서브에이전트와 강제 서브에이전트는 모델 창이 감당하지 못하는 표식을 여전히 떼요). 디스커버리 목록에는 실제 1M 모델의
`· 1M` 행이 계속 나와요. `200k`는 자동 컨텍스트보다 우선해요. 직접 export한 압축 값이 있어도 자동 표식은 다시 켜지지
않고, 그 export 값은 opencodex가 건드리지 않아요.

```bash
ocx claude config set --context-accounting 200k
```

### 실제 모델 환경

`effectiveModelEnv`는 `ocx claude` / 시스템 환경 / 셸 파일이 주입할 슬롯 여섯 개를 계산해요.
Expand Down
14 changes: 14 additions & 0 deletions docs-site/src/content/docs/ru/guides/claude-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,20 @@ Anthropic сохраняют канонические id в обоих инте
можно безопасно пометить). Строки обнаружения игнорируют этот экспорт и сохраняют фиксированный пол. Некорректные значения, внесённые в конфигурацию вручную, откатываются
к 829,800.

### Учёт контекста (1M по умолчанию, 200k по выбору)

`claudeCode.contextAccounting` определяет, что opencodex выбирает по умолчанию. Без значения (`1m`, по умолчанию) модели
с длинным окном предлагаются как 1M в слотах окружения запуска, селекторах Desktop, Desktop 3P (`prefer1m`) и созданных
субагентах. Значение `200k` это отключает: маркер `[1m]` автоматически не ставится, `CLAUDE_CODE_AUTO_COMPACT_WINDOW` не
передаётся, а Desktop 3P убирает `prefer1m`, оставляя `supports1m`. Селектор, который вы сами пометили `[1m]`, остаётся
доступным (созданные и принудительные субагенты по-прежнему снимают маркер, который окно модели не выдерживает), а в списке
обнаружения остаются строки `· 1M` для моделей с настоящим окном 1M. `200k` важнее автоконтекста: экспортированное вами
значение сжатия не включает автоматическую разметку снова, но opencodex ваш экспорт не трогает.

```bash
ocx claude config set --context-accounting 200k
```

### Эффективное окружение моделей

`effectiveModelEnv` вычисляет шесть слотов, внедряемых `ocx claude`, системным окружением и
Expand Down
12 changes: 12 additions & 0 deletions docs-site/src/content/docs/zh-cn/guides/claude-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,18 @@ v1 别名按字面解码(历史上 model ID 中包含的两字符序列 `~s` /
低于 1M 的原生 Anthropic 模型绝不会被自动标记。你自行导出的压缩值在启动槽位标记上始终优先(代理会使用**你的**
值来判断哪些模型可以安全标记)。发现列表忽略该导出值并保持固定下限。手动编辑配置时填入的无效值会回退到 829,800。

### 上下文计算方式(默认 1M,200k 需选择启用)

`claudeCode.contextAccounting` 决定 opencodex 默认选用的值。未设置(`1m`,默认)时,长上下文模型在启动环境槽位、
Desktop 选择器、Desktop 3P(`prefer1m`)和生成的子代理中按 1M 提供。设为 `200k` 即可退出:不再自动添加 `[1m]` 标记,
不注入 `CLAUDE_CODE_AUTO_COMPACT_WINDOW`,Desktop 3P 保留 `supports1m` 但去掉 `prefer1m`。你自己标记 `[1m]` 的选择仍可使用
(生成的子代理和强制子代理仍会去掉模型窗口无法承载的标记),发现列表中真正 1M 模型的 `· 1M` 条目也仍然存在。`200k` 优先于
自动上下文:你自行导出的压缩值不会重新启用自动标记,但 opencodex 不会改动你导出的值。

```bash
ocx claude config set --context-accounting 200k
```

### 有效模型环境变量

`effectiveModelEnv` 会计算由 `ocx claude` / 系统环境 / shell 文件注入的六个槽位:
Expand Down
12 changes: 12 additions & 0 deletions docs-site/src/content/docs/zh-tw/guides/claude-code.md
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,18 @@ v1 別名按字面解碼(歷史上 model ID 中包含的兩字元序列 `~s` /
低於 1M 的原生 Anthropic 模型絕不會被自動標記。你自行匯出的壓縮值在啟動槽位標記上始終優先(代理會使用**你的**
值來判斷哪些模型可以安全標記)。探索列表忽略該匯出值並保持固定下限。手動編輯設定時填入的無效值會回退到 829,800。

### 上下文計算方式(預設 1M,200k 需選擇啟用)

`claudeCode.contextAccounting` 決定 opencodex 預設選用的值。未設定(`1m`,預設)時,長上下文模型在啟動環境槽位、
Desktop 選擇器、Desktop 3P(`prefer1m`)和產生的子代理中按 1M 提供。設為 `200k` 即可退出:不再自動加上 `[1m]` 標記,
不注入 `CLAUDE_CODE_AUTO_COMPACT_WINDOW`,Desktop 3P 保留 `supports1m` 但移除 `prefer1m`。你自己標記 `[1m]` 的選擇仍可使用
(產生的子代理和強制子代理仍會移除模型視窗無法承載的標記),探索清單中真正 1M 模型的 `· 1M` 條目也仍然存在。`200k` 優先於
自動上下文:你自行匯出的壓縮值不會重新啟用自動標記,但 opencodex 不會改動你匯出的值。

```bash
ocx claude config set --context-accounting 200k
```

### 有效模型環境變數

`effectiveModelEnv` 會計算由 `ocx claude` / 系統環境 / shell 檔案注入的六個槽位:
Expand Down
2 changes: 1 addition & 1 deletion scripts/test-layout/layout.json
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@
"messages-native-oauth.test.ts": "claude-integration",
"messages-native-opaque-state.test.ts": "claude-integration",
"messages-surface-matrix.test.ts": "claude-integration", "claude-long-context-eligibility.test.ts": "claude-integration",
"claude-model-info.test.ts": "claude-integration",
"claude-context-accounting.test.ts": "claude-integration", "claude-model-info.test.ts": "claude-integration",
"claude-models-discovery.test.ts": "claude-integration",
"claude-native-affinity.test.ts": "claude-integration",
"claude-native-passthrough.test.ts": "claude-integration",
Expand Down
6 changes: 4 additions & 2 deletions skills/ocx/references/01_surface_integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Declared capabilities: 41.

### `ocx claude config`

Usage: `ocx claude config status [--json]; ocx claude config set [--enabled <on|off>] [--auth-mode <auto|proxy|subscription>] [--system-env <on|off>] [--fast-mode <on|off>] [--auto-context <on|off>] [--compact-window <tokens|default>] [--inject-agents <on|off>] [--small-fast-model <id|->] [--model-map <from=to,...|->] [--blocked-skills <name,name|->] [--web-model <id|->] [--web-backend <openai|anthropic|xai|gemini|exa|->] [--vision-model <id|->] [--vision-backend <openai|anthropic|->] [--json]; or ocx claude config set --first-party <on|off> [--json]`
Usage: `ocx claude config status [--json]; ocx claude config set [--enabled <on|off>] [--auth-mode <auto|proxy|subscription>] [--system-env <on|off>] [--fast-mode <on|off>] [--auto-context <on|off>] [--compact-window <tokens|default>] [--context-accounting <1m|200k>] [--inject-agents <on|off>] [--small-fast-model <id|->] [--model-map <from=to,...|->] [--blocked-skills <name,name|->] [--web-model <id|->] [--web-backend <openai|anthropic|xai|gemini|exa|->] [--vision-model <id|->] [--vision-backend <openai|anthropic|->] [--json]; or ocx claude config set --first-party <on|off> [--json]`

Read or update Claude Code settings, including independent CLI first-party routing.

Expand All @@ -31,6 +31,7 @@ State-changing: yes.
| `--fast-mode` | string | on or off. |
| `--auto-context` | string | on or off. |
| `--compact-window` | string | Positive token count or default to clear. |
| `--context-accounting` | string | 1m (default) or 200k. |
| `--inject-agents` | string | on or off. |
| `--small-fast-model` | string | Model ID; - clears. |
| `--model-map` | string | Comma-separated from=to mappings; - clears. |
Expand Down Expand Up @@ -566,7 +567,7 @@ JSON mode: `payload`.

### `ocx claude config set`

Usage: `ocx claude config set [--enabled <on|off>] [--auth-mode <auto|proxy|subscription>] [--system-env <on|off>] [--fast-mode <on|off>] [--auto-context <on|off>] [--compact-window <tokens|default>] [--inject-agents <on|off>] [--small-fast-model <id|->] [--model-map <from=to,...|->] [--blocked-skills <name,name|->] [--web-model <id|->] [--web-backend <openai|anthropic|xai|gemini|exa|->] [--vision-model <id|->] [--vision-backend <openai|anthropic|->] [--json]; or ocx claude config set --first-party <on|off> [--json]`
Usage: `ocx claude config set [--enabled <on|off>] [--auth-mode <auto|proxy|subscription>] [--system-env <on|off>] [--fast-mode <on|off>] [--auto-context <on|off>] [--compact-window <tokens|default>] [--context-accounting <1m|200k>] [--inject-agents <on|off>] [--small-fast-model <id|->] [--model-map <from=to,...|->] [--blocked-skills <name,name|->] [--web-model <id|->] [--web-backend <openai|anthropic|xai|gemini|exa|->] [--vision-model <id|->] [--vision-backend <openai|anthropic|->] [--json]; or ocx claude config set --first-party <on|off> [--json]`

Change Claude Code settings through the runtime owner.

Expand All @@ -584,6 +585,7 @@ State-changing: yes.
| `--fast-mode` | string | on or off. |
| `--auto-context` | string | on or off. |
| `--compact-window` | string | Positive token count or default to clear. |
| `--context-accounting` | string | 1m (default) or 200k. |
| `--inject-agents` | string | on or off. |
| `--small-fast-model` | string | Model ID; - clears. |
| `--model-map` | string | Comma-separated from=to mappings; - clears. |
Expand Down
6 changes: 3 additions & 3 deletions src/claude/agents-inject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { join } from "node:path";
import type { OcxConfig } from "../types";
import { renameAtomicFile } from "../lib/windows-atomic-replace";
import { assertNotRealClaudeConfigUnderTest } from "../lib/test-home-guard";
import { entryParts, SAFE_AGENT_MODEL_ID, withSubagentContextMarker } from "./subagent-model";
import { accountsAt200k, entryParts, SAFE_AGENT_MODEL_ID, withSubagentContextMarker } from "./subagent-model";
import { stripOneMillionMarker } from "./context-windows";
import { claudeConfigDir } from "./gateway-cache";
import { DEFAULT_SUBAGENT_MODELS } from "../config";
Expand Down Expand Up @@ -98,7 +98,7 @@ export function buildClaudeAgentDefs(
// Generated defs mark [1m] on the authoritative window only — never the
// main-session auto-context predicate (a 372K route marked [1m] would be
// accounted at 1M with no compaction safety net in the subagent).
const model = withSubagentContextMarker(alias, windows);
const model = withSubagentContextMarker(alias, windows, accountsAt200k(config));
const bare = alias.toLowerCase();
if (coveredModels.has(bare)) return;
coveredModels.add(bare);
Expand Down Expand Up @@ -131,7 +131,7 @@ export function buildClaudeAgentDefs(
// the next launch sync — documented limit. No resolvable default -> no self def.
const selfModel = pickerDefaultModel(configDir) ?? (config.claudeCode?.model?.trim() || null);
if (selfModel) {
const marked = withSubagentContextMarker(selfModel, windows);
const marked = withSubagentContextMarker(selfModel, windows, accountsAt200k(config));
defs.push({
file: `${OWNED_PREFIX}self.md`,
name: `${OWNED_PREFIX}self`,
Expand Down
Loading
Loading