Repository navigation
Conversation
Zeus-Deus
force-pushed
the
t3code/add-claude-subscription-support
branch
from
August 26, 2026 17:19
330a533 to
e48cd3c
Compare
Adds a new 'claude-code' provider (api_mode=claude_agent_sdk) that runs whole turns through Anthropic's claude-agent-sdk, so a Claude Pro/Max/Team subscription is billed to the user's plan instead of the extra-usage pool. The existing 'anthropic' API-key provider is unchanged and the current direct-OAuth path keeps working; nothing is migrated automatically. Highlights: - New whole-turn runtime beside the codex one: sync facade over the async SDK client, event projector to the canonical Hermes callbacks, in-process MCP bridge routing every tool call through the one canonical execute_one_tool() lifecycle (approvals, guardrails, checkpoints, environments all preserved). - Billing safety: a sanitized subprocess transport strips every higher-precedence credential (options.env can override but never delete), a static+dynamic preflight refuses to start a turn that would not bill the plan, and a zero-cost init probe verifies the billing source per session. Auxiliary (side-LLM) calls go through the same transport+guard. - Durable sessions: DB-backed SessionStore mirror (SDK conformance suite passes), Hermes<->SDK session binding, restart resume, rewind/branch via SDK forks, stale-session recovery. - System prompt: claude_code preset + Hermes' own identity section (SOUL.md or DEFAULT_AGENT_IDENTITY) + a factual tool-routing note; the full Hermes prompt rides the first user turn. Measured against the live billing classifier: preset replacement or a full-prompt append is billed to extra usage. - Ships default-off behind claude_subscription.enabled pending Anthropic policy clarification (see docs/design/claude-subscription-via-agent-sdk.md). - CI: claude-boundary checker forbidding credential access and Claude Code impersonation, plus an integration job that installs the real SDK and runs the gated tests. Rebase notes (2026-08-26, onto main @ 5538bd1): - agent/tool_executor.py: main's two dispatchers are kept as they are on main; execute_one_tool()/finalize_tool_outcome() are re-ported onto main's middleware (five-field managed result, dispatched-aware terminal post_tool_call rule, tool_call_id-aware guardrail observation) as the entry point for the Agent SDK bridge, instead of re-routing the batch paths through the funnel. - claude-agent-sdk floor 0.2.128 -> 0.2.140: main pins mcp==2.0.0 and 0.2.140 is the first SDK release whose mcp range admits 2.x. A dated exclude-newer exception (remove after 2026-09-01) lets uv see it. - hermes_state.py: the provider rewind-boundary note now runs inside main's single-transaction rewind body. - hermes_cli/models.py keeps main's provider labels. - scripts/check_claude_boundary.py allow-lists hermes_cli/inventory.py (docstring mention of the legacy Claude Code credential file, added on main). - tests: the lifecycle test patches _dispatch_pre_tool_call_hooks (main's single pre_tool_call entry point) and honours suppress_post_tool_call_hook; the delegate test uses non-placeholder goals (main's batch quality gate). - tests made hermetic against the host's Claude setup: the runtime turn tests stub verify_claude_billing_for_agent (the per-session CLI probe) and the auxiliary routing fixture pretends the claude CLI resolves — both had only passed on machines with a signed-in Claude Code. - lint.yml "Claude Agent SDK integration": install from uv.lock (--extra dev --extra claude-code) instead of pip-installing the SDK alone; main's agent.display now imports the yaml-backed utils module. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Zeus-Deus
force-pushed
the
t3code/add-claude-subscription-support
branch
from
August 26, 2026 17:52
e48cd3c to
9326a55
Compare
Contributor
Author
|
Closing this in favour of the official route that landed since: the core seams in #117451 plus the |
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
Adds a new Claude subscription (Agent SDK) provider (
claude-code,api_mode=claude_agent_sdk) that runs whole turns through Anthropic's officialclaude-agent-sdk. Users sign in withclaude auth login; turns draw on their Claude Pro/Max/Team plan instead of the extra-usage pool.The existing
anthropicAPI-key provider is unchanged, and the current direct-OAuth path keeps working. Nothing is migrated automatically — users on the old path get a one-time notice explaining the two options.Why
Today's
claude-codealias reads Claude Code's credential store and hand-builds/v1/messagesrequests with Claude Code identity headers. Anthropic's billing classifier routes that to the plan's extra-usage pool (empty by default), which is the recurring "out of extra usage" complaint. Routing turns through the official SDK — the same integration shape as T3 Code and Codemux — bills the plan itself.Design
execute_one_tool(), which mirrors the per-tool lifecycle of Hermes' own dispatchers (approvals, guardrails, checkpoints, environment routing, hooks).options.envcan override but never delete), preflight refuses any turn that would not bill the plan (naming the offending variable), and a zero-cost init probe verifies the billing source per session. Auxiliary/side-LLM calls use the same transport and guard.claude_subscription.enabled— Anthropic's Agent SDK docs and Help Center currently disagree on third-party subscription use, so enablement is an explicit user choice. Full decision record indocs/design/claude-subscription-via-agent-sdk.md.Testing
claude-agent-sdkextra installed; full suites unaffected.--cap-drop=ALL, non-root) on a consenting maintainer account: billing proven by falsification — with a deliberately invalidANTHROPIC_API_KEYin the environment, a turn through this runtime succeeds (plan credential) while the same turn without sanitization fails; the CLI does not fall back from a bad key.pip install -e '.[claude-code]': chat, tool calls through the bridge, terminal, context continuity, and restart resume (same SDK session id after a new process). Also exercised against SDK 0.2.131 to confirm the range pin at the time; after the rebase the floor is 0.2.140, the first release whosemcprange admits themcp==2.0.0main pins.set_model(context preserved), tool execution, session persistence.Notes for review
TODO(legacy-retirement)markers for removal after enablement and migration.pyproject.tomladdsclaude-codeas an opt-in extra (the SDK wheels are ~80 MB; deliberately not in[all]).uv.lockregenerated.🤖 Generated with Claude Code