openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

Feature: Claude Agent SDK provider for subscription-backed credit

Open Fiztech-ai opened this issue 6 months ago • 9 comments

Summary Add a claude_agent_sdk provider that routes inference through claude -p (or @anthropic-ai/claude-agent-sdk) instead of the Anthropic HTTP API, so subscribers can use OpenHuman against their Claude plan's Agent SDK credit.

Why Starting June 15, 2026, Anthropic Pro/Max/Team/Enterprise plans include a separate monthly credit for Agent SDK and claude -p usage, including third-party apps built on the SDK (Help Center): Pro: $20/mo Max 20x: $200/mo Team Premium: $100/seat/mo

The credit is only redeemable through the Agent SDK surface — not generic HTTP API calls with ANTHROPIC_API_KEY. Today, OpenHuman's Anthropic path goes through the HTTP API, so subscribers effectively pay twice (flat sub + per-token charges) or skip OpenHuman for Claude work. An SDK provider unlocks the credit for OpenHuman users.

Proposed approach: New claude_agent_sdk provider in src/openhuman/providers/ Spawn claude -p as a child process; communicate over stdin/stdout JSON-RPC (control_request / control_response with request_id multiplexing) Map OpenHuman tool calls onto the SDK's can_use_tool callback so existing approvals still apply Don't handle OAuth tokens directly — assume user has run claude setup-token; CLI manages CLAUDE_CODE_OAUTH_TOKEN refresh Doctor check for claude binary + token status

Config: toml [providers.claude_agent_sdk] enabled = true binary = "claude" model = "claude-sonnet-4-6" permission_mode = "default"

Out of scope (first PR) Migrating other providers Composio/integrations changes (SDK provider should be transparent to them) Local fallback when credit is exhausted (good follow-up)

Open questions

  1. Spawn claude -p as a subprocess, or call the TS SDK directly from the existing node_runtime module?
  2. Credit-exhausted behavior — fall back to a configured secondary provider, or hard-fail with a clear message?

References Help Center: Agent SDK with your Claude plan Agent SDK docs Subprocess protocol reference Prior art: ai-sdk-provider-claude-code

Contribution Can help with design discussion and testing the subscription credit flow once it ships. Would need a Rust-fluent co-contributor for the core subprocess and provider work.

Fiztech-ai avatar May 22 '26 03:05 Fiztech-ai

@Al629176 can I work on this or the team will handle it

aryash45 avatar May 26 '26 09:05 aryash45

@Al629176 can I work on this or the team will handle it

Please feel free to take it up @aryash45 thanks.

Al629176 avatar May 26 '26 11:05 Al629176

@aryash45 Will be glad to assist with design validation/testing.

Fiztech-ai avatar May 26 '26 12:05 Fiztech-ai

Right thanks @Fiztech-ai grateful for your assistance

aryash45 avatar May 26 '26 12:05 aryash45

@Al629176 can you please answer the above open questions mentioned in the issue description that would be a great help also @Fiztech-ai can you please mention your requirements for the design thank you

aryash45 avatar May 26 '26 12:05 aryash45

@aryash45 thanks for picking this up! Here are the design requirements, listed roughly in priority order.

One upstream note before the list: I think the main design decision is whether this should be implemented as a Rust-side provider in src/openhuman/providers/ that shells out to claude -p, or as a TypeScript-backed provider using @anthropic-ai/claude-agent-sdk through the existing app/node runtime path. My preference is the TS SDK path if it fits the current architecture, because the SDK already handles the claude subprocess, exposes typed messages/result metadata, and should keep the OpenHuman-side surface smaller. That said, I understand the Rust core is the authoritative business-logic layer, so I'd like the team's view before treating this as settled.

Must-have (P0)

  1. Subscription-only auth path. This provider must use the Claude CLI / Agent SDK subscription-auth path, relying on the existing Claude Code OAuth setup. No ANTHROPIC_API_KEY codepath in this provider; that would defeat the purpose of using subscription-backed Agent SDK credit. If claude setup-token has not been completed, fail fast with a clear setup message pointing the user to that command.

  2. Token safety. Never display, persist unnecessarily, or log CLAUDE_CODE_OAUTH_TOKEN. Any stderr/debug logs should be redacted.

  3. Doctor check. Pre-flight verification should separately report:

    • claude binary found on PATH or configured path
    • claude --version returns sane output
    • subscription/OAuth auth appears usable

    Surface each as a separate pass/fail.

  4. Streaming input mode. Use the SDK's streaming/input mode rather than a single-shot wrapper, so OpenHuman can preserve its existing streaming UX and agent loop behavior.

  5. Tool approvals reconciled, not duplicated. Map the SDK permission/canUseTool flow into OpenHuman's existing approval system. The user should see one approval prompt per tool call in OpenHuman's UI, not a second prompt from Claude Code/SDK underneath. If a Claude permission mode bypasses this callback path, it should not be enabled by default.

Should-have (P1)

  1. Model selection. Config-driven with a sensible default, e.g. claude-sonnet-4-6 if available. Allow explicit model override rather than hardcoding a short allowlist, because model availability changes.

  2. Permission mode passthrough, but safely constrained. Expose supported modes in config only where they are compatible with OpenHuman's approval model. default should be the default. acceptEdits can be supported if edits still map cleanly into OpenHuman's approval/visibility model. bypassPermissions should either be hidden behind an explicit danger flag or treated as incompatible unless we confirm tool approval mediation still works.

  3. Cost visibility, best effort only. Surface SDK result.modelUsage fields such as input/output/cache tokens and costUSD in OpenHuman's cost module, clearly labeled as a local/client-side estimate. Do not claim to show remaining subscription credit or authoritative billing balance unless Anthropic exposes that via an official API.

  4. Graceful subprocess/SDK failure. A stuck SDK/claude process should fail through OpenHuman's existing heartbeat/retry/error path rather than hanging the agent loop. Capture stderr to redacted logs for debugging.

Nice-to-have (P2)

  1. Configurable binary path. Default binary = "claude", but allow override for non-standard installs such as /opt/homebrew/bin/claude or custom Node/package-manager setups.

  2. max_budget_usd exposure. If supported by the SDK, expose a per-run cost cap so users can set a hard ceiling for an agent run.

Non-requirements / out of scope for first PR

  • Migrating or replacing the existing Anthropic HTTP provider — keep both and let users choose.
  • Automatic fallback between providers when subscription credit is exhausted. That is a good follow-up issue, but first PR should hard-fail clearly.
  • Composio/tools layer changes. The provider should be transparent to that layer.
  • Authoritative billing API integration. Client-side estimates are enough for first PR.

Validation I can offer

I can test the end-to-end flow on a Claude subscription plan once a build is available:

  • setup-token flow
  • confirmation that requests draw from Agent SDK/subscription credit rather than the Anthropic HTTP API key path
  • streaming behavior
  • no double approval prompts
  • doctor checks under broken states such as missing binary, missing/expired token, and invalid binary path

For @Al629176 , two meta-questions on top of the issue-body questions:

  1. Does the team prefer this as a TS SDK-backed provider routed through the existing app/node runtime path, or as a Rust-side provider in src/openhuman/providers/ that shells out to claude -p?

  2. UX preference: should this appear alongside the existing Anthropic HTTP provider as a separate Settings → AI provider, or as a mode/auth toggle on the existing Anthropic provider? My preference is a separate provider because API-key billing and subscription-backed Agent SDK credit are materially different auth/billing paths.

Fiztech-ai avatar May 26 '26 12:05 Fiztech-ai

@Fiztech-ai I think I should work on this after @Al629176 ans these two questions that would provide more clarity what do you think

aryash45 avatar May 26 '26 13:05 aryash45

@Fiztech-ai i think the team already figured out as i can see the pr

aryash45 avatar May 27 '26 17:05 aryash45

from team open human member

aryash45 avatar May 27 '26 17:05 aryash45