English | 简体中文
A harness optimization layer for long-running Codex agents.
Inspired by NVIDIA’s SoL-Pi, SoL-Codex is an independent Codex-native implementation that does not modify Codex or the underlying model and is not affiliated with NVIDIA or OpenAI.
It implements four mechanisms:
- Action Fusion — after an
apply_patch, optionally run one predictable validation without another model decision round-trip. - ObservationPack — archive large tool results locally under stable
obs://...handles with exact recall. - Evidence-Preserving Reducer — create deterministic diagnostic receipts only when every retained quote verifies against the archived source.
- Context Compact state preservation — checkpoint task-critical state before native Codex compaction and restore it on
SessionStart(source="compact").
Correctness > efficiency. Evidence > summary. Fallback > failure.
- Node.js 22+
- Codex Desktop / ChatGPT Desktop with Codex, or Codex CLI with current plugin/hooks support
- Codex CLI is recommended for automatic local MCP registration
macOS / Linux:
git clone https://github.com/raydez/sol-codex.git
cd sol-codex
./install.shWindows PowerShell:
git clone https://github.com/raydez/sol-codex.git
cd sol-codex
./install.ps1The installer:
- runs tests;
- copies the plugin to
~/.codex/plugins/sol-codex; - adds a personal marketplace entry to
~/.agents/plugins/marketplace.json; - uses the bundled zero-dependency MCP compatibility server immediately;
- optionally uses the official MCP TypeScript SDK v2 when those optional packages are installed;
- runs
codex mcp add sol_codex ...when the Codex CLI is available.
Then restart ChatGPT Desktop / Codex, install or enable SoL-Codex from your personal marketplace source, open /hooks and review/trust its hooks, and verify /mcp shows sol_codex.
Codex intentionally does not auto-trust third-party hooks. That review step cannot and should not be bypassed by this installer.
Once this repository is published, users can add it as a marketplace source:
codex plugin marketplace add OWNER/sol-codexThe repository includes .agents/plugins/marketplace.json. Local evidence MCP still needs a local process, so run the repository installer once or manually register the MCP server.
## Optional: install the official MCP TypeScript SDK v2
npm run install:modern-mcp
# Register the local STDIO MCP server
codex mcp add sol_codex --env SOL_CODEX_DATA_DIR="$HOME/.local/share/sol-codex" -- node "$PWD/src/mcp/server.mjs"On macOS, the default data directory used by SoL-Codex is ~/Library/Application Support/sol-codex; the installer passes the correct path automatically.
From a project you want to optimize:
node /path/to/sol-codex/src/cli/main.mjs initTo opt into Action Fusion at initialization:
node /path/to/sol-codex/src/cli/main.mjs init --action-fusionAction Fusion is off by default because it executes project validation commands. Observation archiving, deterministic receipt generation, and compact-state checkpointing are on by default and are non-destructive.
Review .sol-codex.json before enabling Action Fusion. Commands are executed with shell:false; arbitrary model-generated shell is never passed to Action Fusion.
Codex PostToolUse hooks can add context, but current hook APIs do not provide a safe general-purpose updated tool output replacement for arbitrary local tools. SoL-Codex therefore uses two modes:
- Passive archive (default): large native tool results are archived locally and a short exact-recall handle is added to context. Native Codex behavior remains unchanged.
- Packed execution via MCP: for configured verbose commands, Codex can call
run_packed. The command's full output stays local while the model receives a compact result plus anobs://...handle.
This is deliberate: SoL-Codex does not misuse PostToolUse decision:block or continue:false merely to fake output suppression.
obs_get(handle, max_chars?)obs_slice(handle, offset, limit)obs_search(handle, query, ...)evidence_get(handle)harness_status(cwd?)run_packed(cwd, name, ...)
run_packed will only execute a named command from project packedCommands, or—after Action Fusion is explicitly enabled—a conservative auto-detected validation command (typecheck, lint, test, or go test).
All archives remain local. Default locations:
- macOS:
~/Library/Application Support/sol-codex - Linux:
$XDG_DATA_HOME/sol-codexor~/.local/share/sol-codex - Windows:
%LOCALAPPDATA%\\sol-codex
Per session:
sessions/<session-id>/
├── state.json
├── metrics.jsonl
├── observations/
├── evidence/
└── compact/latest.json
Project config: .sol-codex.json
User config: $XDG_CONFIG_HOME/sol-codex/config.json or ~/.config/sol-codex/config.json
See config/sol-codex.example.json.
SoL-Codex is not a sandbox and is not a security boundary.
- No remote reducer exists in v0.2.1.
- Archives are local.
- Action Fusion is opt-in.
- Destructive command basenames are rejected by the fused runner.
- Commands are executed as argv arrays with
shell:false. - Evidence receipts are SHA-256 bound to their source and every quote span is exact-verified.
- Hook errors fail open to native Codex behavior.
See SECURITY.md.
npm test
npm run doctorIn Codex:
/hooks
/mcp
v0.2.1 is the Validation Edition. It does not claim a real-world token saving until users run a controlled Codex experiment and the statistical validation gate passes.
Create a manifest:
sol-codex benchmark initEdit two required frozen fields:
{
"environment": {
"model": "YOUR_EXACT_CODEX_MODEL",
"reasoningEffort": "medium"
}
}Every task must also use an exact 40-character Git commit SHA and should provide a deterministic verify command.
Check the manifest before spending model usage:
sol-codex benchmark validate-manifest \
--manifest sol-codex-benchmark.jsonRun the primary Native-vs-All experiment:
sol-codex benchmark run \
--manifest sol-codex-benchmark.json \
--variants native,all \
--repeats 3 \
--validation-gradeThen run the statistical decision gate:
sol-codex benchmark validate \
--variant all \
--min-tasks 30 \
--min-paired-success-tasks 20The report uses Codex-reported turn.completed.usage token counts. It adds task-cluster bootstrap 95% confidence intervals, a paired token-saving sign test, and exact McNemar diagnostics for binary quality outcomes.
A saving claim is marked SUPPORTED only when all of these hold:
- the minimum task/sample gate passes;
- the 95% CI for success-rate delta stays above the configured non-inferiority margin;
- the 95% CI for test-pass delta stays above the same margin;
- the 95% CI for paired token saving is above zero.
Otherwise the result is INCONCLUSIVE or QUALITY-REGRESSION. A lower raw token number alone is not enough.
The repository includes a fixed 30-instance subset of SWE-bench Verified, a human-validated benchmark of real GitHub issue/PR tasks.
List it:
sol-codex benchmark suite \
--action list \
--name swebench-verified-30Fetch the official rows from the Hugging Face SWE-bench dataset server:
sol-codex benchmark suite \
--action fetch \
--name swebench-verified-30 \
--output swebench-verified-30.jsonlThis command intentionally fetches official task metadata only. For an end-to-end validation run, prepare a frozen SoL-Codex manifest from those rows:
sol-codex benchmark suite \
--action prepare \
--rows swebench-verified-30.jsonl \
--repos-dir .swebench-repos \
--manifest-output swebench-sol-codex.json \
--model YOUR_EXACT_CODEX_MODEL \
--reasoning-effort mediumThen run Native and All with external quality verification pending:
sol-codex benchmark run \
--manifest swebench-sol-codex.json \
--variants native,all \
--repeats 3 \
--validation-gradeFor every repetition, export the exact Git patch produced by Codex:
sol-codex benchmark export-swebench \
--variant native --repeat 1 \
--output native-r1.json
sol-codex benchmark export-swebench \
--variant all --repeat 1 \
--output all-r1.jsonGrade each prediction file with the official SWE-bench evaluator, for example:
swebench eval verified -p native-r1.json --run-id sol-codex-native-r1 -j 8
swebench eval verified -p all-r1.json --run-id sol-codex-all-r1 -j 8Import the official results.json back into the corresponding SoL-Codex run cells:
sol-codex benchmark import-swebench \
--results logs/evaluation/sol-codex-native-r1/results.json \
--variant native --repeat 1
sol-codex benchmark import-swebench \
--results logs/evaluation/sol-codex-all-r1/results.json \
--variant all --repeat 1Repeat export/evaluate/import for repetitions 2 and 3, then run:
sol-codex benchmark validate --variant allSoL-Codex never uses the SWE-bench gold patch in the Codex task prompt. Correct environment construction and grading remain the responsibility of the official SWE-bench evaluator. Before publishing a result, also sanity-check the selected instances with swebench eval verified --gold because evaluator/image failures must not be mislabeled as agent failures.
After the primary Native-vs-All experiment, investigate mechanism contribution:
sol-codex benchmark run \
--manifest sol-codex-benchmark.json \
--variants native,plugin-off,observation,action,reducer,compact,all \
--repeats 3 \
--validation-gradeDo not add mechanism percentages together; effects overlap.
Desktop experiments still use the local OTLP/HTTP JSON collector:
sol-codex benchmark collect
sol-codex benchmark otel-configMark each fresh task session:
sol-codex benchmark begin --task bug-001 --variant native
# perform one fresh Desktop Codex task
sol-codex benchmark end --success true --test-pass true
sol-codex benchmark ingest --otel .sol-codex-benchmark/otel.jsonlRepeat with all, then:
sol-codex benchmark report
sol-codex benchmark validate --variant allREAL_WORLD_RESULTS.md starts empty by design. Add a result only when the exact Codex version, model, reasoning effort, task set, repository revisions, repeats, quality criteria, and validation report are preserved. Synthetic unit tests validate the benchmark machinery; they are not evidence that SoL-Codex saves tokens in real Codex runs.
See docs/benchmark.md and docs/validation-protocol.md.
This release intentionally does not claim that passive ObservationPack halves Codex token usage. Native PostToolUse currently cannot safely replace arbitrary native tool results using updatedMCPToolOutput / suppressOutput; those fields are parsed but not fully supported. Real active packing is therefore exposed through the local MCP run_packed path, while native tool outputs are archived passively.
Experimental v0.2.1 Validation Edition. The repository is designed as the first runtime adapter on a longer path toward model-independent Harness Evolution.
Inspired by NVIDIA's SoL-Pi paper and public implementation. SoL-Codex is an independent clean implementation for Codex and is not affiliated with NVIDIA or OpenAI.
MIT