fix: use per-model context window and preserve user config in OpenClaw sync#13666
Merged
kangfenmao merged 4 commits intomainfrom Mar 25, 2026
Merged
fix: use per-model context window and preserve user config in OpenClaw sync#13666kangfenmao merged 4 commits intomainfrom
kangfenmao merged 4 commits intomainfrom
Conversation
The `topicId` and `userMessage` parameters were swapped when calling `knowledgeSearchTool()` in searchOrchestrationPlugin, causing knowledge base searches to use corrupted tracing context and incorrect query text. This resulted in knowledge base content not being delivered to the model. Fixes #13609 Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Siin Xu <[email protected]>
…w sync Previously, syncProviderConfig() hardcoded contextWindow to 128000 for all models and fully overwrote the OpenClaw provider config on every sync, discarding user modifications (e.g., vision, custom context window). Changes: - Add MODEL_CONTEXT_WINDOWS map with correct values for common models (aligned with OpenClaw's opencode-zen-models.ts) - Use getContextWindow() to resolve per-model context window by ID prefix matching, falling back to 128000 for unknown models - Merge existing model config instead of overwriting: user-modified fields in OpenClaw are preserved via object spread, while Cherry Studio-managed fields (id, name) always take precedence - Extract OpenClawModelConfig interface with index signature to support arbitrary user-added fields Fixes #13665 Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Siin Xu <[email protected]>
…w's built-in defaults Let OpenClaw handle model-specific context window sizes via its internal MODEL_CONTEXT_WINDOWS. Cherry Studio only needs to preserve user modifications and provide a 128000 fallback for new models. Co-Authored-By: Claude Opus 4.6 <[email protected]> Signed-off-by: Siin Xu <[email protected]>
DeJeune
approved these changes
Mar 25, 2026
kangfenmao
approved these changes
Mar 25, 2026
MyPrototypeWhat
pushed a commit
that referenced
this pull request
Mar 30, 2026
…w sync (#13666) ## Summary Fixes #13665 - **Preserve user modifications** in OpenClaw config across restarts. Previously `syncProviderConfig()` fully overwrote the model config on every sync, discarding user changes (vision, custom context window, etc.). Now uses a merge strategy: user-modified fields are preserved via object spread, Cherry Studio-managed fields (`id`, `name`) always take precedence. - **Remove hardcoded `MODEL_CONTEXT_WINDOWS` map** — context window defaults are delegated to OpenClaw's built-in `MODEL_CONTEXT_WINDOWS` in `opencode-zen-models.ts`. Cherry Studio only provides `128000` as fallback for new/unknown models on first sync. - **Extract `OpenClawModelConfig` interface** with index signature to support arbitrary user-added fields without type errors. ### Before ```typescript models: provider.models.map((m) => ({ id: m.id, name: m.name, contextWindow: 128000 // hardcoded for ALL models, overwrites every restart })) ``` ### After ```typescript const existing = existingModelMap.get(m.id) return { ...existing, // preserve user's OpenClaw modifications id: m.id, // Cherry Studio managed fields always win name: m.name, contextWindow: existing?.contextWindow ?? 128000 // OpenClaw handles model-specific values } ``` ## Test plan - [x] `pnpm test:main` — 514 passed (including 44 OpenClawService tests) - [x] `pnpm typecheck` — node + web both pass - [x] `pnpm format` — no issues - [ ] Manual: sync provider to OpenClaw → modify vision/context in OpenClaw → restart → verify settings preserved 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Signed-off-by: Siin Xu <[email protected]> Co-authored-by: Claude Opus 4.6 <[email protected]> Co-authored-by: suyao <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #13665
syncProviderConfig()fully overwrote the model config on every sync, discarding user changes (vision, custom context window, etc.). Now uses a merge strategy: user-modified fields are preserved via object spread, Cherry Studio-managed fields (id,name) always take precedence.MODEL_CONTEXT_WINDOWSmap — context window defaults are delegated to OpenClaw's built-inMODEL_CONTEXT_WINDOWSinopencode-zen-models.ts. Cherry Studio only provides128000as fallback for new/unknown models on first sync.OpenClawModelConfiginterface with index signature to support arbitrary user-added fields without type errors.Before
After
Test plan
pnpm test:main— 514 passed (including 44 OpenClawService tests)pnpm typecheck— node + web both passpnpm format— no issues🤖 Generated with Claude Code