{"slug": "add-claude-sonnet-5-behind-a-provider-contract-not-across-your-codebase", "title": "Add Claude Sonnet 5 Behind a Provider Contract, Not Across Your Codebase", "summary": "Anthropic announced Claude Sonnet 5 on June 30, 2026, for coding, agents, and professional work. A developer recommends integrating new models behind a provider contract using a generic Event interface and adapter pattern, rather than spreading provider-specific code across the application. The approach includes a validated event log and tool policy gate to prevent unsafe direct tool calls.", "body_md": "Anthropic announced [Claude Sonnet 5](https://www.anthropic.com/news) on June 30, 2026, positioning it for coding, agents, and professional work. A model release is easiest to adopt when the rest of the application does not know the vendor's wire format.\n\nHere is the TypeScript seam I want first:\n\n```\ntype ToolCall = {\n  id: string;\n  name: string;\n  arguments: unknown;\n};\n\ntype Event =\n  | { type: \"text\"; delta: string }\n  | { type: \"tool\"; call: ToolCall }\n  | { type: \"usage\"; input: number; output: number }\n  | { type: \"done\"; reason: string };\n\ninterface ModelProvider {\n  stream(input: {\n    system: string;\n    messages: Array<{ role: \"user\" | \"assistant\"; content: string }>;\n    tools: Array<{ name: string; schema: object }>;\n    signal: AbortSignal;\n  }): AsyncIterable<Event>;\n}\n```\n\nBuild one adapter for the provider API. Keep the application dependent on `Event`\n\n.\n\nThe production path should be:\n\n``` php\nbrowser -> task API -> provider adapter -> validated event log\n                              |\n                        tool policy gate\n```\n\nDo not let a provider-native tool call jump directly into a shell command. Parse it, validate it, authorize it, and write the decision to the task log.\n\nThis pattern also explains a practical reason I use [MonkeyCode](https://monkeycode-ai.net/): I prefer coding workflows where model selection is not the entire product boundary. MonkeyCode exposes a hosted SaaS for a low-setup trial and an [open-source self-hosted path](https://github.com/chaitin/MonkeyCode). I recommend evaluating it with the same provider contract and failure fixtures rather than assuming any named model works identically.\n\nI have not run a live Sonnet 5 comparison for this article, so this is an integration design, not a performance endorsement.\n\nDisclosure: I'm a MonkeyCode user sharing my own experience, not affiliated with the project.\n\nA new model should be one adapter plus a capability record. If adding it requires provider-specific conditionals in your UI, worker, and tool executor, the migration has exposed an architecture problem before it has exposed a model problem.", "url": "https://wpnews.pro/news/add-claude-sonnet-5-behind-a-provider-contract-not-across-your-codebase", "canonical_source": "https://dev.to/kongkong1/add-claude-sonnet-5-behind-a-provider-contract-not-across-your-codebase-2ki2", "published_at": "2026-07-15 07:16:42+00:00", "updated_at": "2026-07-15 07:29:29.119038+00:00", "lang": "en", "topics": ["large-language-models", "developer-tools", "ai-agents", "ai-safety", "ai-products"], "entities": ["Anthropic", "Claude Sonnet 5", "MonkeyCode"], "alternates": {"html": "https://wpnews.pro/news/add-claude-sonnet-5-behind-a-provider-contract-not-across-your-codebase", "markdown": "https://wpnews.pro/news/add-claude-sonnet-5-behind-a-provider-contract-not-across-your-codebase.md", "text": "https://wpnews.pro/news/add-claude-sonnet-5-behind-a-provider-contract-not-across-your-codebase.txt", "jsonld": "https://wpnews.pro/news/add-claude-sonnet-5-behind-a-provider-contract-not-across-your-codebase.jsonld"}}