# AgentForge Adapters

This directory contains framework-specific adapters that translate the `AGENT.md` specification into executable agent instances across various AI frameworks.

## Hardened Adapter Features

As of the Production Hardening phase, all adapters benefit from:

1. **Exponential Backoff Retries**: Automatic handling of `RateLimitError` and `TimeoutError` for Anthropic and OpenAI SDKs.
2. **Precise Cost Tracking**: Integrated token estimation using `tiktoken` (cl100k_base) and real-time USD cost calculation.
3. **Structured Observability**: All adapters use `ContextLogger` for JSON-formatted logs with correlation IDs.
4. **Parallel Health Checks**: Use `cli.py health` to verify connectivity for all registered adapters simultaneously.
5. **Pre-flight Diagnostics**: Safe loading mechanism checks for missing framework dependencies before instantiation.

## Currently Supported Frameworks

| Framework | Adapter Class | Status |
| :--- | :--- | :--- |
| `anthropic-sdk` | `AnthropicSDKAdapter` | Production Ready |
| `openai-sdk` | `OpenAISDKAdapter` | Production Ready |
| `langchain` | `LangChainAdapter` | Production Ready |
| `http` | `HttpAdapter` | Production Ready |
| `subprocess` | `SubprocessAdapter` | Production Ready |
| `langgraph` | `LangGraphAdapter` | Production Ready |
| `crewai` | `CrewAIAdapter` | Production Ready |
| `autogen` | `AutoGenAdapter` | Production Ready |

## Adding a New Adapter

To add support for a new framework:

1. Inherit from `BaseAdapter` in `core/adapters/base.py`.
2. Implement `run(prompt, context)` and `health_check()`.
3. Register the new adapter in `AgentRunner.ADAPTER_REGISTRY` in `core/agent_runner.py`.
4. Add a pre-flight check mapping in `core/diagnostics.py`.
