Summary
Migrate the HCA-I2P MVP from the current multi-SDK approach to a hybrid architecture:
- Keep: Google ADK for agent orchestration (LlmAgent, Runner, SessionService, FunctionTool)
- Add: Vercel AI SDK with
@openrouter/ai-sdk-provider for LLM calls
- Remove: Direct
openai SDK usage, @opencode-ai/sdk dependency
Motivation
Current architecture uses 3 different approaches for LLM calls:
- Custom
OpenRouterLlm adapter with raw fetch (fragile format conversion)
openai SDK in llm-invoke.ts
@opencode-ai/sdk for extended thinking
Issues with current approach:
- Tool call ID instability (Date.now() collisions)
- No streaming support in ADK adapter
- Format conversion bugs (Gemini vs OpenAI message formats)
- Multiple codepaths for same functionality
Benefits of AI SDK
- Native OpenRouter provider with extended thinking support
- Unified API across providers
- Built-in streaming with proper backpressure
- Provider registry for multi-model routing
- Proper reasoning token tracking
Migration Phases
Phase 1: Add AI SDK Dependencies
Phase 2: Create AI SDK LLM Tool
Phase 3: Update OpenRouterLlm Internals
Phase 4: Migrate Analysis Stages
Phase 5: Remove OpenCode Dependency
Phase 6: Validation & Cleanup
Architecture After Migration
┌─────────────────────────────────────────────────┐
│ Google ADK │
│ (Agent orchestration, Session, FunctionTool) │
└─────────────────────┬───────────────────────────┘
│
┌─────────────────────▼───────────────────────────┐
│ AI SDK Provider Registry │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────┐ │
│ │ boundary │ │ gap │ │decomp: │ │
│ │ (flash) │ │ (opus) │ │thinking │ │
│ └─────────────┘ └─────────────┘ └─────────┘ │
└─────────────────────┬───────────────────────────┘
│
┌─────────────────────▼───────────────────────────┐
│ @openrouter/ai-sdk-provider │
│ (OpenRouter API) │
└─────────────────────────────────────────────────┘
Related Files
src/holons/adk/openrouter-llm.ts - Custom LLM adapter
src/holons/adk/agents.ts - Agent definitions
src/tools/llm-invoke.ts - OpenAI SDK wrapper
src/tools/opencode-client.ts - Extended thinking
src/config.ts - Configuration
Summary
Migrate the HCA-I2P MVP from the current multi-SDK approach to a hybrid architecture:
@openrouter/ai-sdk-providerfor LLM callsopenaiSDK usage,@opencode-ai/sdkdependencyMotivation
Current architecture uses 3 different approaches for LLM calls:
OpenRouterLlmadapter with raw fetch (fragile format conversion)openaiSDK inllm-invoke.ts@opencode-ai/sdkfor extended thinkingIssues with current approach:
Benefits of AI SDK
Migration Phases
Phase 1: Add AI SDK Dependencies
aiand@openrouter/ai-sdk-providerpackagesPhase 2: Create AI SDK LLM Tool
src/tools/ai-sdk-invoke.tsusing AI SDKllmInvokeToolto use new implementationPhase 3: Update OpenRouterLlm Internals
generateText()Phase 4: Migrate Analysis Stages
Phase 5: Remove OpenCode Dependency
:thinkingvariant for extended reasoning@opencode-ai/sdkPhase 6: Validation & Cleanup
openaipackageArchitecture After Migration
Related Files
src/holons/adk/openrouter-llm.ts- Custom LLM adaptersrc/holons/adk/agents.ts- Agent definitionssrc/tools/llm-invoke.ts- OpenAI SDK wrappersrc/tools/opencode-client.ts- Extended thinkingsrc/config.ts- Configuration