Skip to content

fix(cli): honor workspace_dir from config.yaml when --workspace not provided (#90)#91

Open
draix wants to merge 1 commit into
MiniMax-AI:mainfrom
draix:fix/cli-workspace-dir-from-config
Open

fix(cli): honor workspace_dir from config.yaml when --workspace not provided (#90)#91
draix wants to merge 1 commit into
MiniMax-AI:mainfrom
draix:fix/cli-workspace-dir-from-config

Conversation

@draix
Copy link
Copy Markdown

@draix draix commented May 11, 2026

Summary

Fixes #90workspace_dir configured in config.yaml is ignored by the CLI mode.

When the user does not pass --workspace, the CLI currently falls back directly to Path.cwd() and never reads workspace_dir from config.yaml. This PR makes the CLI honour the same precedence the ACP adapter already uses:

--workspace (CLI) > workspace_dir (config.yaml) > Path.cwd()

Reproduction (from the issue)

config.yaml:

workspace_dir: "./workspace"

Run:

python -m mini_agent.cli

Before this PR:

Workspace: D:\2026\Mini-Agent

Expected (and after this PR):

Workspace: D:\2026\Mini-Agent\workspace

What changed

  • mini_agent/cli.py

    • New resolve_workspace_dir(cli_workspace, config) helper that implements the precedence: CLI arg > config.agent.workspace_dir > Path.cwd(). It expands ~ and resolves relative paths against the current cwd, so ./workspace becomes <cwd>/workspace — matching the behaviour described in the issue.
    • main() no longer pre-resolves the workspace path before the config is loaded. Instead it passes the raw args.workspace (or None) to run_agent(), which resolves the final workspace right after loading the config.
    • This mirrors the pattern already used in mini_agent/acp/__init__.py::MiniMaxACPAgent.newSession:
      workspace = Path(params.cwd or self._config.agent.workspace_dir).expanduser()
      so CLI and ACP entrypoints now behave consistently.
  • tests/test_cli_workspace.py (new)

    • --workspace wins over config.workspace_dir.
    • Without --workspace, the value from config.yaml is used.
    • Relative ./workspace in config resolves against the current cwd (regression test for the exact repro in config.yaml中的workspace_dir 配置在 CLI 模式下未生效 #90).
    • Empty workspace_dir in config falls back to Path.cwd().
    • ~/... in workspace_dir is expanded to the user home directory.

Test plan

$ uv run pytest tests/test_cli_workspace.py -v
...
5 passed in 0.29s

Full test suite was also run; the pre-existing failures on main (missing mini_agent/config/config.yaml, API keys, and an unrelated pydantic issue in test_acp_invalid_session) are not introduced by this PR.

Notes

  • No behaviour change when --workspace is provided.
  • No behaviour change for users who do not set workspace_dir in config.yamlPath.cwd() is still the last-resort default.
  • The Path.mkdir(parents=True, exist_ok=True) call previously made by main() is preserved inside run_agent() after the workspace is resolved.

Closes #90

…rovided (MiniMax-AI#90)

Previously, the CLI entry point (mini_agent/cli.py::main) ignored
'workspace_dir' from config.yaml entirely: when '--workspace' was
omitted, it fell straight back to Path.cwd().

This mirrors the precedence already used by the ACP adapter
(mini_agent/acp/__init__.py): CLI arg > config.agent.workspace_dir
> Path.cwd(). The resolution is moved into run_agent() after the
config has been loaded, behind a new resolve_workspace_dir() helper
that expands '~' and resolves relative paths against the current
cwd (so e.g. './workspace' becomes '<cwd>/workspace').

Adds tests/test_cli_workspace.py covering the precedence, the
relative-path case from the issue repro, the '~' expansion case,
and the empty-config fallback to cwd.

Closes MiniMax-AI#90
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.

config.yaml中的workspace_dir 配置在 CLI 模式下未生效

1 participant