Skip to content

fix(cli): Codex config generation clips enabled_tools at 80 columns #201

Open

Description

@coygeek

Summary

artemis mcp --generate-config codex prints a truncated TOML enabled_tools array when output is captured at the default width or at COLUMNS=80. The command exits successfully, but the marked configuration block cannot be parsed as TOML. This prevents directly using the generated snippet at those widths; setting COLUMNS=240 worked in the measured case.

Steps to reproduce

Use a source checkout with the project's locked Python dependencies installed. From the checkout, capture both widths without installing any MCP configuration:

COLUMNS=80 uv run --no-sync artemis mcp --generate-config codex > generated-80.txt
COLUMNS=240 uv run --no-sync artemis mcp --generate-config codex > generated-240.txt
uv run --no-sync python - <<'PY'
from pathlib import Path
import tomllib

for width in (80, 240):
    text = Path(f"generated-{width}.txt").read_text()
    start = text.index("# BEGIN ARTEMIS MCP CONFIG")
    end_marker = "# END ARTEMIS MCP CONFIG"
    end = text.index(end_marker, start) + len(end_marker)
    block = text[start:end]
    try:
        config = tomllib.loads(block)
    except tomllib.TOMLDecodeError as exc:
        print(f"width={width}: {exc}")
    else:
        tools = config["mcp_servers"]["artemis"]["enabled_tools"]
        print(f"width={width}: parsed, tools={len(tools)}")
PY

The local run used clean process environment inputs, isolated Artemis application and trace directories, and a disposable loopback no-device ADB endpoint. That endpoint received zero requests. No model credentials, phone actions, MCP installation, or global client configuration writes were used. Repeating with COLUMNS unset also reproduced the narrow-output failure. These observations concern captured non-TTY stdout; interactive terminal behavior was not measured.

Expected behavior

The CLI option promises ready-to-use MCP configuration and explicitly lists Codex as supported. The marked TOML block should retain the complete configuration, including all five enabled tools, independently of display width so it can be copied and parsed.

Actual behavior

Both generator invocations returned exit status 0. At 80 columns, the line ends mid-string:

enabled_tools = ["mobile_run_task", "mobile_manage_task", "mobile_get_device_sta

The extraction and parse probe reported:

width=80: Illegal character '\n' (at line 9, column 81)
width=240: parsed, tools=5

The wider output included mobile_run_task, mobile_manage_task, mobile_get_device_state, mobile_inspect_trace, and mobile_diagnose. This report establishes generated-config corruption, without asserting a Codex client connection failure.

Evidence

  • Expected source: The --generate-config option help in artemis/interfaces/cli/commands/mcp.py:733-739 promises ready-to-use configuration and includes Codex; the Codex snippet builder declares the five-tool allow-list.
  • Failure source: Captured output from the CLI commands and the tomllib extraction probe above; the generator's output path constructs a Rich Syntax object and prints it at artemis/interfaces/cli/commands/mcp.py:813-825.
  • Evidence provenance: observed
  • Local verification: reproduced
  • Reproduction completeness: complete

The generator source locates the CLI contract and rendering path. The existing Codex generator test in tests/unit/test_cli.py:218-242 checks selected output substrings and the internal tool list; it does not parse the emitted TOML.

Runtime or environment

  • Fresh checkout of current main: 351ca8422f7b5b54e80a9c1ce03a222e02415b6b; repository releases and tags were empty at verification.
  • Artemis CLI reports 1.0; Python 3.12.15, Rich 15.0.0, Typer 0.27.1, macOS.
  • The existing dependency environment was reused read-only after verifying an identical uv.lock; source import identity was checked to resolve Artemis and its workspace client from the fresh checkout. The commands used --no-sync to preserve that environment.
  • Captured stdout with COLUMNS unset, 80, and 240; no TTY and no forced color.

Restoration check

Run the generator with captured stdout at 80 columns and with COLUMNS unset, extract only the marked block, and require it to parse as TOML while retaining all five tool names. Keep the 240-column case as a control with the same parsed tool list. Successful exit or selected substring checks alone do not restore the configuration contract.

Triage assessment

  • Impact level: P2
  • Assessment status: supported
  • Impact basis: The supported config generator emits syntactically invalid TOML at a common captured-output width while returning success, blocking direct use of that snippet. The observed scope is config output, with no measured client connection failure.
  • Workaround status: available
  • Workaround basis: Setting COLUMNS=240 produced a parseable block with the complete five-tool list in the same environment. Users can verify the extracted block with tomllib before using it; longer installation paths may require a wider value.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions