Skip to content

Count Codex MCP tool refusals in results and reports - #67

Draft
kpprasa wants to merge 5 commits into
kpprasa/forge-mcp-readinessfrom
kpprasa/codex-plugin-mcp-tools
Draft

kpprasa wants to merge 5 commits into
kpprasa/forge-mcp-readinessfrom
kpprasa/codex-plugin-mcp-tools

Conversation

@kpprasa

@kpprasa kpprasa commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Context

Stacks on #41.

Observed problem

Forge users on main get no typed warning when Codex refuses an MCP call, a call to a remote tool. A scan of 33 saved sessions found seven such refusals, yet saved results had no warning for the fault. The November runs recorded refusal counts on the eval-runner branch; main lacks that signal when users read scores.

Impact

Measured: seven refused calls in 33 saved sessions. Inferred: a plugin arm can appear to run normally while its tools are refused. That can affect how users read the scores; the score impact has not been measured. A passed install or server check does not prove that a later model turn can use a tool.

Changes

Changes

Count exact MCP refusals in the root native session before Forge builds its main evidence. Count each call ID once. Keep a valid count when other native data forces driver fallback. Missing or bad source yields a typed unavailable state with a fixed reason.

A count above zero or an unavailable state adds a typed, content-free warning to result.json and its report row. Resume and regrade keep the warning. It stores no tool names, native error text, prompts, or keys, and does not change scores or judge inputs. Zero adds no warning. Absence can also mean an old run or an agent that did not record counts; it proves no tool health. A run with no agent turn has no such warning.

Keep the probe in validate --host, on a disposable runtime. The Codex probe rejects empty tool maps. It gives fixed error text when servers are missing, auth fails, or no tools are found. Its script and caller share named exit codes. Drop the eval-time gate from the earlier commit: measured evals run no separate probe, including Claude Code evals. The host probe makes no model or MCP tool call.

These changes add a type and optional fields. The package root exports a new count/state type. Adapters can return it on either form of the native evidence result. Saved results and report rows gain optional warning fields:

AgentMcpToolRefusals:
  {state: 'available', count: safe nonnegative integer}
  | {state: 'unavailable', reason:
      'source_unavailable' | 'source_invalid' | 'source_incomplete'}
AgentNativeEvidenceResult.mcpToolRefusals?: AgentMcpToolRefusals (both variants)
RunWarningV1.mcp_tool_refusals?: AgentMcpToolRefusals
ExperimentRunArtifact.warnings?: ExperimentRunReportRunV1['warnings']
ExperimentRunReportRunV1.warnings?: MCP refusal warning[] (at most one)

New readers still read old runs that lack these fields. Older strict readers may reject new fields. No entry point, CLI flag, config shape, install receipt, or plan digest changes. Codex host checks give more precise error text.

The scope is warnings for new runs and retained warnings in saved runs. A separate local scan measured old logs. This PR keeps refusals as warnings and leaves scoring intact. The separate auth and parser fixes are now on main; this warning is still useful when a call is refused. No warning still means no proof of working tools.

Why this is the right fix

The alternative is an eval-time gate. A separate server check cannot prove model access and may change the measured home, so this PR leaves probes in host validation. A future gate needs proof through a model tool call and its own policy decision.

Read the fault where it occurs, in the exact session log. The agent owns native parsing, the engine owns result writes, and reports read checked data. Bad optional data becomes unavailable rather than failing a scored run. One shared schema checks counts in results and reports. Counts stay in run data. The count relies on the client's exact refusal text; reworded errors are not counted.

Validation

How to test it

The results below predate the latest rebase onto kpprasa/forge-mcp-readiness; they have not been rerun or verified on this head.

Earlier live tests found a delayed call failed twice with the plugin server and passed twice when that server moved to global config. Codex's plugin auth check opened a second link without the bearer token, then hid the tools while the first link stayed up. Those tests also found that Forge failed a turn on a valid MCP tool result. The wiring and parser fixes were separate work and are now on main via #87 and #72; this PR records refusals.

pnpm test src/agents/codex/evidence.test.ts src/agents/codex/mcpProbe.test.ts src/agents/codex/plugins.test.ts src/execution/readiness.test.ts src/execution/execute.test.ts src/experimentReport.test.ts src/regrade/experiment.test.ts src/mcpToolRefusals.test.ts
pnpm lint
pnpm typecheck
pnpm test
pnpm build
pnpm check:cases:built
pnpm check:docs:built
pnpm check:package

The focused checks had 175 passes before the rebase. Tests fail for six edits that break the fix: add an eval gate, zero counts, drop fallback or report warnings, mismatch exit codes, or drop the saved result field. The local scan retains all seven refusals despite native fallback.

Lint, typecheck, build, case checks, and docs checks passed. The default full suite had 1,150 passes, two known macOS failures, and two load timeouts. Both timed-out files passed alone (10 and 26 tests). Package lint and type checks passed; smoke stopped because the offline store lacked toml@5.0.0.

Live checks were not run because Docker and live model access were unavailable. After folding on a suitable host, run validate --host and, if model calls are authorized, a one-case Codex plugin eval that calls MCP after a delay. Check that successful calls add no refusal warning. The earlier live workaround proves the approach, not that this branch fixes the wiring.

Rollout/revert plan

New Codex runs record the warning when counts exceed zero or the source cannot be checked. Old saved runs are not scanned by resume or regrade; those paths keep warnings already recorded. A local scan measures old logs. Revert stops new warning writes but leaves saved fields in place; older strict readers may reject them. Resume on the same Forge build.

cc @codeowners-ai-quality

kpprasa added a commit that referenced this pull request Oct 29, 2026
@kpprasa
kpprasa force-pushed the kpprasa/codex-plugin-mcp-tools branch from d5a9526 to 24d2fae Compare October 30, 2026 00:14
@kpprasa
kpprasa changed the base branch from kpprasa/eval-runner to kpprasa/forge-mcp-readiness October 30, 2026 00:14
@kpprasa
kpprasa force-pushed the kpprasa/codex-plugin-mcp-tools branch from 24d2fae to 4a78445 Compare October 31, 2026 19:46
@kpprasa
kpprasa force-pushed the kpprasa/forge-mcp-readiness branch from aee8f56 to 4317a70 Compare October 31, 2026 19:46
kpprasa and others added 5 commits November 9, 2026 15:46
Committed-By-Agent: codex
Orbit-Session-Id: 3cfa2f86-50b0-4ba6-8a69-0df88e434197
Co-authored-by: codex <noreply@openai.com>
Committed-By-Agent: claude
A finished run cannot be graded again today: the CLI only validates, plans,
and runs, and resume treats judge results as committed. Yet each completed run
already stores everything its judge saw. trajectory.json projects to the judge
transcript (verification proves it equals judge-evidence.json), and
judge-evidence.json holds the rendered workspace excerpts.

regradeCompletedRun verifies a run, rebuilds that exact judge input, judges it
with any registered completion provider and model, and rescores with the run's
original check results (the workspace is gone, so checks are not re-run).
regradeExperimentRun does this for every completed run of a saved experiment
run with bounded concurrency, writing runs/<run-id>.json, a standard
report.json, and regrade.json to a separate directory that must lie outside the
source. Reruns reuse regrades for the same judge and committed result; an
output holding another judge's regrades reports those runs as failed instead
of mixing judges. `forge regrade` exposes it on the CLI, and
@stripe/forge/regrade on the package.

Supporting changes: completionBindingFor builds one judge binding from a
provider collection, and renderJudgeWorkspaceEvidence accepts the fields it
renders, so saved evidence reproduces the judge's workspace text exactly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Committed-By-Agent: claude
Orbit-Session-Id: 70fc1af8-ad08-4dc7-84fa-62c98c9ca515
Committed-By-Agent: claude
Orbit-Session-Id: 70fc1af8-ad08-4dc7-84fa-62c98c9ca515
Committed-By-Agent: claude
`forge validate --host` now prepares temporary runtimes, applies setup, and
checks the selected agents' plugin MCP connections through each native client
(Claude `mcp list`, Codex app-server `mcpServerStatus/list`) without model
calls or MCP tool invocations. It replaces the image build/inspect probe and
reports model authentication as untested. Credentials follow the explicit
grant model: `--credential-env` is accepted with `--host`, and readiness
resolves only setup and agent-scope setup credentials.

Also adds the Claude gateway compatibility coordinate
`disable_experimental_betas`, resolved from
CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS, and a portable plugin experiment in
the release directory.

Reworked onto main without Docker host networking or proxy settings: the
readiness check reads the registered plugin's MCP servers (`plugin: stripe`)
instead of a receipt field, and `ForgeEngine.validateRuntime` is the only new
engine surface.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Committed-By-Agent: claude
A successful plugin install does not prove its MCP tools are available.
Run the existing optional native check after setup finalization, before
opening an agent session, and share receipt checks with host validation.

Require Codex to discover a nonempty tool map with bearer authentication.
Report fixed reasons for missing servers, unavailable auth, empty tools,
and native discovery failures without exposing native output. Preserve
the current plugin wiring while its root cause awaits live verification.

Add regression coverage for setup failure, cleanup, auth status, empty
tools, identity checks, and safe error messages. Document the readiness
boundary and the optional callback's execution lifecycle.

Committed-By-Agent: codex
A separate server-status probe cannot establish which tools reach an exec
model turn, and probing the measured home can change the run. Keep native
discovery in disposable host validation instead of gating eval setup.

Count exact native dispatch refusals before normalization so fallback does
not hide them. Carry safe typed warnings through committed results, resume,
and regraded reports. Degrade missing or malformed observations without
changing scoring, and share the host probe exit-code contract.

Add regressions for fallback, unavailable data, report reuse, and eval
isolation. Verify the regressions with source mutations.

Committed-By-Agent: codex
@kpprasa
kpprasa force-pushed the kpprasa/codex-plugin-mcp-tools branch from 4a78445 to 91c3a47 Compare November 10, 2026 05:21
@kpprasa
kpprasa force-pushed the kpprasa/forge-mcp-readiness branch from 4317a70 to 6c06639 Compare November 10, 2026 05:21
@kpprasa
kpprasa force-pushed the kpprasa/forge-mcp-readiness branch from 6c06639 to 69336ec Compare November 17, 2026 02:12
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.

1 participant