-
Notifications
You must be signed in to change notification settings - Fork 372
feat: Add Codex SDK Support with Unified Adapter Pattern #172
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Add sdk_adapter package with unified interface for Claude and Codex SDKs: - Create sdk_adapter/ package with types, protocols, factory, and adapters - Implement ClaudeAdapter wrapping existing Claude SDK logic - Implement CodexAdapter for codex-sdk-py integration with MCP support - Add AUTOFORGE_SDK environment variable for SDK selection (claude/codex) Update existing code to use unified adapter: - Migrate agent.py to use EventType-based event processing - Update client.py to use create_adapter() factory - Migrate chat sessions to use sdk_adapter (assistant, spec, expand) - Add Codex-specific environment variable support in registry.py Configuration: - Add codex-sdk-py to requirements.txt/requirements-prod.txt - Add AUTOFORGE_SDK to .env.example with documentation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Very Cool! Thanks! (Can you confirm that this ultimately means people can use AutoForge with either their Claude Code Subscription and / or their Codex subscription? (NOT API - too expensive). We should let users use them in tandem even with graceful failover between them when a user's rate limit is reached and or waiting to reset. |
|
Yes, your understanding is correct. AutoForge can be used with either a Claude Code subscription and/or a Codex subscription, without relying on the API (which would be prohibitively expensive). Users should be able to use both in tandem, with graceful failover between them—so if one hits a rate limit or is waiting for a reset, AutoForge can automatically switch to the other to maintain continuity. |
|
@leonvanzyl |
Summary
This PR adds support for the Codex SDK (Python) alongside the existing Claude Agent SDK, enabling users to switch between SDKs via the
AUTOFORGE_SDKenvironment variable.Key Changes:
sdk_adapter/package with a unified interface for both SDKsMotivation
The Codex SDK provides an alternative AI backend that may be preferred in certain environments or for specific use cases. By abstracting the SDK layer, AutoForge becomes more flexible and vendor-agnostic.
Changes
New Package:
sdk_adapter/types.pyEventType,AgentEvent,AdapterOptions)protocols.pySDKAdapterProtocol definitionfactory.pycreate_adapter()factory with SDK selection logicclaude_adapter.pycodex_adapter.pyModified Files
agent.pyEventType-based event processingclient.pycreate_adapter()factory for SDK-agnostic client creationregistry.pyget_sdk_type()andget_effective_sdk_env_for_codex()server/services/assistant_chat_session.pyserver/services/spec_chat_session.pyserver/services/expand_chat_session.pyserver/services/process_manager.pystart_ui.pyConfiguration
.env.exampleAUTOFORGE_SDKdocumentationrequirements.txtcodex-sdk-py>=0.0.6requirements-prod.txtcodex-sdk-py>=0.0.6Usage
Architecture
SDK Feature Comparison
Codex SDK Limitations
--configCLI flag with TOML formatTesting
Breaking Changes
None. Default behavior unchanged (Claude SDK).