Repository navigation
feat: make claude code agent runtime capabilities configurable - #1603
Merged
Merged
Conversation
Replace the hardcoded `--bare` flag with config knobs so skills, MCP servers, and custom settings can be enabled via config instead of editing app.py. Defaults (bare=true, no mcp_config/settings) preserve the current isolated, reproducible behavior. - Add `bare`, `mcp_config`, and `settings` to ClaudeCodeAgentConfig. - Extract testable `_build_command`, `_build_settings`, and `_setup_config_dir` helpers from `_run_claude_code`. `--bare` is only passed when `bare` is true; `--mcp-config` is explicit and applies regardless. The per-run CLAUDE_CONFIG_DIR is the staging seam reused by skills evaluation (#1256). - Cover the new helpers and `_run_claude_code` wiring/timeout paths with unit tests (subprocess mocked); document the knobs and the reproducibility trade-off in the README and config template. Relates to #1602. Signed-off-by: Chris Wing <[email protected]>
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
cwing-nvidia
marked this pull request as ready for review
June 16, 2026 04:07
cmunley1
reviewed
Jun 16, 2026
cmunley1
reviewed
Jun 16, 2026
Contributor
|
looks good to me |
Contributor
|
btw, anthropic docs say
maybe worth mentioning their recommendation in readme. also, i think there is not much for agent to autodiscover as it gets a fresh tmpdir per run but not fully sure |
Note that bare is the recommended mode for scripted/SDK calls (per Claude docs), reframe the Runtime capabilities section to reference the config knobs above, standardize the auto-discovery list, and tidy wording. Signed-off-by: Chris Wing <[email protected]>
cmunley1
approved these changes
Jun 22, 2026
ritaneves
pushed a commit
that referenced
this pull request
Jun 25, 2026
## Summary Replaces the hardcoded `--bare` flag in the Claude Code agent with config knobs, so skills / MCP servers / custom settings can be enabled via config instead of editing `app.py`. Defaults preserve today's isolated, reproducible behavior. - Adds `bare` (default `true`), `mcp_config`, and `settings` to `ClaudeCodeAgentConfig`. - Extracts testable `_build_command`, `_build_settings`, and `_setup_config_dir` helpers from `_run_claude_code`. `--bare` is only passed when `bare` is `true`; `--mcp-config` is explicit and applies regardless. The per-run `CLAUDE_CONFIG_DIR` is the staging seam reused by skills evaluation (#1256). - Unit tests for the new helpers and `_run_claude_code` wiring/timeout (subprocess mocked); README + config template document the knobs and the reproducibility trade-off. A note on API shape: Claude Code's `--bare` is all-or-nothing for *auto-discovery* (skills/hooks/plugins/MCP/memory/CLAUDE.md), while `--mcp-config` and settings are *explicit*. So the minimal honest API is three knobs (`bare`, `mcp_config`, `settings`) rather than a flag per feature — `bare: false` enables auto-discovery as a group. Implements #1602. Unblocks the agent-half of #1256. ## Test plan Unit tests pass (`27 passed`, ruff clean). Unit coverage of `app.py` raised 62% → 79%; all added/changed code is covered. The remaining gaps (`responses`/`run`/`_resolve_base_url`) are pre-existing methods covered by `ng_test`'s live-server run. Unit tests mock `asyncio.create_subprocess_exec`, so the real `claude` binary is not exercised. **Smoke test before marking ready** (pending API key): - [x] **Default (`bare: true`)**: `ng_run` the reasoning_gym claude_code_agent config, `ng_collect_rollouts` one task; confirm a non-error row with `reward`, populated `response.output`, and `usage`. Confirms the refactor works against the real CLI. - [x] **`mcp_config`**: set it to a minimal MCP server config; run a task needing the tool; confirm a tool call to the MCP tool in the output (and that it coexists with default `bare: true`). - [ ] **`bare: false`**: confirm a task still completes with `--bare` dropped. *(Not run live — only omits a flag; covered by unit tests `test_bare_false_omits_flag`.)* - [x] **`settings`**: set a settings JSON with a unique `env` var and have the model echo it via Bash; the value appears in the answer, proving the merged `settings.json` is read from the staged config dir. ### Smoke test details (reproducible) Run against an endpoint serving the Anthropic Messages API. `env.yaml`: ```yaml anthropic_api_key: <key> anthropic_model_name: aws/anthropic/bedrock-claude-sonnet-4-6 anthropic_base_url: https://<host> # no /v1 suffix; the CLI appends /v1/messages ``` **1. Default (`bare: true`) — confirms the refactor works against the real CLI** ```bash ng_run "+config_paths=[resources_servers/reasoning_gym/configs/reasoning_gym_claude_code_agent.yaml]" ng_collect_rollouts \ +agent_name=reasoning_gym_claude_code_agent \ +input_jsonl_fpath=resources_servers/reasoning_gym/data/example.jsonl \ +output_jsonl_fpath=/tmp/cc_default.jsonl +limit=1 ``` Result: rollout completed end-to-end (2 turns, tokens reported, full verify pipeline ran). ✅ **2. `mcp_config` with default `bare: true` — confirms `--mcp-config` is honored even with `--bare`** MCP config (`/tmp/mcp.json`) — the official reference "everything" server, which exposes an `add` tool: ```json { "mcpServers": { "everything": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-everything"] } } } ``` Input task (`/tmp/cc_mcp_input.jsonl`, one row) instructs the model to use the MCP `add` tool (not Bash) and box the result; `metadata.source_dataset=basic_arithmetic` so the reasoning_gym verifier scores it: ```json {"responses_create_params": {"input": [{"role": "user", "content": "You have an MCP tool named 'add' (exposed as mcp__everything__add). You MUST use it to compute 12345 + 67890 — do not calculate it yourself or use Bash. Put only the final number inside <answer></answer> tags."}]}, "question": "Use the MCP add tool to compute 12345 + 67890.", "answer": "80235", "metadata": {"source_dataset": "basic_arithmetic", "source_index": 0, "expression": "12345 + 67890", "num_terms": 2, "num_digits": 5, "difficulty": {"num_terms": [2, 6], "num_digits": [1, 5]}}, "agent_ref": {"type": "responses_api_agents", "name": "reasoning_gym_claude_code_agent"}} ``` Run with `mcp_config` set via a Hydra override (note `bare` stays at its default `true`): ```bash ng_run "+config_paths=[resources_servers/reasoning_gym/configs/reasoning_gym_claude_code_agent.yaml]" \ +reasoning_gym_claude_code_agent.responses_api_agents.claude_code_agent.mcp_config=/tmp/mcp.json ng_collect_rollouts \ +agent_name=reasoning_gym_claude_code_agent \ +input_jsonl_fpath=/tmp/cc_mcp_input.jsonl \ +output_jsonl_fpath=/tmp/cc_mcp.jsonl +limit=1 grep -o 'mcp__[A-Za-z0-9_-]*' /tmp/cc_mcp.jsonl | sort -u ``` Result: the model invoked `mcp__everything__add`, `reward=1.0`, `extracted_answer=80235`, 3 turns. The MCP server loaded and its tool was used **with `--bare` still active**, validating the design choice to treat explicit `--mcp-config` as independent of the auto-discovery (`bare`) knob. ✅ **3. `settings` — confirms a user settings JSON is merged into the staged `CLAUDE_CONFIG_DIR` and its `env` reaches tools** > An `env`-var signal is used instead of a `permissions.deny` rule: the agent always passes `--dangerously-skip-permissions`, which would bypass deny rules and give a misleading result. Settings file (`/tmp/cc_settings.json`): ```json { "env": { "NG_SMOKE_TOKEN": "ng-smoke-7f3a9" } } ``` Input task (`/tmp/cc_settings_input.jsonl`, one row) tells the model to `echo "$NG_SMOKE_TOKEN"` via Bash and box the result; `metadata.source_dataset=basic_arithmetic` keeps the verifier happy: ```json {"responses_create_params": {"input": [{"role": "user", "content": "Use the Bash tool to run exactly this command: echo \"$NG_SMOKE_TOKEN\" Then put the exact printed value inside <answer></answer> tags. Do not guess the value; obtain it by actually running the command."}]}, "question": "Echo the NG_SMOKE_TOKEN environment variable via Bash.", "answer": "ng-smoke-7f3a9", "metadata": {"source_dataset": "basic_arithmetic", "source_index": 0, "expression": "0 + 0", "num_terms": 2, "num_digits": 1, "difficulty": {"num_terms": [2, 6], "num_digits": [1, 1]}}, "agent_ref": {"type": "responses_api_agents", "name": "reasoning_gym_claude_code_agent"}} ``` Run with `settings` set via a Hydra override: ```bash ng_run "+config_paths=[resources_servers/reasoning_gym/configs/reasoning_gym_claude_code_agent.yaml]" \ +reasoning_gym_claude_code_agent.responses_api_agents.claude_code_agent.settings=/tmp/cc_settings.json ng_collect_rollouts \ +agent_name=reasoning_gym_claude_code_agent \ +input_jsonl_fpath=/tmp/cc_settings_input.jsonl \ +output_jsonl_fpath=/tmp/cc_settings.jsonl +limit=1 grep -o 'ng-smoke-7f3a9' /tmp/cc_settings.jsonl | head -1 ``` Result: the answer contained `ng-smoke-7f3a9`, proving the merged `settings.json` was read and its `env` reached the Bash tool environment. ✅ --------- Signed-off-by: Chris Wing <[email protected]> Co-authored-by: Christian Munley <[email protected]> Signed-off-by: Rita Fernandes Neves <[email protected]>
5 tasks done
ffrujeri
added a commit
that referenced
this pull request
Jul 23, 2026
## Summary Integrates the OpenAI Codex CLI (`codex exec`) as a built-in NeMo Gym agent harness, mirroring the Claude Code agent's architecture (#1336, #1603). Any Gym environment can now evaluate models inside the Codex harness — against OpenAI directly, or against any backend Gym serves via a model server. Implements #1389 (part of #1042). The central constraint: Codex removed `wire_api = "chat"` (openai/codex#7782) and only speaks the **Responses API over SSE**. Where Claude Code needed a Messages ↔ Responses mapping (`/v1/messages`), Codex needs Gym's *native* format plus a streaming envelope and tolerance for its wire dialect. So this PR has two parts: **Core seam — every Gym model server speaks the streaming Responses dialect** (`nemo_gym/responses_streaming.py`, dispatch route on `SimpleResponsesAPIModel`): - Non-streaming `/v1/responses` requests are unchanged (strict validation, same 422 shape). - `stream: true` requests are sanitized onto the strict params model and the complete response is re-emitted as synthesized SSE (`response.created` → `response.output_item.done` per item → `response.completed` — the minimal sequence streaming clients require, verified against codex-cli 0.144.4). - The sanitizer degrades gracefully instead of 422-ing the rollout: drops unknown bookkeeping fields (`client_metadata`, `prompt_cache_key`), flattens `namespace` tool specs to `<ns>__<tool>` functions (and splits the names back into `namespace` + `name` on the way out — the wire shape Codex's tool router requires), hoists function tools out of code-mode `additional_tools` carriers, hoists leading developer messages into `instructions` (strict chat backends admit exactly one system message at position 0), and prunes SDK-unknown nested fields via generic `extra_forbidden` retry (e.g. `reasoning.context`). - Converter fixes in `responses_converter.py`: `instructions` was silently dropped in Responses → ChatCompletions conversion — now mapped to a leading system message (also fixes the latent loss of Claude Code's system prompt on the vLLM path); when `instructions` is present, the leading system/developer run is folded into that single system message. **Agent — `responses_api_agents/codex_agent/`:** - Runs `codex exec --json --ephemeral --skip-git-repo-check` per request with a fresh generated `CODEX_HOME` (config.toml) and scratch `--cd` workdir, both removed afterwards. - Gym-owned model provider with `env_key` auth — no `codex login`/auth.json needed. `model_server` ref (with `/ng-rollout/<id>` capture correlation) or direct `openai_base_url`. - Isolation defaults: `approval_policy=never`, analytics/history/update-checks off, `web_search` disabled, `features.multi_agent/code_mode` off. `sandbox_mode` configurable (default `danger-full-access`, mirroring the Claude agent's skip-permissions default — Gym envs provide their own isolation). - Model-name pinning: for models Codex recognizes, model-family gating enables code mode, which moves tools into carriers chat-served models cannot drive; `model: null` + `model_server` writes a `gym-policy-model` placeholder to keep classic function tools (Gym servers substitute their configured model anyway). - Gym MCP tools: `/seed_session` metadata becomes a per-rollout streamable-HTTP `mcp_servers` entry with the session token on `http_headers`. - Skills staged into `CODEX_HOME/skills/` from the run-level `skills_ref` (native discovery, no `--bare` analog needed). - Timeout is the runaway bound (no `--max-turns` equivalent): kill on timeout → empty response → verify still runs (reward 0). Codex runs in its own process group and timeout kills the whole group — the npm shim's vendored-binary child otherwise survives and holds the stdout pipe open past the kill. - JSONL events map to a uniform trajectory shape (`agent_message`/`reasoning` → messages with `<think>` prefixes; `command_execution`/`mcp_tool_call`/`file_change`/`web_search`/`todo_list` → `function_call` + `function_call_output` pairs; `turn.completed` → usage incl. cached/reasoning details). A run ending on buffered reasoning is surfaced as a think-tagged message (vLLM reasoning parsers sometimes route the final answer there). - `extra_config` deep-merge knob for arbitrary `config.toml` content; per-rollout Gym MCP entries win name collisions. Also: composed showcase configs `reasoning_gym_codex_agent[_model_server].yaml`, README(s), agent-skills docs updated with the Codex staging location. ## Test plan Unit tests pass (full suite `1270 passed, 31 skipped`; ruff + pre-commit clean). New coverage: ~45 agent tests (command/config/TOML generation, `CODEX_HOME` staging + cleanup, timeout/process-group kill, MCP config, rollout correlation, skills forwarding, event parsing) and ~28 core tests (sanitizer, SSE synthesis, dispatch route incl. non-streaming strict-validation regression, converter `instructions` mapping). Unit tests mock `asyncio.create_subprocess_exec`; the real CLI and full stack were smoke-tested against codex-cli 0.144.4 with a vLLM-dialect model server (`inference-api` Qwen3.6-35B backend): - [x] **Streaming dialect via curl**: `stream: true` + codex bookkeeping fields against a live `vllm_model` server returns `response.created` / `output_item.done` / `response.completed` SSE. - [x] **Real CLI shell round trip**: `codex exec` against the Gym model server — model called `exec_command`, Codex executed `` /bin/bash -lc 'echo $((17*23))' `` → `391`, multi-turn replay (reasoning + function_call + output) validated, `turn.completed` usage reported. - [x] **MCP round trip**: header-gated streamable-HTTP FastMCP server (the Gym resources-server stack) — namespaced `function_call` routed to the MCP tool with the per-rollout session token, result returned to the model. - [x] **Full eval loop**: `gym env start --resources-server reasoning_gym/reasoning_gym_codex_agent_model_server --model-type vllm_model` + `gym eval run --no-serve ... --limit 2` → 2/2 rollouts with rewards, `turns_used`, token usage, and aggregate metrics. - [x] **Timeout degradation**: one live rollout exceeded the 600 s budget and landed as an empty, reward-0 rollout (and exposed the orphaned-child kill bug this PR fixes with process-group kill). ### Smoke test details (reproducible) `env.yaml` (any OpenAI-compatible chat endpoint): ```yaml policy_base_url: https://<host>/v1 policy_api_key: <key> policy_model_name: <model> ``` ```bash gym env start \ --resources-server reasoning_gym/reasoning_gym_codex_agent_model_server \ --model-type vllm_model gym eval run --no-serve \ --agent reasoning_gym_codex_agent_model_server \ --input resources_servers/reasoning_gym/data/example.jsonl \ --output codex_rollout.jsonl --limit 1 ``` Standalone CLI seam check (no resources server) — take the model server URL from the `gym env start` log: ```bash mkdir -p /tmp/codex_home && cat > /tmp/codex_home/config.toml <<EOF model = "<policy_model_name>" # explicit name avoids model-family code-mode gating model_provider = "gym" approval_policy = "never" sandbox_mode = "danger-full-access" [model_providers.gym] name = "gym" base_url = "$URL/v1" env_key = "GYM_API_KEY" wire_api = "responses" EOF CODEX_HOME=/tmp/codex_home GYM_API_KEY=local \ codex exec --json --ephemeral --skip-git-repo-check "Compute 17*23 with a shell command." < /dev/null ``` ## Limitations - Eval only — token IDs / logprobs not wired up (same as the Claude Code agent). - Token counts come from Codex's own `turn.completed` usage reporting; `turns_used` counts assistant messages. - Code mode (JS tool orchestration) is fundamentally incompatible with chat-served backends; the seam degrades it gracefully (function tools preserved, JS `exec` dropped with a warning), but the supported path is classic function tools via explicit model naming. - `reasoning_gym_codex_agent*` configs are `verified: false` pending reward-profile baselining. Closes #1389. --------- Signed-off-by: Felipe Vieira Frujeri <[email protected]>
OlegSudakov
pushed a commit
to OlegSudakov/Gym
that referenced
this pull request
Aug 7, 2026
…-NeMo#2095) ## Summary Integrates the OpenAI Codex CLI (`codex exec`) as a built-in NeMo Gym agent harness, mirroring the Claude Code agent's architecture (NVIDIA-NeMo#1336, NVIDIA-NeMo#1603). Any Gym environment can now evaluate models inside the Codex harness — against OpenAI directly, or against any backend Gym serves via a model server. Implements NVIDIA-NeMo#1389 (part of NVIDIA-NeMo#1042). The central constraint: Codex removed `wire_api = "chat"` (openai/codex#7782) and only speaks the **Responses API over SSE**. Where Claude Code needed a Messages ↔ Responses mapping (`/v1/messages`), Codex needs Gym's *native* format plus a streaming envelope and tolerance for its wire dialect. So this PR has two parts: **Core seam — every Gym model server speaks the streaming Responses dialect** (`nemo_gym/responses_streaming.py`, dispatch route on `SimpleResponsesAPIModel`): - Non-streaming `/v1/responses` requests are unchanged (strict validation, same 422 shape). - `stream: true` requests are sanitized onto the strict params model and the complete response is re-emitted as synthesized SSE (`response.created` → `response.output_item.done` per item → `response.completed` — the minimal sequence streaming clients require, verified against codex-cli 0.144.4). - The sanitizer degrades gracefully instead of 422-ing the rollout: drops unknown bookkeeping fields (`client_metadata`, `prompt_cache_key`), flattens `namespace` tool specs to `<ns>__<tool>` functions (and splits the names back into `namespace` + `name` on the way out — the wire shape Codex's tool router requires), hoists function tools out of code-mode `additional_tools` carriers, hoists leading developer messages into `instructions` (strict chat backends admit exactly one system message at position 0), and prunes SDK-unknown nested fields via generic `extra_forbidden` retry (e.g. `reasoning.context`). - Converter fixes in `responses_converter.py`: `instructions` was silently dropped in Responses → ChatCompletions conversion — now mapped to a leading system message (also fixes the latent loss of Claude Code's system prompt on the vLLM path); when `instructions` is present, the leading system/developer run is folded into that single system message. **Agent — `responses_api_agents/codex_agent/`:** - Runs `codex exec --json --ephemeral --skip-git-repo-check` per request with a fresh generated `CODEX_HOME` (config.toml) and scratch `--cd` workdir, both removed afterwards. - Gym-owned model provider with `env_key` auth — no `codex login`/auth.json needed. `model_server` ref (with `/ng-rollout/<id>` capture correlation) or direct `openai_base_url`. - Isolation defaults: `approval_policy=never`, analytics/history/update-checks off, `web_search` disabled, `features.multi_agent/code_mode` off. `sandbox_mode` configurable (default `danger-full-access`, mirroring the Claude agent's skip-permissions default — Gym envs provide their own isolation). - Model-name pinning: for models Codex recognizes, model-family gating enables code mode, which moves tools into carriers chat-served models cannot drive; `model: null` + `model_server` writes a `gym-policy-model` placeholder to keep classic function tools (Gym servers substitute their configured model anyway). - Gym MCP tools: `/seed_session` metadata becomes a per-rollout streamable-HTTP `mcp_servers` entry with the session token on `http_headers`. - Skills staged into `CODEX_HOME/skills/` from the run-level `skills_ref` (native discovery, no `--bare` analog needed). - Timeout is the runaway bound (no `--max-turns` equivalent): kill on timeout → empty response → verify still runs (reward 0). Codex runs in its own process group and timeout kills the whole group — the npm shim's vendored-binary child otherwise survives and holds the stdout pipe open past the kill. - JSONL events map to a uniform trajectory shape (`agent_message`/`reasoning` → messages with `<think>` prefixes; `command_execution`/`mcp_tool_call`/`file_change`/`web_search`/`todo_list` → `function_call` + `function_call_output` pairs; `turn.completed` → usage incl. cached/reasoning details). A run ending on buffered reasoning is surfaced as a think-tagged message (vLLM reasoning parsers sometimes route the final answer there). - `extra_config` deep-merge knob for arbitrary `config.toml` content; per-rollout Gym MCP entries win name collisions. Also: composed showcase configs `reasoning_gym_codex_agent[_model_server].yaml`, README(s), agent-skills docs updated with the Codex staging location. ## Test plan Unit tests pass (full suite `1270 passed, 31 skipped`; ruff + pre-commit clean). New coverage: ~45 agent tests (command/config/TOML generation, `CODEX_HOME` staging + cleanup, timeout/process-group kill, MCP config, rollout correlation, skills forwarding, event parsing) and ~28 core tests (sanitizer, SSE synthesis, dispatch route incl. non-streaming strict-validation regression, converter `instructions` mapping). Unit tests mock `asyncio.create_subprocess_exec`; the real CLI and full stack were smoke-tested against codex-cli 0.144.4 with a vLLM-dialect model server (`inference-api` Qwen3.6-35B backend): - [x] **Streaming dialect via curl**: `stream: true` + codex bookkeeping fields against a live `vllm_model` server returns `response.created` / `output_item.done` / `response.completed` SSE. - [x] **Real CLI shell round trip**: `codex exec` against the Gym model server — model called `exec_command`, Codex executed `` /bin/bash -lc 'echo $((17*23))' `` → `391`, multi-turn replay (reasoning + function_call + output) validated, `turn.completed` usage reported. - [x] **MCP round trip**: header-gated streamable-HTTP FastMCP server (the Gym resources-server stack) — namespaced `function_call` routed to the MCP tool with the per-rollout session token, result returned to the model. - [x] **Full eval loop**: `gym env start --resources-server reasoning_gym/reasoning_gym_codex_agent_model_server --model-type vllm_model` + `gym eval run --no-serve ... --limit 2` → 2/2 rollouts with rewards, `turns_used`, token usage, and aggregate metrics. - [x] **Timeout degradation**: one live rollout exceeded the 600 s budget and landed as an empty, reward-0 rollout (and exposed the orphaned-child kill bug this PR fixes with process-group kill). ### Smoke test details (reproducible) `env.yaml` (any OpenAI-compatible chat endpoint): ```yaml policy_base_url: https://<host>/v1 policy_api_key: <key> policy_model_name: <model> ``` ```bash gym env start \ --resources-server reasoning_gym/reasoning_gym_codex_agent_model_server \ --model-type vllm_model gym eval run --no-serve \ --agent reasoning_gym_codex_agent_model_server \ --input resources_servers/reasoning_gym/data/example.jsonl \ --output codex_rollout.jsonl --limit 1 ``` Standalone CLI seam check (no resources server) — take the model server URL from the `gym env start` log: ```bash mkdir -p /tmp/codex_home && cat > /tmp/codex_home/config.toml <<EOF model = "<policy_model_name>" # explicit name avoids model-family code-mode gating model_provider = "gym" approval_policy = "never" sandbox_mode = "danger-full-access" [model_providers.gym] name = "gym" base_url = "$URL/v1" env_key = "GYM_API_KEY" wire_api = "responses" EOF CODEX_HOME=/tmp/codex_home GYM_API_KEY=local \ codex exec --json --ephemeral --skip-git-repo-check "Compute 17*23 with a shell command." < /dev/null ``` ## Limitations - Eval only — token IDs / logprobs not wired up (same as the Claude Code agent). - Token counts come from Codex's own `turn.completed` usage reporting; `turns_used` counts assistant messages. - Code mode (JS tool orchestration) is fundamentally incompatible with chat-served backends; the seam degrades it gracefully (function tools preserved, JS `exec` dropped with a warning), but the supported path is classic function tools via explicit model naming. - `reasoning_gym_codex_agent*` configs are `verified: false` pending reward-profile baselining. Closes NVIDIA-NeMo#1389. --------- Signed-off-by: Felipe Vieira Frujeri <[email protected]>
This branch was previously deployed
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.
Summary
Replaces the hardcoded
--bareflag in the Claude Code agent with config knobs, so skills / MCP servers / custom settings can be enabled via config instead of editingapp.py. Defaults preserve today's isolated, reproducible behavior.bare(defaulttrue),mcp_config, andsettingstoClaudeCodeAgentConfig._build_command,_build_settings, and_setup_config_dirhelpers from_run_claude_code.--bareis only passed whenbareistrue;--mcp-configis explicit and applies regardless. The per-runCLAUDE_CONFIG_DIRis the staging seam reused by skills evaluation (feat: agent skill evaluation infrastructure #1256)._run_claude_codewiring/timeout (subprocess mocked); README + config template document the knobs and the reproducibility trade-off.A note on API shape: Claude Code's
--bareis all-or-nothing for auto-discovery (skills/hooks/plugins/MCP/memory/CLAUDE.md), while--mcp-configand settings are explicit. So the minimal honest API is three knobs (bare,mcp_config,settings) rather than a flag per feature —bare: falseenables auto-discovery as a group.Implements #1602. Unblocks the agent-half of #1256.
Test plan
Unit tests pass (
27 passed, ruff clean). Unit coverage ofapp.pyraised 62% → 79%; all added/changed code is covered. The remaining gaps (responses/run/_resolve_base_url) are pre-existing methods covered byng_test's live-server run.Unit tests mock
asyncio.create_subprocess_exec, so the realclaudebinary is not exercised. Smoke test before marking ready (pending API key):bare: true):ng_runthe reasoning_gym claude_code_agent config,ng_collect_rolloutsone task; confirm a non-error row withreward, populatedresponse.output, andusage. Confirms the refactor works against the real CLI.mcp_config: set it to a minimal MCP server config; run a task needing the tool; confirm a tool call to the MCP tool in the output (and that it coexists with defaultbare: true).bare: false: confirm a task still completes with--baredropped. (Not run live — only omits a flag; covered by unit teststest_bare_false_omits_flag.)settings: set a settings JSON with a uniqueenvvar and have the model echo it via Bash; the value appears in the answer, proving the mergedsettings.jsonis read from the staged config dir.Smoke test details (reproducible)
Run against an endpoint serving the Anthropic Messages API.
env.yaml:1. Default (
bare: true) — confirms the refactor works against the real CLIResult: rollout completed end-to-end (2 turns, tokens reported, full verify pipeline ran). ✅
2.
mcp_configwith defaultbare: true— confirms--mcp-configis honored even with--bareMCP config (
/tmp/mcp.json) — the official reference "everything" server, which exposes anaddtool:Input task (
/tmp/cc_mcp_input.jsonl, one row) instructs the model to use the MCPaddtool (not Bash) and box the result;metadata.source_dataset=basic_arithmeticso the reasoning_gym verifier scores it:Run with
mcp_configset via a Hydra override (notebarestays at its defaulttrue):Result: the model invoked
mcp__everything__add,reward=1.0,extracted_answer=80235, 3 turns. The MCP server loaded and its tool was used with--barestill active, validating the design choice to treat explicit--mcp-configas independent of the auto-discovery (bare) knob. ✅3.
settings— confirms a user settings JSON is merged into the stagedCLAUDE_CONFIG_DIRand itsenvreaches toolsSettings file (
/tmp/cc_settings.json):Input task (
/tmp/cc_settings_input.jsonl, one row) tells the model toecho "$NG_SMOKE_TOKEN"via Bash and box the result;metadata.source_dataset=basic_arithmetickeeps the verifier happy:Run with
settingsset via a Hydra override:Result: the answer contained
ng-smoke-7f3a9, proving the mergedsettings.jsonwas read and itsenvreached the Bash tool environment. ✅