Rename AGENT_BACKEND to DEFAULT_BACKEND#719
Merged
Merged
Conversation
Renames the global and per-user default-backend knob to parallel DEFAULT_MODEL and drop the redundant agent_ prefix. A shared _resolve_default_backend helper reads the new key with a one-release fallback to the old name (one-shot deprecation warning per source); a required default arg keeps the two absence semantics distinct (global readers default to claude, the per-user users.yaml reader defaults to None so a backend-less user still inherits the global backend). Five readers route through it: load_config, _cmd_apply, the behavioral eval, _load_user_configs, and the wizard prefill. _cmd_apply migrates a legacy AGENT_BACKEND key in the install.conf env dict before any gate reads it or /etc/kai/env is written. Four installer-side users.yaml scanners read both key names via _entry_backend. The wizard writes DEFAULT_BACKEND only. Effective-backend parameter names (post-cascade runtime values) are left unchanged. Adds nine back-compat/inheritance/migration tests.
Two installer-side scanners (_collect_backends_from_yaml, _collect_goose_os_users_from_yaml) stripped but did not lowercase the per-user backend value, unlike the runtime loader and the wizard-side scanners. A users.yaml entry with default_backend: Goose routes to goose at startup but the apply scanners saw 'Goose', so _apply_goose_config's 'goose' in <set> membership check skipped the per-user goose config deploy and _collect_goose_os_users_from_yaml dropped the os_user. Both now .strip().lower() to match the loader. _cmd_apply also writes the normalized global DEFAULT_BACKEND back into the env dict after validation so the downstream goose-config and sudoers gates and the written /etc/kai/env all see the canonical lowercase form. Pre-existing drift surfaced while routing all four scanners through _entry_backend; fixed here since the scanners are already in this change's blast radius. Adds three tests.
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
Renames the installation-wide and per-user "which backend by default" knob from
AGENT_BACKENDtoDEFAULT_BACKEND, parallelingDEFAULT_MODELand dropping the redundant "agent_" prefix (backends are the agents in this codebase). The old name is still read for one release with a one-shot deprecation warning at every reader; all writers emit the new name only.This is groundwork ahead of adding the Pi backend (#696), so that work only learns the new vocabulary.
What changed
Config.agent_backend→Config.default_backendandUserConfig.agent_backend→UserConfig.default_backend. Every constructor call and attribute access swept.AGENT_BACKEND→DEFAULT_BACKEND(env),agent_backend:→default_backend:(users.yaml per-user key),AGENT_BACKEND→DEFAULT_BACKEND(install.conf env dict)._resolve_default_backend(get, new_key, old_key, *, context, default)inconfig.py: reads the new key, falls back to the old with a one-shot per-context deprecation log. Takes a requireddefaultso the two absence semantics stay distinct — global readers passdefault="claude"(installation default); the per-user users.yaml reader passesdefault=Noneso a backend-less user still inherits the global backend via the existinguser_backend or global_backendcascade (rather than being pinned to claude on a non-claude install).load_config(env),_cmd_apply(install.conf dict),behavioral._run_cli(env),_load_user_configs(per-user yaml), plus the wizard prefill._cmd_apply) consumes the install.conf env dict directly (never throughload_config), so it migrates a legacyAGENT_BACKENDkey toDEFAULT_BACKENDonce at the top of apply, before any backend gate reads it or/etc/kai/envis written. Without this, a legacy install.conf would validate a codex/goose default model against the wrong (claude/anthropic) surface and fail, or silently skip backend-specific setup._users_yaml_goose_providers,_users_yaml_agent_backends,_collect_backends_from_yaml,_collect_goose_os_users_from_yaml) read each entry's backend through a new_entry_backend(entry)helper (preferdefault_backend, fall backagent_backend).DEFAULT_BACKENDonly (so a re-run silently migratesinstall.conf).templates/.env,templates/users.yaml,templates/config/goose-config.yaml) and docs (README; wiki pages pushed after merge).Internal function parameters named
agent_backendthat hold the effective (post-cascade) backend at a call site (e.g.models_for_backend,review_pr,run_triage,_apply_goose_config) are intentionally left unchanged — they name a runtime value, not a default.Test plan
make check(ruff + format) cleanmake testclean (4576 passed, 1 skipped; +18 overmain)AGENT_BACKENDenv still resolves with a warning; new key wins when both set; legacyagent_backend:users.yaml key still resolves with a warningdefault=None), not claudeAGENT_BACKEND=codexinstall.conf validates against the codex surface and writes/etc/kai/envwithDEFAULT_BACKENDand noAGENT_BACKEND; a new-name install.conf passes through cleanlyDEFAULT_BACKENDand legacyAGENT_BACKENDDEFAULT_BACKEND, dropsAGENT_BACKENDmake configshows the "Default backend" prompt; a legacy/etc/kai/envwithAGENT_BACKENDlogs the deprecation warning at startup and still resolves