fix: honor CLI config defaults#1746
Merged
jmhbh merged 3 commits intokagent-dev:mainfrom Apr 27, 2026
Merged
Conversation
Signed-off-by: Akash Kumar <meakash7902@gmail.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes CLI behavior so values stored in ~/.kagent/config.yaml are loaded first and then used as Cobra flag defaults, while still allowing explicit CLI flags to override them. This addresses issue #973 where commands like kagent dashboard did not honor the configured namespace.
Changes:
- Initialize/load config before constructing Cobra commands and pass the shared config object through execution.
- Bind persistent flag defaults to the loaded config values (instead of hardcoded defaults).
- Use the loaded namespace as the
deploy --namespacedefault and add tests covering config-file defaults and flag overrides.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| go/core/cli/cmd/kagent/main.go | Loads config before building commands; uses loaded config values as flag defaults; ensures interactive mode uses the same config instance. |
| go/core/cli/cmd/kagent/main_test.go | Adds tests validating config file loading, default propagation into flags, and CLI flag override behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
jmhbh
approved these changes
Apr 27, 2026
Contributor
jmhbh
left a comment
There was a problem hiding this comment.
LGTM, thanks for your contribution
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.
Fixes #973
Summary
~/.kagent/config.yamlbefore constructing Cobra commands so saved values become the CLI defaults.--namespacedefault so registering that command does not reset the configured namespace.Testing
go test ./core/cli/cmd/kagentgo test ./core/cli/internal/config ./core/cli/cmd/kagentgo test ./core/cli/...go test -race -skip 'TestE2E.*' ./core/cli/...go vet ./core/cli/cmd/kagent ./core/cli/internal/configgo run github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.11.3 run ./core/cli/cmd/kagent ./core/cli/internal/configgit diff --checkgo run ./core/cli/cmd/kagent --helpshows config-file defaults for--kagent-url,--namespace,--output-format, and--timeout.