Gemini API Managed Agents: 3.6 Flash, Hooks, and Serverless Agent Orchestration
Teaser: Google's Gemini API now runs managed agents — persistent, stateful AI agents deployed as serverless endpoints with built-in tool execution, memory, and lifecycle hooks. This article breaks down the architecture, the new 3.6 Flash support, the five hook points, and when managed agents beat hand-rolled orchestration.
Introduction
In July 2026, Google expanded Gemini API Managed Agents with support for the 3.6 Flash model and a new lifecycle hooks system. The feature set represents Google's push to make agent deployment as simple as API deployment: define your agent, its tools, and its behaviour — Google runs the orchestration loop, manages state, and scales it serverlessly.
Managed agents differ from the DIY approach (LangChain + a vector store + a queue worker) in one fundamental way: the orchestration loop — planning, tool calling, memory retrieval, retry, and multi-turn state — runs on Google's infrastructure, not yours. For teams that want agent capabilities without the operational burden, this is a significant shift.
This article examines the managed agent architecture, the 3.6 Flash integration, the hook system for extending behaviour, and the decision framework for choosing between managed and self-hosted agents.
What Is a Managed Agent?
A managed agent is a stateful, tool-using AI application deployed as an API endpoint. You define:
- Agent configuration — system prompt, model, temperature, memory settings
- Tool definitions — function schemas the agent can call (OpenAPI or JSON Schema)
- Webhooks — URLs Google calls for state transitions
Google then provides a single REST endpoint that maintains conversation state across requests, executes tools on your behalf (via your webhook endpoints), retrieves from the agent's built-in memory, and handles retries and error recovery.
graph LR
subgraph Your App
A[Application]
B[Tool Webhooks]
C[Memory Store]
end
subgraph Google Infrastructure
D[Managed Agent API]
E[Orchestration Loop]
F[3.6 Flash Model]
G[Agent State]
H[Hooks]
end
A -->|"sessions.create()"| D
D --> E
E -->|"LLM calls"| F
E -->|"tool.execute()"| B
E -->|"persist"| G
E -->|"on_event"| H
H -->|"notify"| A
classDef google fill:#4285F4,stroke:#2c5f8a,color:#fff
classDef yours fill:#54A24B,stroke:#3a7a35,color:#fff
class D,E,F,G,H google
class A,B,C yours
The New 3.6 Flash Support
The headline addition is Gemini 3.6 Flash as a managed agent model:
| Feature | 3.6 Flash (new) | 3.5 Pro (previous) |
|---|---|---|
| Context window | 128K tokens | 1M tokens |
| Tool calling | Native, parallel | Native, parallel |
| Max output | 32K tokens | 32K tokens |
| Reasoning | On-demand (thinking budget) | Always-on |
| Latency (P50) | 380ms | 1.2s |
| Price per 1K in | $0.10 | $0.35 |
| Price per 1K out | $0.40 | $1.75 |
3.6 Flash is the default model for new managed agents. The lower latency and cost make it viable for high-frequency agent workloads — customer support triage, code review bots, and operational assistants — where 3.5 Pro's always-on reasoning was too slow and expensive.
The model supports on-demand reasoning: you can set a thinking_budget parameter to enable chain-of-thought only for complex turns:
{
"agentId": "support-triage",
"model": "gemini-3.6-flash",
"thinking_budget": 2048,
"systemInstruction": "You triage support tickets. Classify into: billing, technical, account. Assign priority. Do not solve issues."
}
Agent Lifecycle
Managed agents have an explicit lifecycle with configurable persistence:
sequenceDiagram
participant App as Application
participant API as Managed Agent API
participant Model as 3.6 Flash
participant Mem as Agent Memory
participant Hook as Webhooks
App->>API: POST /sessions
API-->>App: {sessionId}
App->>API: POST /sessions/{id}/messages
API->>Mem: Load conversation context
Mem-->>API: Prior turns + entities
API->>Model: generate (context + tools)
Model-->>API: tool_calls: [search_kb]
API->>Hook: POST /hooks/on_tool_call
Hook-->>API: {result: [...]}
API->>Model: generate (tool results)
Model-->>API: final response
API->>Mem: Persist updated state
API-->>App: {response}
API->>Hook: POST /hooks/on_turn_complete (async)
The Five Hook Points
The new hooks system gives you control over five lifecycle events:
| Hook | Trigger | Use Case | Payload |
|---|---|---|---|
on_session_created | New session starts | Enrich context, user identity lookup | session metadata |
on_tool_call | Agent invokes a tool | Execute tool, return results | tool name, args |
on_guardrail | Guardrail rule triggered | Custom safety policy, human escalation | rule, context |
on_turn_complete | Turn finished | Logging, analytics, notifications | tokens, duration, tool calls |
on_session_expired | TTL reached or idle timeout | Cleanup, archival, billing | session stats |
Tool Execution via on_tool_call
The most important hook is on_tool_call, which is how the agent executes tools on your infrastructure:
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route("/hooks/on_tool_call", methods=["POST"])
def handle_tool_call():
payload = request.json
tool = payload["tool"]["name"]
if tool == "search_knowledge_graph":
results = query_neo4j(
cypher=payload["tool"]["args"]["cypher"]
)
return jsonify({
"status": "success",
"result": results
})
if tool == "get_ticket_details":
ticket_id = payload["tool"]["args"]["ticketId"]
return jsonify({
"status": "success",
"result": fetch_ticket(ticket_id)
})
return jsonify({"status": "error", "error": f"Unknown tool: {tool}"}), 400
Guardrails via on_guardrail
Guardrails let you intercept agent behaviour before it reaches the user:
{
"guardrails": [
{
"name": "pii-redaction",
"trigger": "on_output",
"rules": ["email_regex", "credit_card_luhn"],
"action": "redact"
},
{
"name": "topic-restriction",
"trigger": "on_input",
"rules": ["medical_advice_blocklist"],
"action": "block_and_notify"
}
]
}
When a guardrail triggers, Google calls your on_guardrail webhook with the rule context. Your hook can allow, block, redact, or escalate — including pausing the session for human review.
Built-in Memory
Managed agents include built-in memory, configurable by scope:
| Memory Scope | Persistence | Use Case |
|---|---|---|
session | Conversation lifetime | Chat context, no cross-session |
user | Per-end-user, cross-session | Personalisation, preferences |
agent | Global across all users | Shared knowledge, learned policies |
Memory is structured — the agent stores entities, preferences, and facts, not raw transcripts:
{
"memory": {
"user_1234": {
"facts": [
{"key": "preferred_language", "value": "German", "confidence": 0.95},
{"key": "account_tier", "value": "enterprise", "confidence": 0.99}
],
"entities": ["acme-corp", "project-aurora"],
"recent_topics": ["graph-database-migration", "cypher-optimization"]
}
}
}
You can read and write memory directly via the API, or disable it entirely for stateless agents.
Managed vs. Self-Hosted: Decision Framework
| Criterion | Managed Agent (Gemini API) | Self-Hosted (LangGraph, CrewAI) |
|---|---|---|
| Orchestration infra | ✅ Google-managed, serverless | ❌ You operate (K8s, workers) |
| Time to first agent | Minutes | Days |
| State management | ✅ Built-in, versioned | ⚠️ Your design |
| Tool execution | Webhooks (external) | In-process functions |
| Model choice | Gemini only (3.6 Flash/Pro) | Any (OpenAI, Claude, local) |
| Data residency | Google regions | Your control (EU, on-prem) |
| Cost model | Per-token + memory | Infra + model |
| Lock-in | High (Google ecosystem) | Low (portable) |
| Custom memory schema | ⚠️ Fixed scopes | ✅ Full control (Neo4j, Postgres) |
| Digital sovereignty | ❌ Third-party processing | ✅ Full self-hosting possible |
For graphwiz.ai's digital sovereignty audience, the trade-off matters: managed agents trade control and data residency for operational simplicity. The built-in memory (simple key-value facts) cannot replace a full knowledge graph memory layer — but you can bridge both by using on_tool_call to query your own Neo4j-backed memory as a tool.
Getting Started
# Install SDK
npm install @google/genai
# Create a managed agent
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });
const agent = await ai.agents.create({
displayName: "graph-support-agent",
model: "gemini-3.6-flash",
systemInstruction: "You help users with knowledge graph questions.",
tools: [
{
functionDeclarations: [{
name: "search_knowledge_graph",
description: "Query the Neo4j knowledge graph",
parameters: {
type: "object",
properties: {
cypher: { type: "string", description: "Cypher query" }
},
required: ["cypher"]
}
}]
}
],
webhooks: {
onToolCall: "https://api.yourdomain.com/hooks/on_tool_call",
onTurnComplete: "https://api.yourdomain.com/hooks/on_turn_complete"
}
});
// Send a message
const session = await ai.sessions.create({ agent: agent.id });
const response = await ai.sessions.sendMessage(session.id, {
message: "Which customers have contracts expiring this quarter?"
});
Limitations
| Limitation | Details |
|---|---|
| Model lock-in | Gemini models only — no BYO-LLM for the orchestration brain |
| Webhook latency | Every tool call adds an HTTPS round-trip (~100–300ms overhead) |
| Memory granularity | Fixed scopes and simple fact/entity model; no custom schema or graph queries |
| Region availability | Agent endpoints in us-central1, europe-west4, asia-northeast1 |
| Idle timeout | Sessions expire after 24h idle (configurable TTL, max 7 days) |
Conclusion
Gemini API Managed Agents represent the "agents as a service" direction of the platform: Google runs the orchestration loop so you don't have to. With 3.6 Flash, the cost/latency profile finally makes managed agents attractive for production-scale workloads, and the hooks system provides enough extension points for real applications — tool execution on your infra, custom guardrails, and lifecycle observability.
The decision between managed and self-hosted agents is now a legitimate architecture choice rather than a capability question. For teams already on Google Cloud with Gemini-native requirements, managed agents remove an entire class of operational complexity. For teams with strict data-residency or sovereignty requirements — the core audience of this site — the hooks architecture means you can still keep your knowledge graph, tools, and sensitive logic on your own infrastructure while delegating only the orchestration.
Docs: Gemini API Managed Agents (July 2026).