Skip to content

Commit 58cd660

Browse files
committed
feat: cache optimizations, upstream PR cherry-picks, new tools
Core cache optimizations: - Move mindContext from dynamicSystem to stableSystem (500-2000+ tokens/turn cached at BP1 for sessions with SessionMind context) - Split failureContext into stableFailures (prior turns, BP1 cached) and dynamicFailures (current turn only) using signature-based dedup - Add markLargeToolResults() pre-pass: cache_control on tool-result content parts >7000 chars (~2000 tokens), Anthropic direct + OpenRouter Claude - Fix stale parts reference bug in markLargeToolResults for multi-tool messages - Add compressImages() async pre-pass via sharp (PR anomalyco#21371): 3-phase quality->dimension->fallback compression prevents 5MB API limit errors - Session snapshot resets (resetFailureSnapshot/resetEnvDynamicSent) in cleanup - prompt_async idle race condition fix: check new messages before loop break Upstream PR cherry-picks: - PR anomalyco#21535: deterministic queued message wrapping eliminates per-turn cache miss - PR anomalyco#21492: tool evidence digest (evidence.ts) preserves context through compaction - PR anomalyco#21507: session processor single-flight summary dedup improvements - PR anomalyco#21528: prompt_async idle wakeup race condition fix - PR anomalyco#21500: Levenshtein O(min(N,M)) space with Int32Array two-row algorithm New tools (PR anomalyco#21399): - ContextUsageTool (check_context_usage): real-time token/cache usage reporting - NewSessionTool (new_session): TUI-only, abort + create new session - TuiEvent.SessionNew bus event and app.tsx handler - SDK types.gen.ts/sdk.gen.ts EventTuiSessionNew type Test infrastructure: - E2E cache tests (OPENCODE_E2E=1) verified 100% cache hit rate on T2+ - Unit tests for large-tool cache breakpoints (4 scenarios) - Fix pre-existing lsp-deps.test.ts assertion bug (LspTool in make() not all()) - Add await to all ProviderTransform.message() call sites (now async)
1 parent 039c601 commit 58cd660

37 files changed

Lines changed: 11861 additions & 872 deletions

bun.lock

Lines changed: 302 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/opencode/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
registry=https://registry.npmjs.org/

packages/opencode/package.json

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"prepare": "effect-language-service patch || true",
1010
"typecheck": "tsgo --noEmit",
1111
"test": "bun test --timeout 30000",
12-
"test:ci": "mkdir -p .artifacts/unit && bun test --timeout 30000 --reporter=junit --reporter-outfile=.artifacts/unit/junit.xml",
12+
"test:ci": "bun test --timeout 30000 --reporter=junit --reporter-outfile=.artifacts/unit/junit.xml",
1313
"build": "bun run script/build.ts",
1414
"fix-node-pty": "bun run script/fix-node-pty.ts",
1515
"upgrade-opentui": "bun run script/upgrade-opentui.ts",
@@ -79,7 +79,7 @@
7979
"@actions/github": "6.0.1",
8080
"@agentclientprotocol/sdk": "0.16.1",
8181
"@ai-sdk/amazon-bedrock": "4.0.83",
82-
"@ai-sdk/anthropic": "3.0.67",
82+
"@ai-sdk/anthropic": "npm:@fairyhunter13/ai-anthropic@4.0.0-beta.17-fork.3",
8383
"@ai-sdk/azure": "3.0.49",
8484
"@ai-sdk/cerebras": "2.0.41",
8585
"@ai-sdk/cohere": "3.0.27",
@@ -92,14 +92,15 @@
9292
"@ai-sdk/openai": "3.0.48",
9393
"@ai-sdk/openai-compatible": "2.0.37",
9494
"@ai-sdk/perplexity": "3.0.26",
95-
"@ai-sdk/provider": "3.0.8",
96-
"@ai-sdk/provider-utils": "4.0.23",
95+
"@ai-sdk/provider": "npm:@fairyhunter13/ai-provider@4.0.0-beta.6",
96+
"@ai-sdk/provider-utils": "npm:@fairyhunter13/ai-provider-utils@5.0.0-beta.10",
9797
"@ai-sdk/togetherai": "2.0.41",
9898
"@ai-sdk/vercel": "2.0.39",
9999
"@ai-sdk/xai": "3.0.75",
100100
"@aws-sdk/credential-providers": "3.993.0",
101101
"@clack/prompts": "1.0.0-alpha.1",
102102
"@effect/platform-node": "catalog:",
103+
"@fairyhunter13/opentui-core": "0.1.110",
103104
"@gitlab/gitlab-ai-provider": "3.6.0",
104105
"@gitlab/opencode-gitlab-auth": "1.3.3",
105106
"@hono/node-server": "1.19.11",
@@ -117,15 +118,15 @@
117118
"@opencode-ai/sdk": "workspace:*",
118119
"@opencode-ai/util": "workspace:*",
119120
"@openrouter/ai-sdk-provider": "2.4.2",
120-
"@opentui/core": "0.1.97",
121-
"@opentui/solid": "0.1.97",
121+
"@opentui/core": "0.1.113",
122+
"@opentui/solid": "0.1.113",
122123
"@parcel/watcher": "2.5.1",
123124
"@pierre/diffs": "catalog:",
124125
"@solid-primitives/event-bus": "1.1.2",
125126
"@solid-primitives/scheduled": "1.5.2",
126127
"@standard-schema/spec": "1.0.0",
127128
"@zip.js/zip.js": "2.7.62",
128-
"ai": "catalog:",
129+
"ai": "npm:@fairyhunter13/[email protected]",
129130
"ai-gateway-provider": "3.1.2",
130131
"bonjour-service": "1.3.0",
131132
"bun-pty": "0.4.8",
@@ -155,6 +156,7 @@
155156
"partial-json": "0.1.7",
156157
"remeda": "catalog:",
157158
"semver": "^7.6.3",
159+
"sharp": "0.34.5",
158160
"solid-js": "catalog:",
159161
"strip-ansi": "7.1.2",
160162
"tree-sitter-bash": "0.25.0",

0 commit comments

Comments
 (0)