AI Agents — Multi-Provider Developer Guide
What is an AI agent?
Same loop everywhere; the differentiator is the SDK, the hosting, and how you attach tools — unified by MCP.
xAI Grok (xai-sdk: client-side tool()/tool_result() + server-side web_search/code_execution/mcp()), Anthropic (the Claude API Tool Runner, the Claude Agent SDK with @tool + create_sdk_mcp_server where allowed_tools auto-approves rather than restricts, and the hosted Managed Agents beta), Microsoft's Agent Framework (agent_framework / .NET AIAgent over IChatClient; the SK+AutoGen successor) plus VS Code's Agents (MCP via .vscode/mcp.json), and Google ADK (Agent + functions-as-tools, McpToolset, deploy to Agent Runtime), and the Vercel AI SDK's ToolLoopAgent. MCP is the connector: build one server, every agent consumes it. Its 2026-07-28 spec is stateless, with Streamable HTTP for remote servers. For codeAmani: keep keys server-side, allowlist tools, require human approval before any money-moving action, and bound the loop with step + cost limits.
Four ways to build one — and the connector
Same loop, different SDK + hosting. Tap a card for install, tools, and MCP wiring.
Watch the agent loop run
The single idea behind every agent SDK. Press Run and follow one pass: the agent can’t answer directly, so it reasons, calls a tool, observes the result, reasons again, and only then responds — exactly the flow you wire with Grok, Claude, Microsoft, or Google.
- →Perceive
- →Reason
- →Act
- →Observe
- Respond
Every provider runs this same loop. The tool here is an mpesa MCP server — written once, callable from Grok, Claude, Microsoft, or Google agents. Bound the loop with step + cost limits, and require human approval before any money-moving tool.
█████╗ ██╗ █████╗ ██████╗ ███████╗███╗ ██╗████████╗███████╗
██╔══██╗██║ ██╔══██╗██╔════╝ ██╔════╝████╗ ██║╚══██╔══╝██╔════╝
███████║██║ ███████║██║ ███╗█████╗ ██╔██╗ ██║ ██║ ███████╗
██╔══██║██║ ██╔══██║██║ ██║██╔══╝ ██║╚██╗██║ ██║ ╚════██║
██║ ██║██║ ██║ ██║╚██████╔╝███████╗██║ ╚████║ ██║ ███████║
╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚══════╝AI Agents — Multi-Provider Developer Guide
Focus: how to build AI agents on the stacks you'll actually reach for: Anthropic (Claude API Tool Runner, Claude Agent SDK, Claude Managed Agents), xAI Grok, Microsoft Agent Framework (+ VS Code agents), Google ADK, and the Vercel AI SDK. Covers their scope, how to wire tools, and the MCP connector that links them all. Grounded in each vendor's official docs and registries; reviewed 2026-10-18.
What an agent actually is
Strip away the hype: an agent is a language model put in a loop with tools. It reads the goal, decides whether it can answer directly or needs a tool, calls the tool, reads the result, and loops until it can give a final answer. Everything else (memory, multi-agent, hosting) is built on top.
The two non-negotiables: tools (what the agent can do: search, query a DB, send an SMS) and stop conditions (when to quit the loop). Get those right and the rest is plumbing.
Who runs the loop?
The first decision is not which model. It is who owns the loop and where tools execute:
| You want… | Reach for | Loop runs | Tools run |
|---|---|---|---|
| Full control of every message | Raw SDK, manual loop | Your code | Your code |
| Your tools, no loop boilerplate | Claude Tool Runner, AI SDK ToolLoopAgent, MS Agent Framework, Google ADK | SDK in your process | Your code |
| A ready-made coding/ops agent (files, bash, web) | Claude Agent SDK | SDK in your process | Your machine / container |
| Anthropic to host the loop and a sandbox | Claude Managed Agents (beta) | Anthropic | Per-session container |
| Search / code / MCP calls run by the provider | xAI server-side tools | xAI | xAI |
| A loop that survives crashes and waits for approval | AI SDK WorkflowAgent | Durable workflow | Your code |
Official Documentation
MCP — the universal connector
Before the providers, learn the thing that ties them together. MCP (Model Context Protocol) is an open standard: an MCP server exposes tools, resources, and prompts, and any MCP-capable agent (client) can consume them. Build your "check M-Pesa status" or "query Supabase" tool once as an MCP server, and every agent below can call it.
What changed in the 2026-07-28 spec
The current revision is 2026-07-28 (the previous one was 2025-11-25). If you wrote MCP code a year ago, these are the changes that matter:
- MCP is stateless. The
initializehandshake and theMcp-Session-Idheader are gone. Every request carries its protocol version and client capabilities in_meta. Servers must implement a newserver/discoverRPC. Servers that need state across calls pass explicit handles as ordinary tool arguments. - Transports: stdio for local subprocesses, Streamable HTTP for remote servers. The old HTTP+SSE transport is formally Deprecated (12-month minimum window), so migrate to Streamable HTTP. SSE resumability (
Last-Event-ID) is removed. - Deprecated: Roots, Sampling, and Logging. Pass directories as tool parameters, call the model API directly instead of sampling, and log to
stderror OpenTelemetry. - Server-initiated requests (elicitation, sampling) are replaced by Multi Round-Trip Requests: the server returns
resultType: "input_required"and the client retries with the answers. Every result now carries aresultType. - Auth: OAuth stays. Client ID Metadata Documents are preferred, Dynamic Client Registration is deprecated, and clients must validate
iss(RFC 9207). - Extensions (opt-in,
io.modelcontextprotocol/*): MCP Apps (inline UI), Tasks (long-running work, moved out of the core), Skills over MCP, auth extensions. The MCP Registry exists but is officially preview.
SDKs
| Language | Package | Version (2026-10-18) | Notes |
|---|---|---|---|
| TypeScript (v2, current) | @modelcontextprotocol/server, @modelcontextprotocol/client | 2.3.1 | Split packages; implements the 2026-07-28 spec |
| TypeScript (v1) | @modelcontextprotocol/sdk | 1.32.1 | Maintenance branch (v1.x): fixes for at least 6 months after the v2 release |
| Python | mcp | 2.3.0 | from mcp.server import MCPServer (replaces FastMCP in the README) |
A read-only tool server, built once and attachable to every agent below (TypeScript, v2 SDK, ESM):
// mpesa-tools/server.ts npm i @modelcontextprotocol/server zod
import { McpServer } from "@modelcontextprotocol/server";
import { StdioServerTransport } from "@modelcontextprotocol/server/stdio";
import { z } from "zod";
const server = new McpServer({ name: "mpesa-tools", version: "1.0.0" });
server.registerTool(
"mpesa_status",
{
description: "Read the recorded status of an M-Pesa STK checkout. Read-only.",
inputSchema: z.object({ checkout_request_id: z.string().min(10) }),
},
async ({ checkout_request_id }) => {
const row = await lookupCheckout(checkout_request_id); // your DB read
return row
? { content: [{ type: "text", text: JSON.stringify(row) }] }
: { content: [{ type: "text", text: "not_found" }], isError: true };
},
);
await server.connect(new StdioServerTransport());Every provider in this guide speaks MCP. That's the bet: write tools once, reuse everywhere. See the github and supabase guides for first-party MCP servers you can attach today.
1. Anthropic — three ways to build on Claude
Anthropic offers three agent surfaces that differ in who hosts what. Pick the simplest one that does the job.
a) Claude API + Tool Runner (your tools, SDK runs the loop)
The default for a custom-tool agent. The TypeScript SDK's Tool Runner (beta in @anthropic-ai/sdk 0.135) runs the request → execute → loop cycle; you write tool functions. Full example: examples/agent-tool-runner.ts. The manual loop it automates is in examples/agent-loop.ts.
import Anthropic from "@anthropic-ai/sdk";
import { betaZodTool } from "@anthropic-ai/sdk/helpers/beta/zod";
import { z } from "zod";
const client = new Anthropic(); // ANTHROPIC_API_KEY, server-side
const mpesaStatus = betaZodTool({
name: "mpesa_status",
description: "Read the recorded status of an M-Pesa STK checkout.",
inputSchema: z.object({ checkout_request_id: z.string() }),
run: async ({ checkout_request_id }) => JSON.stringify(await lookupCheckout(checkout_request_id)),
});
const final = await client.beta.messages.toolRunner({
model: "claude-opus-5-5",
max_tokens: 16000,
max_iterations: 10, // the step cap. Always set it
tools: [mpesaStatus],
messages: [{ role: "user", content: "Is checkout ws_CO_123 paid?" }],
});Three gotchas from the current API:
- Handle every
stop_reason."tool_use"means run tools;"pause_turn"means a server tool paused, so re-send to continue (the Tool Runner does not auto-resume it);"refusal"means the model declined, so checkstop_detailsinstead of retrying blindly. A loop that treats "nottool_use" as "done" silently truncates. - Tool errors go back as data: a
tool_resultwithis_error: true, never a thrown exception. And return all results of a turn in one user message, or Claude learns to stop making parallel calls. - Current models reject old request shapes.
claude-opus-5-5returns a 400 fortemperature, for disabled thinking, and for forcedtool_choice(any/tool). Usetool_choice: autoplus a prompt instruction, and control depth withoutput_config.effort(defaultmediumon Opus 5.5).
b) Claude Agent SDK (a ready-made agent harness)
- Scope: the harness behind Claude Code, packaged as a library: built-in file / bash / web tools, hooks, permissions, subagents, sessions, and first-class MCP. You host it.
- Packages: PyPI
claude-agent-sdk(0.2.168, Python ≥3.10) and npm@anthropic-ai/claude-agent-sdk(0.3.302).
from claude_agent_sdk import tool, create_sdk_mcp_server, ClaudeAgentOptions, query, ResultMessage
@tool("mpesa_status", "Check an M-Pesa STK payment status", {"checkout_id": str})
async def mpesa_status(args):
status = await lookup(args["checkout_id"]) # your code
return {"content": [{"type": "text", "text": status}]}
server = create_sdk_mcp_server(name="mpesa", version="1.0.0", tools=[mpesa_status])
options = ClaudeAgentOptions(
mcp_servers={"mpesa": server},
allowed_tools=["mcp__mpesa__mpesa_status"], # auto-approve this one tool
disallowed_tools=["Bash"], # remove a built-in entirely
permission_mode="default",
max_turns=10,
max_budget_usd=0.50, # hard cost cap → result subtype "error_max_budget_usd"
)
async for msg in query(prompt="Is checkout ws_CO_123 paid?", options=options):
if isinstance(msg, ResultMessage) and msg.subtype == "success":
print(msg.result)allowed_toolsis auto-approval, not a restriction. The docs: tools listed there run without a prompt; unlisted tools "fall through topermissionModeandcanUseTool". To restrict availability, usetools=[...](tools=[]removes every built-in) ordisallowed_tools. A bare name like"Bash"removes the tool from Claude's context; a scoped rule like"Bash(rm *)"only denies matching calls.- Tool names are
mcp__{server}__{tool}; wildcards such asmcp__mpesa__*work. - Other options worth knowing:
can_use_tool(your own approval callback),hooks,agents(subagent definitions),fallback_model,effort, andresume/fork_sessionfor sessions. UseClaudeSDKClientinstead ofquery()for multi-turn, bidirectional sessions. The TypeScript names are the camelCase twins (createSdkMcpServer,allowedTools,maxTurns,maxBudgetUsd,canUseTool). - Mark read-only tools with
annotations=ToolAnnotations(readOnlyHint=True)so Claude can run them in parallel. Tool search is on by default, so large MCP tool sets load lazily.
c) Claude Managed Agents (Anthropic hosts the loop and the sandbox)
Beta (managed-agents-2026-04-01, set automatically by the SDK on client.beta.*). You create a persisted, versioned Agent config once (model, system prompt, tools, MCP servers, skills), then start a Session per run. Each session gets its own container where bash, file, and code tools execute, and streams events back to you. Credentials for MCP servers and CLIs live in vaults and are substituted at egress, never visible in the sandbox. There are also scheduled deployments, rubric-graded outcomes, and multi-agent sessions.
- Mandatory flow:
agents.create()once (store the ID) →sessions.create({ agent: id })every run. Creating an agent per request accumulates orphaned agents. - Reach for it when the work is long-running, needs a workspace, or runs on a schedule, and you would rather not host a sandbox. Availability varies by cloud platform: Bedrock, Vertex, and Foundry use Claude API + tool use instead.
See anthropic for models, prompt caching, and effort.
2. xAI — Grok agents
- Scope: frontier reasoning plus a strong server-side agentic toolset, where xAI runs the tool loop for you. The current flagship is
grok-4.7(500k context). xAI recommends its Responses API and marks Chat Completions as deprecated. Thexai-sdk(gRPC) below is unaffected. - Install & a client-side tool (you run the tool):
# pip install xai-sdk (1.20.0, Python 3.10+)
import json
from pydantic import BaseModel, Field
from xai_sdk import Client
from xai_sdk.chat import system, user, tool, tool_result
client = Client() # reads XAI_API_KEY
class WeatherReq(BaseModel):
city: str = Field(description="City name")
def get_weather(city: str) -> str:
return f"Sunny, 26°C in {city}"
chat = client.chat.create(
model="grok-4.7",
messages=[system("You are a helpful assistant.")],
tools=[tool(name="get_weather", description="Current weather for a city.",
parameters=WeatherReq.model_json_schema())],
)
chat.append(user("Weather in Nairobi?"))
resp = chat.sample()
chat.append(resp)
for tc in resp.tool_calls: # the model asked to call a tool
args = json.loads(tc.function.arguments)
chat.append(tool_result(get_weather(**args), tool_call_id=tc.id)) # tool_call_id optional
print(chat.sample().content) # final answer after the tool result- Server-side tools (xAI runs the loop): pass
web_search(),x_search(),code_execution(),collections_search(),image_generation(), ormcp(...)intotools=.mcp()takesserver_url,server_label(prefixes tool names),allowed_tool_names(an allowlist),authorization, andextra_headers.
from xai_sdk.tools import web_search, code_execution, mcp
chat = client.chat.create(model="grok-4.7", tools=[
web_search(), code_execution(),
mcp(server_url="https://mcp.example.com", server_label="mpesa",
allowed_tool_names=["mpesa_status"], authorization="Bearer TOKEN"),
])- Gotchas: server-side tools are billed per call on top of tokens (
web_searchandcode_executionare $5 per 1k calls). Parallel tool calls are on by default, so resolve them all before the next request. KeepXAI_API_KEYserver-side. For a TypeScript Grok agent on the AI SDK (Responses API,store: false, cost metering), see grok-chatbot.
3. Microsoft — Agent Framework + VS Code agents
a) Build agents in code — Microsoft Agent Framework
The direct successor to Semantic Kernel and AutoGen (same teams). It is GA in Python (agent-framework 1.22.0, Python ≥3.10) and .NET (Microsoft.Agents.AI 1.25.0). Go is public preview (github.com/microsoft/agent-framework-go v0.1.1). It covers agents, functional and graph-based workflows, session state, middleware and telemetry, MCP, and a newer Harness Agent (planning, context compaction, file and memory access, tool approval).
# pip install agent-framework
from typing import Annotated
from pydantic import Field
from agent_framework import Agent, tool
from agent_framework.openai import OpenAIChatClient # or foundry.FoundryChatClient, anthropic.AnthropicClient
@tool(approval_mode="never_require") # read-only → no approval prompt
def get_weather(location: Annotated[str, Field(description="City name")]) -> str:
"""Get the weather for a location."""
return f"Sunny, 26°C in {location}"
agent = Agent(
client=OpenAIChatClient(),
name="SupportAgent",
instructions="You are codeAmani's Swahili-fluent support agent.",
tools=[get_weather],
)
result = await agent.run("Habari ya hali ya hewa Nairobi?")
print(result.text)- Providers: OpenAI, Foundry (
FoundryChatClient; prefer it over the olderagent-framework-azure-ai), Azure OpenAI, Ollama, and Anthropic (from agent_framework.anthropic import AnthropicClient). The Anthropic packageagent-framework-anthropicis still beta, so install it with--pre. A separateClaudeAgentwraps the Claude Agent SDK runtime. Since rc6 the model parameter ismodel=, notmodel_id=. Python doesn't auto-load.env, so callload_dotenv(). - MCP:
MCPStdioTool(local process),MCPStreamableHTTPTool(remote;static_headers/header_provider), andMCPWebsocketTool, passed intools=[...]. Hosted MCP is available viaclient.get_mcp_tool(...)on the Anthropic and Foundry clients. - .NET: the base type is
AIAgent.ChatClientAgentwraps anyIChatClient, andA2AAgent,CopilotStudioAgent,GitHubCopilotAgent, andDurableAIAgentderive from the same base. The Foundry, A2A, and CopilotStudio packages still ship as preview, so pin versions.
b) Drive an agent in the IDE — VS Code
VS Code's docs now say agents rather than "agent mode": pick the Agent (or the Plan agent) in the chat session controls. Enable MCP tools with the Configure Tools button, reference tools with # (e.g. #fetch), and invoke MCP prompts as /<server>.<prompt>.
// .vscode/mcp.json (top-level key is "servers"; .mcp.json files use "mcpServers")
{
"inputs": [
{ "type": "promptString", "id": "mpesa-token", "description": "M-Pesa tools token", "password": true }
],
"servers": {
"mpesa": {
"type": "stdio",
"command": "npx",
"args": ["-y", "mpesa-mcp"],
"env": { "MPESA_TOOLS_TOKEN": "${input:mpesa-token}" }
},
"github": { "type": "http", "url": "https://api.githubcopilot.com/mcp" }
}
}- Gotcha: never commit a token into
mcp.json. Useinputs(prompted, stored securely) orenvFile. Treat IDE agent tools like production access and require approval for file writes and shell.
4. Google — Agent Development Kit (ADK)
- Scope: an open, code-first agent toolkit, Gemini-optimised but model-agnostic, with graph workflows since ADK 2.0. SDKs: Python (
google-adk2.12.0, Python ≥3.11), TypeScript (@google/adk2.3.0), Go (google.golang.org/adk/v2), Java (com.google.adk:google-adk), and Kotlin (new). Docs moved to adk.dev. - Quickstart agent (the official one uses the
adk create/adk run/adk webCLI; a runner is shown for in-process use):
# pip install google-adk
from google.adk.agents import Agent
from google.adk.runners import InMemoryRunner
def get_weather(city: str) -> dict:
"""Current weather for a city. (the docstring is the tool's description)"""
return {"status": "success", "report": f"Sunny, 26°C in {city}"}
root_agent = Agent(
name="weather_agent",
model="gemini-flash-latest", # the string the official quickstart uses
description="Answers weather questions.",
instruction="Use the get_weather tool to answer.",
tools=[get_weather], # plain Python functions; docstring + type hints = schema
)
runner = InMemoryRunner(agent=root_agent, app_name="weather")- MCP wiring: the connection params live in the
mcp_session_managersubmodule:
from google.adk.tools.mcp_tool import McpToolset
from google.adk.tools.mcp_tool.mcp_session_manager import (
StdioConnectionParams, StreamableHTTPConnectionParams,
)
from mcp import StdioServerParameters
tools = [
McpToolset( # local server over stdio
connection_params=StdioConnectionParams(
server_params=StdioServerParameters(command="npx", args=["-y", "mpesa-mcp"]),
),
tool_filter=["mpesa_status"], # expose only what the agent needs
),
McpToolset( # remote server: prefer Streamable HTTP over SseConnectionParams
connection_params=StreamableHTTPConnectionParams(
url="https://mcp.example.com/mcp", headers={"Authorization": "Bearer TOKEN"},
),
),
]- Deploy: Google now calls the hosting product Agent Runtime on the Gemini Enterprise / Google Cloud Agent Platform (formerly Vertex AI Agent Engine; https://adk.dev/deploy/agent-runtime/). The CLI command is unchanged:
adk deploy agent_engine --project=… --region=… <agent_dir>. To route Gemini through Google Cloud, setGOOGLE_GENAI_USE_ENTERPRISE=TruewithGOOGLE_CLOUD_PROJECTandGOOGLE_CLOUD_LOCATION. The oldGOOGLE_GENAI_USE_VERTEXAIstill works as a legacy alias. - Memory:
VertexAiMemoryBankService(project=…, location=…, agent_engine_id=…)passed toRunner(memory_service=...). - A2A (agent-to-agent): expose an agent with
to_a2a(root_agent, port=8001)and consume one withRemoteA2aAgent(...). Marked experimental; Python, Go, and Java (not TypeScript). - Gotcha: ADK reads your function's docstring + type hints as the tool schema, so write them well. Region-pin for data residency (KDPA).
5. Vercel AI SDK — agents in a Next.js app
For codeAmani's Next.js apps, AI SDK 7 (ai 7.x) gives you a provider-agnostic agent class, so you can swap Claude, Grok, or Gemini without rewriting the loop. Full example: examples/agent-loop-vercel.ts.
import { ToolLoopAgent, isStepCount } from "ai";
import { anthropic } from "@ai-sdk/anthropic";
export const supportAgent = new ToolLoopAgent({
model: anthropic("claude-opus-5-5"),
instructions: "Answer from tools; never guess payment status.",
tools: { mpesaStatus }, // tool({ description, inputSchema, execute })
stopWhen: isStepCount(10),
});
const { text } = await supportAgent.generate({ prompt: "Is ws_CO_123 paid?" });Step limits differ by entry point, so always set stopWhen explicitly:
| Entry point | Default stop | Consequence if you forget |
|---|---|---|
generateText / streamText | isStepCount(1) | Stops after the first tool call and returns an empty answer |
ToolLoopAgent | isStepCount(20) | Logs a warning when it hits the cap |
WorkflowAgent (@ai-sdk/workflow) | none | Runs until the model stops calling tools |
WorkflowAgent is the durable variant. Each tool call is a workflow step with retries, the run survives a crash, and needsApproval tools suspend for a human and resume later. That is the right shape for an agent that must wait for an approval before an M-Pesa payout.
Choosing a stack
| Claude (Tool Runner / Agent SDK / Managed) | xAI Grok | MS Agent Framework | Google ADK | Vercel AI SDK | |
|---|---|---|---|---|---|
| Language | TS / Python (+ more SDKs) | Python / REST | Python / .NET / Go (preview) | Python / TS / Go / Java / Kotlin | TypeScript |
| Tools | functions, MCP, built-ins | client + server-side | functions + MCP | functions + MCP | functions (+ MCP adapter) |
| MCP | mcp_servers / Managed vaults | mcp() tool | MCPStdioTool / MCPStreamableHTTPTool | McpToolset | via MCP client |
| Hosting | your infra, or Anthropic (Managed) | xAI API | Azure / your infra | Agent Runtime / your infra | Vercel / your infra |
| Multi-agent | subagents, multi-agent sessions | DIY | graph + functional workflows | agent hierarchies, A2A | subagents, workflows |
| Best for | coding/ops agents, guardrails, hosted sandboxes | live web/X research | .NET/Azure shops | Gemini + GCP-native | Next.js apps, provider swaps |
Rule of thumb for codeAmani: Claude for anything agentic with real consequences (Tool Runner in apps, Agent SDK for ops, Managed Agents when you want Anthropic to host the sandbox); the AI SDK ToolLoopAgent in Next.js when provider portability matters; Grok for live web/X research; ADK when you're already on GCP/Gemini; Microsoft when the stack is .NET/Azure.
Capabilities & scope (what to expect)
- Tools: the agent's hands. Anything you can call from code can be a tool (HTTP, DB, M-Pesa, SMS). Keep each tool small, typed, and documented. The model chooses tools from their descriptions.
- Memory & state: short-term (the conversation) vs long-term (ADK Memory Bank, Managed Agents memory stores, a vector store — see pinecone/pgvector).
- Multi-agent: split work across specialised agents (planner → workers → reviewer). Every stack supports it; graph workflows (Microsoft, ADK 2.0) make the control flow explicit.
- Human-in-the-loop: gate risky actions behind approval (
can_use_tool,approval_mode, AI SDKneedsApprovalin aWorkflowAgent). Non-negotiable for anything that moves money or writes to prod. - What agents are bad at: unbounded loops (set step limits and cost caps) and silent failure (log every tool call + result, and handle
refusal/pause_turn).
codeAmani notes
- Secrets stay server-side. Model keys (
XAI_API_KEY,ANTHROPIC_API_KEY, Google ADC, Azure creds) and tool credentials live in Hazina / env managers (infisical), never in client code, prompts, or a committedmcp.json. MCP servers that touch money or PII run server-side only. - Allowlist + approve. Auto-approve only safe, read-only tools for unattended runs. In the Claude Agent SDK, remember that
allowed_toolsapproves rather than restricts, so also settools/disallowed_tools. Require human approval before any agent action that triggers an M-Pesa transfer, deletes data, or deploys. - Bound the loop. Cap steps (
max_iterations,max_turns,stopWhen) and spend (max_budget_usdin the Agent SDK; trackusageelsewhere). An agent in a tool loop can burn spend fast. Log every tool call + result for audit. - AI routing. House policy: complex reasoning/coding → Claude (
claude-opus-5-5default;claude-sonnet-5-5cheaper;claude-haiku-5-5for high-volume dispatch); GCP/Gemini-native + managed memory → ADK; live web/X research → Grok; structured/function-calling-heavy flows → whichever SDK fits the runtime. Build shared tools as MCP servers so the choice of agent stays swappable. - MCP hygiene. Target the 2026-07-28 spec for new servers: Streamable HTTP for remote, no reliance on sessions, Sampling, or Roots. Keep tools read-only by default and expose write tools behind a separate server you can leave unattached.
- African market. A Swahili-fluent support agent with an
mpesaMCP tool (check status, send receipt) is a high-leverage first build. Keep the callback + reconciliation idempotent (see daraja + webhooks), and region-pin hosted agents (africa-south1/europe-west1) for latency + residency. For the customer-facing WhatsApp side, see grok-chatbot.