Office Hours — How should I architect my AI agent projects to avoid being locked in by Claude's native tooling if the API changes? A daily developer question about AI/LLMs, answered with a direct, opinionated take. 2026-11-29T12:00:00.000Z Office Hours Office Hours office-hoursq-and-apractical-ai

Office Hours — How should I architect my AI agent projects to avoid being locked in by Claude's native tooling if the API changes?

A daily developer question about AI/LLMs, answered with a direct, opinionated take.

Daily One question from the trenches, one opinionated answer.

How should I architect my AI agent projects to avoid being locked in by Claude’s native tooling if the API changes?

The fear here makes sense. Claude’s tooling is excellent—native tool calling, MCP servers, token caching, persistent Projects with memory—but binding your agent architecture directly to Anthropic’s specific implementation creates vendor lock-in. If Claude’s API shifts, pricing changes drastically, or you need to multi-model for cost or compliance reasons, you’re rearchitecting from scratch instead of swapping a provider.

The core principle is simple: abstract the LLM away from your agent logic. Your agent shouldn’t know whether it’s talking to Claude, GPT-5.6 Sol, or Qwen3.8-Max. The harder part is doing this without building a leaky abstraction that defeats the purpose.

Build Against a Portable Agent Interface

Define your agent’s decision-making loop independently of any provider’s native format. Instead of coupling directly to Claude’s tool_use content blocks or MCP message schemas, write your agent around a provider-agnostic interface:

from dataclasses import dataclass
from typing import Protocol

@dataclass
class ToolCall:
    tool_name: str
    arguments: dict
    id: str  # For matching responses

@dataclass
class AgentStep:
    reasoning: str
    tool_calls: list[ToolCall] | None
    final_response: str | None

class LLMBackend(Protocol):
    def step(self, messages: list, tools: list, temperature: float) -> AgentStep:
        """
        Unified interface for one agentic step.
        Each backend translates its native format to AgentStep.
        """
        ...

class ClaudeBackend:
    def step(self, messages, tools, temperature):
        # Call claude-opus-5-5 via Anthropic SDK
        # Parse tool_use blocks into AgentStep
        # Hide MCP and Projects complexity here
        ...

class GPTBackend:
    def step(self, messages, tools, temperature):
        # Call GPT-5.6 Sol via OpenAI SDK
        # Parse function_call into AgentStep
        # Translate between param formats
        ...

class Agent:
    def __init__(self, backend: LLMBackend, tools: list):
        self.backend = backend
        self.tools = tools
    
    def run(self, user_input: str):
        messages = [{"role": "user", "content": user_input}]
        while True:
            step = self.backend.step(messages, self.tools, temperature=0)
            if step.final_response:
                return step.final_response
            # Execute tool_calls, append results, continue loop
            ...

This isn’t groundbreaking, but it’s the floor. Your agent loop never calls the Anthropic SDK or touches MCP directly. The backend abstraction is where all vendor-specific code lives. Swapping providers becomes changing one line: agent = Agent(GPTBackend(), tools).

Keep Tool Definitions Provider-Neutral

Anthropic’s tool schemas use a specific JSON structure. OpenAI’s are slightly different. Rather than duplicating tool definitions for each provider, define tools once in a canonical format and translate on the fly:

@dataclass
class Tool:
    name: str
    description: str
    parameters: dict  # JSON Schema, provider-agnostic

def to_claude_tool(tool: Tool) -> dict:
    return {
        "name": tool.name,
        "description": tool.description,
        "input_schema": {
            "type": "object",
            "properties": tool.parameters,
            "required": list(tool.parameters.keys()),
        },
    }

def to_openai_tool(tool: Tool) -> dict:
    return {
        "type": "function",
        "function": {
            "name": tool.name,
            "description": tool.description,
            "parameters": {
                "type": "object",
                "properties": tool.parameters,
                "required": list(tool.parameters.keys()),
            },
        },
    }

# Define once
search_tool = Tool(
    name="search",
    description="Search the knowledge base",
    parameters={"query": {"type": "string"}},
)

# Use everywhere
claude_tools = [to_claude_tool(search_tool)]
openai_tools = [to_openai_tool(search_tool)]

This saves maintenance burden and prevents drift where your Claude version and OpenAI version of the same tool end up doing different things.

Don’t Lean Too Hard on MCP or Persistent Projects

MCP servers are powerful for state management and tool sharing, but they’re Anthropic-specific. If you build your agent’s memory and tool discovery around MCP, migrating to another model means rewriting that layer. Instead, keep MCP as optional infrastructure for performance, not a required primitive:

class Agent:
    def __init__(self, backend, tools, memory=None, mcp_server=None):
        self.backend = backend
        self.tools = tools
        self.memory = memory or InMemoryMemory()  # Fallback
        self.mcp = mcp_server  # Optional optimization
    
    def get_context(self):
        # Try MCP first if available, fall back to in-memory
        if self.mcp:
            return self.mcp.get_context()  # Claude-specific
        return self.memory.recall()  # Provider-agnostic

This way MCP accelerates your Claude deployment without becoming a hard dependency. If you switch providers, you lose the performance boost but the agent still works.

Treat Token Caching and Long Context as Optimization Layers

Claude’s prompt caching and 1M token context are genuinely useful, but don’t architect your system assuming they exist. Build your context management to work with 100K tokens, then use caching and longer windows as optimizations when available. This is especially important because other providers (GPT-5.6 Sol has 1M context too, but different caching semantics) have different tradeoffs.

A real example: if you’re building an agent that processes long documents, segment them and retrieve chunks like you would in RAG. When you deploy on Claude, you can cache the full document once and reuse it. On GPT, you retrieve as normal. The agent logic stays identical.

Version Your Agent Traces, Not Your Prompts

Lock in reproducibility by logging agent decisions—tool calls, reasoning steps, results—not raw prompt text. This means you can re-evaluate an old decision against a new model without rewinding the entire system:

@dataclass
class AgentTrace:
    step_num: int
    input_messages: list
    tool_calls: list[ToolCall]
    tool_results: dict
    final_response: str
    model_used: str  # For audit trails

# Store traces in a database
traces = []
for step in agent.run_with_tracing(user_input):
    traces.append(step)
    # Replay: test_new_model.step(step.input_messages, step.tools)

This lets you benchmark new models against your production traces without rereleasing the agent. If Claude changes and you’re worried, replay 100 recent traces on GPT-5.6 Sol and compare quality before committing.

Accept Some Latency and Cost Overhead

A truly portable agent architecture costs something: extra abstraction layers add latency, and you can’t use provider-specific tricks (like Claude’s native computer use) without special-casing code. The question is whether that tradeoff is worth it for your use case.

If you’re building a one-off internal tool and Claude is perfect for it, locking in is probably fine. If you’re building a customer-facing agent that needs to survive provider changes or cost spikes, the abstraction pays for itself. Know which camp you’re in.

Bottom line: Abstract your agent loop from provider APIs using a simple backend interface, keep tool definitions canonical, and treat vendor-specific features (MCP, caching, long context) as optional optimizations rather than architectural requirements. This costs some convenience but keeps you portable.

Question via Hacker News