Skip to content

fix(kiloclaw): preserve Brave config when provider is unset#2723

Open
joshavant wants to merge 3 commits intomainfrom
fix/kiloclaw-preserve-brave-controller
Open

fix(kiloclaw): preserve Brave config when provider is unset#2723
joshavant wants to merge 3 commits intomainfrom
fix/kiloclaw-preserve-brave-controller

Conversation

@joshavant
Copy link
Copy Markdown
Contributor

Summary

Preserves user-configured Brave search on image upgrades when the web search provider field is unset.

The controller config patcher no longer auto-assigns kilo-exa when KILO_EXA_SEARCH_MODE is unset if BRAVE_API_KEY is already configured. This keeps existing Brave configurations from being implicitly overridden during bootstrap/doctor/restore patching.

Added regression coverage for both normal config generation and restore-path config generation.

Verification

  • No manual verification performed.

Visual Changes

N/A

Reviewer Notes

Primary risk area is generateBaseConfig() web-search steering logic in controller boot patching.
Behavior for explicit providers and explicit Exa mode values is unchanged.

const shouldForceExa = kiloExaSearchMode === 'kilo-proxy';
const shouldAutoAssignExa = kiloExaSearchMode === 'unset' && !hasExplicitSearchProvider;
const shouldAutoAssignExa =
kiloExaSearchMode === 'unset' && !hasExplicitSearchProvider && !braveConfigured;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WARNING: Leaving the provider unset still allows Kilo Exa to win auto-detection

createKiloExaWebSearchProvider() is always registered and advertises envVars: ['KILOCODE_API_KEY'] with autoDetectOrder, and every KiloClaw machine has KILOCODE_API_KEY. In the Brave-configured case this branch now stops writing tools.web.search.provider, but it never explicitly selects brave or disables the customizer provider, so the runtime can still auto-select kilo-exa when the provider is missing. That means the restore/doctor path here does not reliably preserve Brave search despite the new regression tests passing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, this was valid.

I changed the unset-mode + Brave-configured path to explicitly prefer Brave (instead of leaving provider unset):

  • tools.web.search.provider = 'brave'
  • plugins.entries.kiloclaw-customizer.config.webSearch.enabled = false

Also updated regression tests for both normal and restore paths and re-ran:

  • pnpm -C services/kiloclaw test -- controller/src/config-writer.test.ts
  • pnpm typecheck
  • pnpm format

@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented Apr 22, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • services/kiloclaw/controller/src/config-writer.ts
  • services/kiloclaw/controller/src/config-writer.test.ts

Reviewed by gpt-5.4-20260305 · 527,726 tokens

@joshavant
Copy link
Copy Markdown
Contributor Author

Added the requested PR1 tightening:

  • Added controller test coverage for mode=unset + BRAVE_API_KEY + provider=custom-provider to verify explicit custom providers are preserved.
  • Added a clarifying comment in the controller defaulting block that defaults are only assigned when provider is unset.

Invariant remains: explicit provider strings are not clobbered by upgrade defaulting logic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant