agentflow

← Dashboard

In src/agentflow/cli.py, if the --config path is given explicitly and does not exist as a file, print a clear error to stderr and return exit code 1 instead of silently falling back to defaults. Do not change any other behavior.

run_id: 20260823-154732-4077d0d5 · started: 2026-08-23 15:47:32 · finished: 2026-08-23 15:49:38

Config used

Status: pushed (ee16fc5d to phase-b)

#RoleModeResultBackendCostOutput
0 review read ok claude-code / claude-haiku-4-5-20251001 $0.090081
1. In `main()`, change the `--config` argument to `default=None` (keep the help text referencing `DEFAULT_CONFIG_PATH` for display purposes), so we can distinguish "user passed `--config`" from "user omitted it."
2. After `args = parser.parse_args(argv)`, if `args.config is not None` and `not os.path.isfile(args.config)`, print `f"Error: config file not found: {args.config}"` to `sys.stderr` and `return 1` immediately (before the `--version`/`--check`/goal branches, since it should short-circuit regardless of mode).
3. Compute the effective config path once: `config_path = args.config if args.config is not None else DEFAULT_CONFIG_PATH`.
4. Replace the two existing uses of `args.config` (`run_checks(args.config)` and `load_config(args.config)`) with `config_path`, so behavior for the "no `--config` given" case is unchanged (still silently falls back to defaults via `load_config`'s existing `_from_file` logic).
5. Leave `config.py` untouched — the missing-default-file fallback there stays as-is; the new validation only applies to an explicitly-provided `--config`.
6. Add/update a test in the CLI test file (find existing `test_cli*.py`) asserting: `agentflow --config missing.yaml <goal>` (and/or `--check`) exits 1 and stderr contains a clear "config file not found" message, while omitting `--config` with no config file present still falls back to defaults without error.
1 build write ok openrouter / deepseek/deepseek-v4-flash $0.002425
wrote 2 file(s): src/agentflow/cli.py, tests/test_cli.py
1 verify verify ok claude-code / claude-haiku-4-5-20251001 $0.152238
Verification summary:

- `git diff` confirms the implementation matches the plan exactly: `--config` defaults to `None`, an early check prints `Error: config file not found: {path}` to stderr and returns 1 when an explicit path doesn't exist, and both `run_checks`/`load_config` call sites use the computed `config_path`.
- `uv run python -c "import agentflow.cli"` — imports cleanly.
- Manual CLI runs:
  - `agentflow --config /tmp/definitely_missing_config.yaml "do something"` → prints the error to stderr, exit 1.
  - `agentflow --config /tmp/definitely_missing_config.yaml --check` → same error, exit 1.
  - `agentflow --check` (no `--config`) → falls back to default config, runs real health checks against claude-code/openrouter backends, exit 0 (unchanged behavior).
  - `agentflow --version` → still prints version, exit 0 (unchanged behavior).
- `uv run --with pytest pytest tests/ -v` → all 3 tests in `tests/test_cli.py` pass (missing explicit config fails, no-config falls back, `--check` with missing config fails).
- `uv run --with ruff ruff check` shows zero issues in `src/agentflow/cli.py` (only minor nested-`with` style nitpicks in the test file, unrelated to this change and not part of any configured project lint).

No regressions found; only the explicitly-requested behavior changed.

VERIFY_RESULT: PASS