fix(controller): preserve channel configs and agent model fallbacks on redeploy#1337
Merged
jeanduplessis merged 4 commits intomainfrom Mar 23, 2026
Merged
Conversation
…n redeploy Channel configs (Telegram, Discord, Slack) and agent model defaults were being overwritten with fresh object literals on every restart/redeploy, destroying user customizations. Switch to null-coalescing init + field-level set pattern (consistent with the rest of generateBaseConfig) so existing config keys are preserved and only env-derived fields are updated.
Contributor
Author
Code Review SummaryStatus: 2 Issues Found | Recommendation: Address before merge Overview
Fix these issues in Kilo Cloud Issue Details (click to expand)CRITICAL
WARNING
SUGGESTION
Other Observations (not in diff)Issues found in unchanged code that cannot receive inline comments: N/A Files Reviewed (2 files)
Reviewed by gpt-5.4-20260305 · 1,144,798 tokens |
…dits The previous field-level set pattern unconditionally overwrote allowFrom on every redeploy, which destroyed user-customized DM allowlists. Telegram: TELEGRAM_DM_ALLOW_FROM env override still always wins; without it, allowFrom is only written when the key is absent (first boot). Discord: allowFrom is only seeded when the key is absent; subsequent redeploys leave the user's value untouched.
jeanduplessis
approved these changes
Mar 23, 2026
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
The controller's
generateBaseConfig()was overwriting channel configs (channels.telegram,channels.discord,channels.slack) and the agent model default (agents.defaults.model) with fresh object literals on every restart/redeploy. This destroyed user customizations such as Discord guild configs, Slack slash commands, Telegram group policies, DM allowlists, and model fallback settings.Fix: Switch from full object assignment to the null-coalescing init + field-level set pattern (already used elsewhere in
generateBaseConfigforgateway,tools,browser,plugins.entries, etc.). On redeploy, existing config objects are preserved viaconfig.channels.X = config.channels.X ?? {}and only env-derived fields (botToken,enabled,dmPolicy, etc.) are updated. User-added keys are left untouched. Initial bootstrap still sets all defaults because the config starts empty.Changes in
config-writer.ts:config.channels.telegram = { ... }with field-level setsconfig.channels.discord = { ... }with field-level sets; also preservesdmsub-objectconfig.channels.slack = { ... }with field-level setsconfig.agents.defaults.model = { primary: ... }withconfig.agents.defaults.model.primary = ..., preservingfallbackand other user-set keysVerification
pnpm typecheck— passed (0 errors)pnpm test -- controller/src/config-writer.test.ts— 47 tests passedpnpm test(full suite) — 948 tests passed across 42 filespnpm lint(kiloclaw) — 0 warnings, 0 errorsVisual Changes
N/A
Reviewer Notes
config.gateway,config.tools,config.browser, andconfig.plugins.entriesin the same function — no new patterns introduced.writeBaseConfig(fresh install / config restore) path is unaffected because config starts empty, so the?? {}initializers create fresh objects and all fields are set — identical behavior to before.Built for Florian by Kilo for Slack