Repository navigation
feat(llm): subscription CLI providers (claude-code:*, codex:*) + sampling doc correction - #592
Merged
Merged
Conversation
Route completions through a signed-in Claude Code (`claude -p`) or Codex (`codex exec`) CLI so runs draw on the user's subscription instead of an API key. This replaces MCP sampling as the "use the host's model access" path: sampling was deprecated in MCP 2026-07-28 (SEP-2577) and Claude Code never implemented it. - New providers in llm/providers/subscription_cli.py, registered ahead of Anthropic (claude-code: would otherwise match claude-). Explicit prefix only; never a credential fallback. - Each call is an isolated, tool-less completion: agent system prompt replaced, tools/MCP/user settings/session persistence disabled, empty scratch cwd. Forced single-tool structured output maps to --json-schema / --output-schema (strict-mode rewrite for Codex). - ANTHROPIC_API_KEY is stripped from the claude child env (it would otherwise take precedence over the subscription login). - Structured-output escalation stays on the same CLI; MCP decide_mode treats an explicit CLI model as having credentials. - Docs: Claude Code no longer listed as sampling-capable; sampling deprecation noted; no-creds error points at CLI models. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
Adds two subscription CLI providers so Althing can run on a signed-in Claude Code or Codex CLI instead of an API key:
claude-code:<model>→claude -p(e.g.claude-code:haiku,claude-code:sonnet;claude-code:uses the CLI default)codex:<model>→codex exec(codex:uses the CLI default)This is the replacement for MCP sampling as the "borrow the host's model access" path. MCP 2026-07-28 deprecated sampling (SEP-2577), and Claude Code never implemented it (anthropics/claude-code#1785), so sampling mode never activated under Claude Code even though the docs said it would.
How it works
system(persona) prompt. Tools, MCP servers, user settings and session persistence are disabled. The process runs in an empty scratch directory so no CLAUDE.md or AGENTS.md leaks in.StructuredOutputEnginepath and SynthBench's--elicitation structured) map onto--json-schema/--output-schemaand come back as normal tool-call responses. Codex needs an OpenAI strict-mode schema, so optional fields become required-but-nullable and the nulls are stripped on the way back.claude-code:would otherwise matchclaude-.claude-code:haikuwould have escalated to the API-keysonnet.decide_modechoose direct execution, sorun_paneland the other tools work under Claude Code with no key.ANTHROPIC_API_KEYis stripped from theclaudechild environment, because the CLI prefers it over the subscription login and would silently bill the key.ALTHING_CLAUDE_CODE_ALLOW_API_KEY=1keeps it.--max-costtherefore acts as a usage budget.ALTHING_CLI_MAX_CONCURRENT(default 4),ALTHING_CLI_TIMEOUT(300 s),ALTHING_CLAUDE_CODE_EFFORT/ALTHING_CODEX_EFFORT,ALTHING_CLAUDE_CODE_BIN/ALTHING_CODEX_BIN.Limitations (documented)
temperature/top_p/seed/max_tokenscontrol. Results should be labelled separately from API-key runs.Docs (sampling correction)
README,
docs/mcp.md,site/mcp(HTML re-rendered to markdown), CLAUDE.md, the CHANGELOG and the no-credentials error message no longer claim Claude Code supports sampling. They note the deprecation and point to the CLI models.Testing
tests/test_subscription_cli.py: 37 tests covering routing, the arguments and environment passed to each CLI, prompt flattening, strict-schema rewriting, error classification, timeouts, stream replay, structured-engine round-trip, escalation anddecide_mode.main(signal handling, file locking, CRLF digests, shell hooks).althing promptran on bothclaude-code:haiku(about 2 s) andcodex:(about 5.6 s). The 3-persona examplepanel runwith synthesis completed cleanly in about 70 s.-p althing -m claude-code:haiku --elicitation structured): 750 out of 750 samples parsed, SPS 0.747 [0.687–0.805], 8.7 min, no errors or rate limits.🤖 Generated with Claude Code