Repository navigation
llm: openai-cli backend — semantic extraction through the locally authenticated Codex CLI - #5
Merged
Merged
Conversation
…ly authenticated Codex CLI
Sibling of the existing claude-cli backend, for operators whose OpenAI access is a ChatGPT
subscription (Codex CLI OAuth), not an API key. Ported from a field-proven implementation
(measured ~308 docs/hour at concurrency 6 on an 8 GB box): codex exec --skip-git-repo-check
--json --sandbox read-only, prompt via stdin (argv would hit Linux MAX_ARG_STRLEN), result
via -o file, empty-graph refusal to avoid hollow-bisect storms. Two per-call config pins:
mcp_servers={} (each exec otherwise spawns the user's configured MCP servers per call —
measured ~160-300 MB each, more than the extraction itself) and model_reasoning_effort
(GRAPHIFY_OPENAI_CLI_EFFORT, default ultra). Model via GRAPHIFY_OPENAI_CLI_MODEL (default
gpt-5.6-sol). Tests: argv contract, env overrides, missing-binary error.
…the credential (OAuth), mirroring claude-cli
…ket mcp_servers={} does not work
Codex merges config overrides into the table rather than replacing it, so `-c mcp_servers={}` leaves
every server enabled — verified with Codex's own reader: `codex mcp list -c mcp_servers={}` still
shows 'enabled', while `-c mcp_servers.<name>.enabled=false` shows 'disabled' (`enabled` is a real
field in `codex mcp get`). Measured cost of the ineffective pin during a live extraction: four MCP
servers spawned by one `codex exec`, ~152 MB each.
Now the backend asks Codex for its own server list (`codex mcp list --json`) and adds one
`-c mcp_servers.<name>.enabled=false` per server — no hardcoded names, best-effort (older Codex or no
config: extraction proceeds unchanged). Tests cover both servers disabled, the empty-config case, and
that the blanket form is gone.
# Conflicts: # graphify/cli.py
…etail, and turn-usage accounting; changelog The argv-contract tests said what we send; these say what we accept back: the -o JSON becomes the result dict with usage from the last turn.completed JSONL event (cached input not double-counted), a non-zero exit or a missing/ empty -o file raises with stderr AND the JSONL stdout tail preserved (HTTP errors surface only there), and an empty-but-valid graph raises instead of feeding the hollow-response bisect. Co-Authored-By: Claude Fable 5 <[email protected]>
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.
What
A new
openai-clibackend (--backend openai-cli) that runs semantic extraction and community labeling through the locally authenticated OpenAI Codex CLI (codex exec) — i.e. on a ChatGPT OAuth subscription, not a meteredOPENAI_API_KEY.gpt-5.6-sol(GRAPHIFY_OPENAI_CLI_MODELoverrides); reasoning effort defaultultra(GRAPHIFY_OPENAI_CLI_EFFORT).--sandbox read-only: an agentic Codex must not be able to write to the corpus it reads.enabledoverride; a blanket-c mcp_servers={}deep-merges away and leaves the servers running (measured: four ~152 MB graph servers started percodex exec).turn.completedJSONL event; cached input is not re-added (Codexinput_tokensalready includes it).GRAPHIFY_OPENAI_CLI_PARALLEL=1, mirroring ollama/claude-cli.codexCLI as the credential (OAuth), mirroringclaude-cli.Why
This ports a local patch that has been carrying production extraction on the TELB-COCKPIT box since 2026-08-19. The original patch comment states the stake plainly:
With it merged, a reinstall from this repo no longer erases the free extraction route.
Tests
tests/test_openai_cli_backend.py— 15 offline tests (subprocess and shutil.which mocked): argv contract, MCP-disable per server, env overrides, missing binary, happy parse with usage accounting, non-zero exit / missing -o / empty -o raises carrying stderr and the JSONL stdout tail, empty-graph raise, and_openai_cli_turn_usageedge cases.🤖 Generated with Claude Code