Skip to content
Closed
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Versions follow the merge of a `*_release-v*` branch; CI publishes to npm on tag

### Fixes

- **Codex Responses session continuity**: ChatGPT account identity now survives OAuth bearer rotation; cross-checked per-agent `thread-id` metadata replaces the legacy `instructions`-based namespace guess; and terminal `compaction_trigger` requests stay in the base conversation and bypass ACP injection, preserving the upstream requirement that the trigger remain the final input item. ACP state is rebased only after native compaction succeeds.
- **omp/stateless Responses sessions never compress (prompt_cache_key identity)**: clients that replay full history statelessly with no conversation headers (omp without its plugin loaded) fell through the identity chain to a hash of the ENTIRE input array — which changes every turn, so every request minted a brand-new session (`requests: 1` on dozens of 90%+-full session files). The nudge evaluates token counts BEFORE the first forward of a session, so it always saw 0 tokens (`usage=0%, growth 0 < floor`) and never fired: contexts sat at 92% with zero compressions, while the upstream cache affinity also churned every turn. The Responses `prompt_cache_key` (the client's own stable conversation id) now replaces that fingerprint — real headers, body `session_id`, and `previous_response_id` still win; only the per-request fingerprint fallback is upgraded.
- **acp-loop replay auto-retry on upstream risk-control rejections** (#189): after a `compress`, the acp-loop replay request can be rejected by provider risk-control — GLM Coding Plan returns `400 {"code":3007,"msg":"captcha verify failed"}` ~1s after the big context rewrite — and the error was passed straight into the agent session as `[acp-proxy: compress loop upstream error 400: ...]`. The replay request (both the streaming loop and the Responses-API JSON loop) now retries transient upstream failures with exponential backoff: up to 3 attempts total, base delay 1500ms doubling per attempt, overridable via `BILI_REPLAY_RETRY_BASE_MS` (ms; `0` disables the delay). Transient = HTTP 429/5xx, or any other 4xx whose body matches risk-control markers (`captcha`, `verify failed`, `risk control`, `风控`, `rate limit`, `too many requests`, `try again`); plain 4xx (bad model, bad params) still fail fast with no retry. Each retry logs a clear line (`upstream rejected replay (HTTP 400 ...); likely provider risk-control — retrying in 1500ms (attempt 1/3)`), and if all attempts fail the surfaced error now says `after 3 attempt(s)` so users can tell it was retried. Set `BILI_REPLAY_RETRY_MAX=1` to restore the previous fail-fast behavior.
- **Upstream rejection of replayed thinking blocks (#222, issue #221)**: some upstreams (GLM 4.6 thinking) reject the compress-loop re-request when it carries replayed `thinking` blocks with a 400 (`Invalid parameter: thinking_content …`). The compress loop now strips loop-injected thinking and retries the re-request degraded-first: replay with thinking stripped → on failure retry with reasoning dropped entirely → on failure replay raw; each degradation logs a clear line. Only affects the internal re-request — the client stream keeps the original reasoning blocks.
Expand Down
6 changes: 2 additions & 4 deletions CONFIGURATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -618,8 +618,6 @@ bili export <id> --full --output handoff.md

Then start a new conversation in the client (direct to upstream) and paste the handoff doc as the opening context.

### Codex subagents get their own compression namespace (#150)
### Codex subagents get their own compression session

Codex subagents (e.g. the `guardian_subagent` approval reviewer) reuse the main conversation's `session_id`, so on the wire they look like the same session. Without care their requests inherit the main conversation's compression state — a subagent turn can get its context folded (losing the verbatim user authorization it must read back) and the two roles' usage estimates pollute each other.

billion-context detects this via the `instructions` field: subagent requests carry their own role prompt. The **first** instructions seen for a conversation anchor the main namespace (stable even if the main prompt drifts); any other instructions value maps to a separate `|sub:` namespace with its own empty compression state. Subagent requests are self-contained replays, so the fresh namespace is lossless — and the web UI's session list shows the two namespaces as separate sessions sharing the same client label.
Modern Codex requests identify each agent with a `thread-id` also recorded in `x-codex-turn-metadata`. billion-context prefers this cross-checked per-agent identity over the root `session-id`, so the main agent, spawned agents, and the approval reviewer cannot overwrite one another's compression state. Requests without this explicit Codex metadata use the normal conversation identity; `instructions` are request content and may change between turns, so they are not treated as identity.
6 changes: 2 additions & 4 deletions CONFIGURATION.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -618,8 +618,6 @@ bili export <id> --full --output handoff.md

然后在客户端里开一个新会话(直连上游),把交接文档粘贴为开场上下文。

### Codex 子代理有独立压缩命名空间(#150)
### Codex 子代理有独立压缩会话

Codex 子代理(如 `guardian_subagent` 审批 reviewer)复用主会话的 `session_id`,在线路上看起来是同一个会话。若不处理,子代理请求会继承主会话的压缩状态 —— 子代理轮次的上下文可能被折叠(丢失它必须逐字读取的用户授权),两个角色的用量估算也会互相污染。

billion-context 通过 `instructions` 字段识别:子代理请求带自己的角色 prompt。会话**首次**看到的 instructions 锚定主命名空间(即使主 prompt 后来漂移也稳定);任何其他 instructions 值映射到独立的 `|sub:` 命名空间,拥有自己的空白压缩状态。子代理请求是自包含重放,所以新命名空间无损 —— Web UI 的会话列表会把两个命名空间显示为共享同一客户端标签的独立会话。
新版 Codex 请求会用 `thread-id` 标识每个 agent,并在 `x-codex-turn-metadata` 中记录同一 ID。billion-context 优先采用这个经过相互印证的 agent 身份,而不是根任务的 `session-id`,因此主 agent、派生 agent 和审批 reviewer 不会覆盖彼此的压缩状态。没有这组 Codex 元数据的请求沿用普通会话身份;`instructions` 属于请求内容并可能随轮次变化,因此不再用作身份判断。
Loading