Skip to content

feat(auth): force subscription-only mode for Claude provider#166

Open
Maury1329 wants to merge 1 commit intoAutoForgeAI:masterfrom
Maury1329:feature/use-cli-instead-of-api
Open

feat(auth): force subscription-only mode for Claude provider#166
Maury1329 wants to merge 1 commit intoAutoForgeAI:masterfrom
Maury1329:feature/use-cli-instead-of-api

Conversation

@Maury1329
Copy link

@Maury1329 Maury1329 commented Feb 6, 2026

Summary

Prevents accidental API credit consumption by explicitly enforcing subscription-only mode when using the default Claude provider. This ensures users with Claude Code subscriptions don't inadvertently incur API charges.

Changes

client.py

  • Added safety check to reject API credentials for Claude provider before SDK client creation
  • Added user-facing confirmation messages for subscription mode
  • Raises RuntimeError if ANTHROPIC_API_KEY or ANTHROPIC_AUTH_TOKEN are detected in Claude mode

registry.py

  • Modified get_effective_sdk_env() to explicitly clear API authentication env vars
  • Forces empty strings for ANTHROPIC_API_KEY and ANTHROPIC_AUTH_TOKEN in Claude mode
  • Added logging to confirm subscription-only mode activation

Motivation

Previously, the system would forward existing environment variables which could lead to:

  • Unexpected API billing when users have OAuth tokens
  • Confusion between subscription vs API usage
  • Potential accidental charges for users with Claude Code subscriptions

Testing

  • Verify agent runs successfully in subscription mode
  • Confirm no API credentials are passed to SDK
  • Check that safety error is raised if API key is detected
  • [ ] Validate console messages show subscription mode confirmation

Breaking Changes

None - This is a safety enhancement that only affects Claude provider configuration.

Labels:

  • enhancement
  • security
  • authentication

Prevent accidental API credit consumption by explicitly disabling API
authentication when using the default Claude provider. This ensures
users with Claude Code subscriptions don't inadvertently incur API charges.

Changes:
- Add safety check in client.py to reject API credentials for Claude provider
- Modify registry.py to explicitly clear API auth env vars in Claude mode
- Add user-facing confirmation messages for subscription mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant