Skip to content
AI Primer
release

Gemini API adds token budget caps for Managed Agents

Google added token budget caps and other controls for Managed Agents in the Gemini API. The release also adds sandbox hooks, cron triggers, model configuration, free-tier support, and Gemini 3.6 Flash defaults.

4 min read
Gemini API adds token budget caps for Managed Agents
Gemini API adds token budget caps for Managed Agents

TL;DR

  • Gemini Managed Agents now default to Gemini 3.6 Flash and expose model selection, with OfficialLoganK's update listing both changes.
  • Token caps landed for runaway-loop containment: _philschmid's launch thread names budget controls, and Google's launch post says max_total_tokens covers input, output, and thinking tokens.
  • Hooks can block, lint, or audit sandbox tool calls, with _philschmid's screenshot showing security-gate and auto-format hook groups.
  • Cron triggers now bind an agent, environment, prompt, and schedule into a persistent resource; _philschmid's feature list calls them remote cron-scheduled triggers.
  • REST/SSE is now the cleaner integration path for Interactions API work, while _philschmid's SDK follow-up says hookable fetch is not available in the SDK today.

Google's launch post says a run that hits max_total_tokens returns status: "incomplete" and keeps environment state for continuation. The hooks docs define two lifecycle events, pre_tool_execution and post_tool_execution, with command or HTTP handlers. The Triggers API reference exposes cron schedules and a budget_exceeded state, while _philschmid said in a reply about the Interactions API that GA replaced RPC quirks with standard REST + SSE.

Token budget caps

The new cap is max_total_tokens inside agent_config, according to Google's launch post. It applies to input, output, and thinking tokens.

When the cap is reached, the interaction returns status: "incomplete" and preserves environment state. Continuation uses previous_interaction_id with a fresh budget, and the Interactions API reference also lists budget_exceeded among interaction states.

Sandbox hooks

Hooks are configured with .agents/hooks.json and run inside the remote sandbox before or after tool execution, according to the hooks docs.

  • pre_tool_execution: runs before a tool call, can return {"decision":"allow"} or {"decision":"deny","reason":"..."}.
  • post_tool_execution: runs after a tool call, can format, test, log, or audit, but cannot block or undo the completed action.
  • matcher: uses regex matching for target tool names.
  • command handlers: run shell commands or scripts inside the sandbox.
  • http handlers: POST event JSON to an external HTTPS endpoint and expect a JSON decision.

Google's post says OffDeal uses a post_tool_execution hook for banker deck logo validation, including 30+ logos per deck, pixel-level quality checks, Gemini vision verification, and a manifest of approved files.

Model selection

The antigravity-preview-05-2026 managed agent now picks up Gemini 3.6 Flash automatically on the next interaction, with no code change, per Google's launch post.

agent_config.model can pin:

  • gemini-3.6-flash, the new default.
  • gemini-3.5-flash, the previous generation for general agentic workflows.
  • gemini-3.5-flash-lite, the lower-latency and lower-cost 3.5 option.

Cron triggers

Scheduled triggers bind four things into a persistent resource, according to Google's launch post:

  • agent
  • environment
  • prompt
  • cron schedule

Each run reuses the same sandbox, so files persist across executions. The Triggers API reference marks schedule as a required standard cron expression and also exposes max_total_tokens and max_consecutive_failures fields.

Free tier and environment cleanup

Managed agents now work in free-tier projects with an API key and no active billing, according to Google's launch post.

The same post says the Environments API can list, inspect, and delete sandbox sessions from code. Google framed two concrete uses: recovering environment IDs after a disconnect, and deleting sandboxes before the 7-day TTL.

REST and SSE Interactions API

The SDK does not have hookable fetch today, _philschmid said in a follow-up. The new Interactions API path is standard REST + SSE, with quickstart examples and an OpenAPI spec called out in the GA reply.

Google's getting started guide says the Interactions API is available through REST, Python, and JavaScript SDKs. REST responses return the full Interaction resource, including metadata, usage statistics, and step-by-step turn history, while SSE streaming emits incremental step.delta chunks.

Further reading

Discussion across the web

Where this story is being discussed, in original context.

On X· 5 threads
TL;DR1 post
Token budget caps1 post
Sandbox hooks2 posts
Model selection1 post
Cron triggers1 post
Share on X