Skip to content

feat: make Claude Code agent runtime configurable (replace hardcoded --bare) #1602

Closed

Description

@cwing-nvidia

Background

The Claude Code agent (responses_api_agents/claude_code_agent/) currently invokes the claude CLI with a hardcoded --bare flag, which "skips auto-discovery of hooks, skills, plugins, MCP servers, auto memory, and CLAUDE.md so each scripted call starts clean and fast." Combined with a fresh, per-invocation CLAUDE_CONFIG_DIR (a UUID directory created and rmtree'd on every call) and IS_SANDBOX=1, the agent guarantees that a rollout depends only on the model, the task input, and the explicit config — nothing about the host machine.

This isolation-by-default is the correct default for an eval/benchmark harness: it makes reproducibility a controlled variable instead of measuring "the model + whatever happens to be on this developer's laptop" (notably, the Gym repo itself contains a root .claude/skills/ for docs authoring that would otherwise leak into unrelated evals).

The problem is not the default — it is that --bare is all-or-nothing and hardcoded, with no config seam. To enable skills, MCP servers, or hooks today, you must edit app.py's _run_claude_code command list and rework the CLAUDE_CONFIG_DIR lifecycle. This contradicts Gym's "everything composable via Hydra config" philosophy, and it directly blocks #1256 (agent skill evaluation), whose "out of scope: modifying existing agent code" premise cannot hold while skill loading requires an agent-code edit.

Description

Make the Claude Code agent's runtime capabilities configurable instead of hardcoded. Expose the isolation level as a knob (default preserves today's clean/reproducible behavior) plus explicit opt-ins for MCP servers and custom settings, and refactor command/config-dir construction into testable helpers.

A note on --bare granularity: Claude Code's --bare is all-or-nothing for auto-discovery (skills, hooks, plugins, MCP, auto memory, CLAUDE.md), whereas --mcp-config and settings are explicit and apply independently. So the honest, minimal API is three knobs — bare, mcp_config, settings — rather than a separate flag per discoverable feature. Skills/hooks/plugins/memory are enabled together by setting bare: false.

This is a contained, independently valuable change: it unblocks MCP and settings customization in addition to skills, and it converts #1256's agent-half from "fork the agent" into "set config."

Design

Config

Add fields to ClaudeCodeAgentConfig:

claude_code_agent:
  responses_api_agents:
    claude_code_agent:
      entrypoint: app.py
      # ... existing fields ...
      bare: true        # default: pass --bare; skip auto-discovery (skills/hooks/plugins/MCP/memory/CLAUDE.md)
      mcp_config: null  # path to an MCP server config file, passed to --mcp-config (explicit; works even with bare: true)
      settings: null    # path to a settings JSON layered into the per-run CLAUDE_CONFIG_DIR/settings.json
  • bare defaults to true, so behavior is byte-for-byte identical to today.
  • mcp_config and settings are explicit and apply regardless of bare (they are not auto-discovery).
  • Set bare: false to let Claude Code discover skills/hooks/plugins/memory/CLAUDE.md from CLAUDE_CONFIG_DIR and the working directory.
  • Defaults are chosen so existing configs and rollouts are unaffected.

Command construction

Extract a testable _build_command(model, instruction, system_prompt) that builds the claude argv from config:

  • Append --bare only when config.bare is true.
  • Append --mcp-config <path> when mcp_config is set (independent of --bare).
  • Keep --dangerously-skip-permissions, IS_SANDBOX=1, and the per-model env wiring unchanged.

See the Claude Code CLI reference for exact flag names; the agent passes through what the installed CLI version supports.

Settings + CLAUDE_CONFIG_DIR

Extract _build_settings() and _setup_config_dir():

  • _build_settings() starts from the telemetry-disabling defaults; when settings is set, its JSON is layered on top (top-level keys override, env shallow-merged so telemetry stays off unless explicitly overridden).
  • _setup_config_dir() creates the fresh per-call dir and stages settings.json. The dir is still created per request and rmtree'd afterward — it is already valid for the full duration of a run and keeps opted-in content from leaking between rollouts. This is the staging seam feat: agent skill evaluation infrastructure #1256 reuses to place skills under CLAUDE_CONFIG_DIR/skills/.

Scope boundary with #1256

  • This issue owns the agent mechanism: the bare knob, the _build_command/_build_settings/_setup_config_dir seams, and explicit MCP/settings opt-ins.
  • feat: agent skill evaluation infrastructure #1256 owns skills as an evaluation variable: nemo_gym/skills.py (load_skill_directory), skills_ref tagging in rollout_collection.py, the top-level skills.path config, and the skills-specific staging onto the now-configurable agent.

Out of Scope

  • Skills loading, skills_ref tagging, or skills metrics — owned by feat: agent skill evaluation infrastructure #1256.
  • Training / token-ID / logprob wiring for the Claude Code agent (tracked separately).
  • Routing capability opt-ins through Gym's model server.
  • A general capability framework for non-Claude-Code agents.

Acceptance Criteria

  • ClaudeCodeAgentConfig exposes bare (default true), mcp_config, and settings.
  • With default config, the emitted claude command and CLAUDE_CONFIG_DIR behavior are unchanged from today (verified by test), preserving reproducibility for existing evals.
  • Setting mcp_config passes --mcp-config (and coexists with --bare); setting bare: false drops --bare.
  • settings is layered into the per-run CLAUDE_CONFIG_DIR/settings.json with telemetry defaults preserved unless overridden.
  • Enabling a capability via config requires no edits to app.py.
  • Tests cover the default (bare: true) command, an opted-in path, and the settings merge.
  • README documents the new config fields and the reproducibility trade-off of disabling bare.

Relationship to #1256

Metadata

Metadata

Assignees

No one assigned

    Labels

    AgentsConfigcore-infraevaluation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions