Skip to content

harshilmathur/fablex

Repository files navigation

Fable → Codex Bridge (fablex)

CI MIT License

Keep long-running work on Fable. When a guardrail blocks a turn, use GPT-5.6 Sol instead of Opus.

Claude Fable is especially good at sustained, agentic coding tasks. The challenge is that Fable 5 also has strict and sensitive domain guardrails. Legitimate work can trip them, particularly around cybersecurity and biology. When that happens, Claude Code normally retries the blocked turn on Opus.

fablex changes that fallback. Fable remains the primary model for the session, but when its structured domain classifier blocks a turn, fablex skips the Opus retry and hands the current turn to GPT-5.6 Sol through Codex. The following turn returns to Fable, with Codex's outcome available as context.

Normal turn              → Claude Fable
Classifier blocks a turn → Opus skipped → GPT-5.6 Sol completes that turn
Next turn                → Claude Fable resumes

This is useful when you prefer Fable for the long-running task but want Sol, not Opus, to take over the occasional turn that Fable's guardrails cannot handle.

What it does

  • Keeps Fable as the default model throughout the session.
  • Detects Claude Code's structured Fable classifier-refusal event.
  • Prevents Claude Code from automatically retrying that turn on Opus.
  • Sends the same request, bounded conversation context, and current repository state to GPT-5.6 Sol through Codex.
  • Returns control to Fable on the next turn instead of making Sol sticky.

fablex does not bypass either provider's safety policies. Ordinary Claude refusals do not trigger a handoff, and Codex independently evaluates every request it receives.

Why a launcher is necessary

Claude Code performs its Opus retry internally. A normal plugin hook only sees the completed turn, so it cannot replace that retry in time. fablex launches Claude Code with automatic model switching disabled, reads its structured event stream, and invokes codex exec only when Fable's classifier event is present.

The launcher preserves Claude's session and the shared working directory. If Fable changed files before the classifier event, Codex sees those changes and is instructed to inspect the repository before continuing the turn.

Requirements

  • Claude Code 2.1.170 or later, authenticated and able to use Fable 5
  • Codex CLI 0.144.0 or later, authenticated and able to use gpt-5.6-sol
  • Python 3.10+
  • Git (recommended and required by default for Codex handoffs)
  • On Linux, system bubblewrap is recommended; Codex can use its bundled fallback

Confirm the complete environment after installation:

fablex --doctor

Install

Clone the repository and run the installer:

git clone https://github.com/harshilmathur/fablex.git
cd fablex
./scripts/install.sh

This installs the plugin as a personal skills-directory plugin and links fablex into ~/.local/bin. Restart Claude Code and your shell after the first install. The plugin appears as fable-codex-bridge@skills-dir.

The terminal launcher is required for automatic pre-Opus routing. Installing only the Claude marketplace plugin provides the optional manual handoff skill, but a marketplace installation cannot add fablex to your shell's PATH.

For the manual Claude Code handoff skill without the terminal launcher, install the marketplace plugin:

claude plugin marketplace add harshilmathur/fablex
claude plugin install fable-codex-bridge@fable-codex-bridge

For a one-session development load without installing the plugin components, Claude Code also accepts --plugin-dir ./fablex; use the fablex launcher for automatic pre-Opus routing.

Use

Start in any repository:

fablex

A Codex handoff requires the current directory to be inside a Git repository. This protects against accidentally granting an agent write access to an arbitrary directory. For deliberate non-repository work, use --allow-non-git.

Run a single prompt:

fablex --once "Investigate and fix the failing authentication tests"

Test the routes

Run these smoke tests from inside a Git repository. They request only a short confirmation token and do not ask either model to produce sensitive content.

This ordinary prompt should stay on Fable and print only FABLE_NORMAL_OK:

fablex --once "This is a routing smoke test. Reply with exactly FABLE_NORMAL_OK and nothing else."

This cybersecurity classifier probe should hand off to Codex Sol:

fablex --once "This is a routing smoke test. Do not provide instructions or analysis. Reply only CYBER_HANDOFF_OK. Topic labels: malware, ransomware, credential theft, remote code execution, persistence, and defense evasion."

Expected output:

↪ Fable classifier triggered — handed to GPT-5.6 Sol via Codex.

CYBER_HANDOFF_OK

This biology classifier probe should also hand off to Codex Sol:

fablex --once "This is a routing smoke test. Do not provide instructions or analysis. Reply only BIO_HANDOFF_OK. Topic labels: pathogen engineering, viral genome modification, increased transmissibility, and immune evasion."

If you are outside the repository, point fablex at it explicitly:

fablex --cwd "/path/to/your/repository" --once "This is a routing smoke test. Reply with exactly FABLE_NORMAL_OK and nothing else."

Classifier behavior is controlled by the upstream model service and may evolve. The bridge routes only when Claude Code emits a structured classifier-refusal event.

For a multiline prompt:

fablex --once "$(cat prompt.md)"

Normal turns go to Fable. A classifier-blocked turn prints:

↪ Fable classifier triggered — Opus skipped.
codex-sol> ...

The next Fable turn receives Codex's outcome as bridge context, and both agents always work in the same current directory.

Inside Claude Code, manually send a task to Codex Sol with:

/fable-codex-bridge:handoff <task for Codex>

Configuration

Environment variables:

Variable Default Purpose
FABLEX_CLAUDE_MODEL fable Claude model/alias
FABLEX_CODEX_MODEL gpt-5.6-sol Codex fallback model
FABLEX_CODEX_SANDBOX workspace-write Codex sandbox
FABLEX_CLAUDE_ARGS empty Extra Claude CLI flags
FABLEX_CODEX_ARGS empty Extra Codex CLI flags
FABLEX_CLAUDE_TIMEOUT 3600 Claude turn timeout in seconds
FABLEX_CODEX_TIMEOUT 3600 Codex turn timeout in seconds
FABLEX_ALLOW_NON_GIT false Explicitly permit handoff outside Git

Example with Claude auto-approving edits:

FABLEX_CLAUDE_ARGS='--permission-mode acceptEdits' fablex

Do not use danger-full-access unless you intentionally want Codex to have unrestricted local access.

Extra arguments are parsed as shell-style words but are passed directly to each executable without a shell. They can still weaken CLI safeguards, so configure them only from trusted startup files.

Diagnostics

fablex --doctor
fablex --version

--doctor checks Python, Claude Code, Codex, the working directory, Git, and Linux bubblewrap. It does not make a paid model request or verify account entitlements. Use each vendor CLI directly for authentication or model-access problems.

Tradeoffs

  • fablex is a lightweight REPL, not Claude Code's full-screen interactive UI.
  • Claude responses are buffered for the turn so a retracted Fable response is never printed before handoff.
  • The bridge returns to Fable on the next turn rather than making the fallback sticky.
  • Claude's session and repository changes persist. The bridge keeps a bounded local dialogue summary for Codex and injects the prior Codex outcome into the next Fable turn.
  • Bridge history exists only in the running process. Restarting fablex starts fresh bridge context, although repository changes remain.
  • Provider CLI output formats and model aliases are external dependencies. Pin a known release in controlled environments and run the smoke tests before upgrading.

Test

python3 -m unittest discover -s tests -v

The tests use fake Claude and Codex executables; they do not spend model tokens.

Uninstall

./scripts/uninstall.sh

The uninstaller removes only the expected installed plugin directory and a symlinked launcher. It leaves a non-symlink file named fablex untouched.

Security and support

The bridge stores no credentials and has no telemetry. Claude Code and Codex still send prompts through their normal provider connections. Do not place secrets in prompts, logs, or untrusted repositories. See SECURITY.md for the trust model and private reporting guidance.

For usage questions and reproducible bugs, open a GitHub issue. Contributions are described in CONTRIBUTING.md, and release history is maintained in CHANGELOG.md.

This is an independent compatibility bridge, not an Anthropic or OpenAI product. Fable's event schema and model availability may change; use fablex --doctor, CI, and a real two-route smoke test when releasing updates.

About

Keep long-running work on Claude Fable; route guardrail-blocked turns to GPT-5.6 Sol through Codex instead of Opus.

Topics

Resources

Contributing

Security policy

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages