OpenCode v2.0.19:重写压缩与 diff 视图
OpenCode 更新压缩机制改为逐级缩小重试、输出上限适配上下文窗口、跨会话复用 prompt 缓存,并新增 Last turn diff 视图。
𝙊𝙥𝙚𝙣𝘾𝙤𝙙𝙚 v2.0.19 released. TL;DR: Compaction is rebuilt to shrink and retry instead of failing, output-token limits now fit the context window, prompt-cache reuse improves across sessions and subagents, and the TUI diff viewer gains a Last turn view. 𝗧𝗨𝗜 Added • Added a Last turn source to /diff that shows the files the session changed in its latest turn and refreshes when each turn finishes. You can make it the default with diffs.source: "turn". Outside a session it falls back to branch. Fixed • Fixed --prompt auto-submit firing before the agent, model and catalog were ready. • Fixed duplicate entries in the open-project picker when older project records point to the same checkout. • Fixed shell tool rows so a command still running in the background no longer looks like an interrupted one. • Fixed the TUI jumping to model selection after connecting an MCP integration. • Fixed long /btw questions so they collapse to one truncated line. • Fixed the OpenCode web search provider label capitalization. 𝗔𝗴𝗲𝗻𝘁 Changed • Rebuilt session compaction. When a provider says a request is too long, it now retries at 70%, 50% and then 35% of the rejected size. If the request is still too big, it sends history as trimmed text, dropping media first and then the oldest exchanges. Native OpenAI compaction retries smaller instead of switching to a summary. • Changed the default compaction buffer from a fixed 20k tokens to 10% of the model's limit, with a 16k minimum on larger windows. With auto compaction off, only manual /compact runs, including after a too-long rejection. • Changed the default max output tokens for main and compaction requests to fit the room left in the context window. It is capped at 256k, uses 32k when the model's limit is unknown, and is limited to 32k for summaries. • Reordered system instructions from most to least shared, putting date and environment last, and removed the session ID from the environment block. This keeps the reused prompt-cache prefix the same across sessions. Added • Added AGENT=1, OPENCODE=1, AI_AGENT=opencode and OPENCODE_SESSION_ID to the environment of shell tool commands, so scripts can tell they are running under an agent. • Added a warning log when a provider's too-long rejection triggers compaction. 𝗖𝗟𝗜 Added • Added support for passing an unused ID to --session in the TUI and opencode run. OpenCode now creates a session with that ID instead of failing with "Session not found". • Added a grouped, searchable picker to opencode auth login, with MCP, Popular and Services groups and markers for connected integrations. • Changed opencode mcp auth so the server name is optional and an interactive picker lists OAuth-capable servers. It flags servers with expired credentials, and re-authenticating replaces the old credential instead of adding another. Fixed • Fixed Ctrl+C during auth login so it cancels the pending OAuth or command attempt instead of exiting and leaving it running. • Fixed opencode run showing a misleading interruption error after a declined permission or dismissed question. It now exits with code 1. • Changed command-based auth to print the command's output line by line instead of inside a spinner. 𝗣𝗿𝗼𝘃𝗶𝗱𝗲𝗿𝘀 Changed • Changed session and affinity headers, including the ChatGPT session-id and GitHub Copilot interaction ID, so child sessions send their parent's ID and forks send the source session's ID. This lets subagents share the parent's provider cache. • Changed OpenAI context and compaction requests to omit the output-token limit, because the ChatGPT backend rejects it and OpenAI counts it against rate limits. • Changed xAI Responses variants to request reasoning summaries and encrypted reasoning. • Changed Anthropic-compatible providers to use their own route so they get Anthropic-style cache hints. xAI routes also get distinct IDs. Fixed • Fixed Gemini parallel tool calls over its OpenAI-compatible endpoint by keeping and replaying thought signatures. • Fixed invalid Google API keys being retried; they are now reported as authentication errors. • Fixed Cloudflare AI Gateway and Workers AI so configured account and gateway IDs take priority, with CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_GATEWAY_ID used only as fallbacks. • Fixed one-off generation calls so they carry session attribution, which gateways require. 𝗟𝗟𝗠 Added • Added ElevenLabs Scribe transcription with word timestamps and diarized speaker turns. • Added retries with backoff and jitter for transient failures when checking queued media jobs. Starting and cancelling a job are never retried. • Added per-answer confidence to evaluation results. Fixed • Fixed aborted calls so they reject with signal.reason, like fetch, instead of ending quietly. • Fixed failed video jobs so they report the provider's error type, such as authentication, rate limit or invalid request, instead of a generic internal error. • Fixed cut-off or blocked Gemini speech and transcription results so they are reported instead of dropped. • Fixed OpenAI and Deepgram speech results reporting a different audio format than the one actually requested. 𝗖𝗼𝗿𝗲 • Fixed repository hosts containing relative path segments so they are rejected before being used as cache directories. 𝗗𝗼𝗰𝘀 • Added Go Plus plan documentation and synced the V2 Go model list. • Listed LongCat 2.5 Preview Free among the free Console models and added the Jev data-retention policy to the Zen docs. No noticeable bundle change Compare: https://github.com/anomalyco/opencode/compare/v2.0.18...v2.0.19