Gemini 4 for Coding Agents: Models, Usage Limits and When to Run a Swarm

Gemini 4 in practice, with a checklist for models, usage limits and agent safety.
TL;DR

Choose a Gemini 4 model for your next coding task, identify which quota stopped a run, and fix Drive access with a one-document check.

A coding agent stops halfway through a refactor. Gemini says it can’t open the Google Doc with the requirements. Your API dashboard still shows headroom. Those three things can happen at the same time because Gemini Apps, Google Antigravity and the Gemini API track different kinds of usage and access. Start with the tool that displayed the warning. Google’s Gemini Apps limits · Antigravity plans · Gemini API rate limits

Start here

  • Choosing a model? Try Hydrogen on tightly specified edits and Neon on a real multi-file task. Evaluate Argon or Carbon when a difficult task justifies a second run.
  • Near a limit? Check the Gemini app notice, Antigravity’s usage panel or AI Studio’s rate-limit dashboard, depending on where the work stopped.
  • Missing a Drive file? Open it with the same Google account, then ask Gemini for that one document by name.
  • Adding more agents? Give each one a clear assignment, restrict its tools and decide who can approve a merge.

Which Gemini 4 model should you use?

Google lists four Gemini 4 models. Each has a unified context window of 1,048,576 tokens in the Gemini API. Input and output share that space. The Gemini app has its own context limits by plan, and Antigravity has its own model availability. Gemini API model catalog · Gemini Apps limits · Antigravity model selector

Click any column to sort
4 rows
HydrogenUpdate a dependency, add a test for specified behavior or write a small script with a clear expected result. Hydrogen model reference
NeonImplement a feature that spans application code, tests and documentation. Start with a task whose acceptance tests you can check yourself. Neon model reference
ArgonCompare two migration plans or trace a difficult bug across services. Google positions Argon as a frontier reasoning model that responds faster and uses fewer tokens per turn than Carbon on the workloads it describes. Argon model reference
CarbonTry a long investigation with several competing explanations or a repository-wide change with hard-to-preserve behavior. Carbon model reference

A large context window gives you room for relevant files, tests and logs. Start with the failing test and the code paths it exercises. Include a decision record if it settles a disputed requirement. Expand the file list when the agent can name what evidence it still needs. Pristren’s context engineering guide

What thinking and caching do to the bill

For a Gemini API workflow, try the lowest supported thinking level that consistently passes your checks. On supported models, Google documents higher latency and token use at xhigh. A practical comparison is to run the same issue at two thinking levels and record whether the extra reasoning saves a retry or changes the outcome. Gemini API thinking guide

Google lists a 4,096-token minimum for implicit caching across the four Gemini 4 models. Put repeated material, such as stable instructions and the same repository notes, near the start of the request. Put the new task and changing logs after it. Then check cached-token counts in the response usage metadata. The prefix improves your chances of a hit, and the discount applies to the tokens the service actually reports as cached. Gemini API caching guide

Here’s what that changes for one hypothetical standard Neon request. With 100,000 input tokens, 80,000 of them cached, and 5,000 billable output tokens including thinking, the token charge is about $0.15. With the same output and no cache hit, it is about $0.38. Tool fees and later calls are additional. Check the live price table before budgeting a rollout. Gemini Developer API pricing

Gemini 4 vs. Claude and ChatGPT for coding

If you’re choosing a coding agent, compare Antigravity, Claude Code and Codex on the work you do. A chatbot comparison answers a different question. The agent harness, which supplies tools and manages the run, affects how each model searches files, edits code and invokes tests. Artificial Analysis publishes which benchmark version and agent variant it evaluated. Google’s Neon evaluation likewise identifies the provider harnesses used for its SWE-sweep comparison. Artificial Analysis Coding Agent Index methodology · Gemini 4 Neon evaluation methodology

Google’s Neon report shows how the answer varies with the benchmark. On Terminal-Bench 4.1, it reports 65.2% for Neon, 65.8% for Claude Opus 5.5 and 61.5% for GPT-6.2 Sol. On SWE-sweep, Neon’s score was 39.0% with Google’s provider harness and 12.8% with Mini-SWE. These are published evaluation results. Use the harness-specific numbers to decide what to test on your own project. Google DeepMind’s Gemini 4 Neon evaluation

A terminal score is useful if your agent spends the day building and testing in a shell. For a checkout flow, you’ll also want to see how the agent handles loading, validation and failure states in the browser. When you read a leaderboard, look for the exact model, benchmark version, harness, effort setting and time budget before comparing rows. Terminal-Bench 4.1 · Pristren’s SWE-bench guide

A three-task comparison you can run on your repository

  1. Fix a bug. Supply an existing failure and a test that reproduces it. Count a pass only if the regression test and relevant existing tests pass.
  2. Change a user flow. Supply a screen and its expected loading, empty and error states. Review each state and record what you had to correct.
  3. Explain a refactor. Ask for a read-only plan naming the files, invariants and verification steps. Check whether the plan would preserve existing behavior.

Start each tool from the same commit and fix the time and retry budget. Record elapsed time, retries, tests passed, review minutes and API cost where metered. If a fast patch needs substantial cleanup, the review minutes will show it. For a copyable acceptance-criteria format, see Pristren’s executable specification guide.

Gemini usage limits depend on where you’re working

Where you ran the taskWhat to check first
Gemini AppsRead the in-app notice and check the plan’s limits. Google says prompt complexity, long chats, large files and features such as Deep Research affect consumption. Gemini Apps usage documentation
AntigravityOpen the usage panel or run /usage in the CLI. Google shows five-hour and weekly balances where applicable. Check the balance for your model group. Antigravity CLI overview · CLI usage command
Gemini APIIn AI Studio, check the project and model against the metric that failed. Request, token and daily limits can apply independently. Reduce concurrency for repeated rate-limit errors, and set retry and spending limits in your own job runner. Gemini API rate limits

Start a fresh Gemini app chat when the topic changes. If the next task depends on the previous one, carry over a short handoff with the goal, the decisions already made and the files still needed. In Antigravity, use one agent for work concentrated in a single package and reserve parallel workers for tasks they can make progress on independently. Gemini Apps usage documentation · Antigravity Swarm documentation

How to fix Gemini’s Google Drive access

Try one ordinary Google Doc you already have permission to open. This makes it easier to tell whether you’re dealing with an account mismatch, a missing connection or a problem with one particular file.

  1. Check the account and file. Open the document directly in Drive with the same Google account you’re using in Gemini. If the link asks you to request access, resolve that with the owner first.
  2. Check Connected Apps. On a personal account, Google’s Workspace connection instructions list Keep Activity as a requirement. Review the activity setting before enabling it. On a work or school account, a qualifying edition and administrator settings determine whether the connection is available.
  3. Name the file in a new chat. Type @, choose Google Drive if it appears, and give the exact title plus a distinctive keyword. Ask Gemini to summarize one section and open the source it cites to verify it.
  4. Narrow down the failure. If a second Google Doc works, check the first file’s type and sharing. Google’s Drive integration documentation excludes pictures and videos stored in Drive. If Drive is missing from the picker on a managed account, ask the Workspace administrator to check Connected Apps and Keep Activity.

Google’s personal-account instructions · Google’s work and school instructions

Antigravity Orchestrator vs. Swarm

Orchestrator pairs a planner with a faster executor in one conversation. That fits a change where implementation depends on the previous step, such as changing a validation rule and updating its callers. Google’s model selector shows which planner and executor are available to your account. Antigravity Orchestrator documentation

Swarm gives parallel workers a coordinator and a shared board. That fits a change where one worker can update documentation, another can check behavior with existing tests and a reviewer can verify the final diff against the spec. The feature is in preview. Google says workers share the workspace by default, separate working copies are available, and active workers consume quota faster than a single conversation. Decide who owns each file before giving workers write access. Antigravity Swarm documentation

For a custom workflow, give each handoff an artifact the next agent can verify, such as a test report, a patch or a decision record. Use LangGraph when you want explicit state and resumable steps, Google ADK for Gemini-oriented workflows with sequential and parallel components, CrewAI for role-based task delegation, or Pydantic AI when typed outputs are central to how your Python agents pass results. LangGraph documentation · Google ADK documentation · CrewAI documentation · Pydantic AI multi-agent guide

MCP connects an AI application to tools and data. A2A lets agents exchange messages and delegate work across implementations. For example, a review agent could read the test results through MCP and send its review to a separate release agent over A2A. A2A and MCP documentation

For examples of what the tool can do outside a repository, see Pristren’s Antigravity workflow guide.

A safety checklist for coding agents

A document, issue comment or tool result can contain instructions that try to redirect an agent. OWASP calls this indirect prompt injection. When an agent reads external content and can also modify files, use credentials or send data elsewhere, enforce permissions at the tool boundary. OWASP AI Agent Security Cheat Sheet

  • Limit what each worker can do. A reviewer can read the diff and run approved checks. Keep publishing, deployment and production credentials behind separate permissions.
  • Isolate the runtime. Use a disposable, restricted runner for untrusted inputs. A separate Git worktree helps keep edits organized. Set filesystem, credential and network restrictions in the runner itself.
  • Approve high-impact actions. Validate tool arguments outside the model. Show the exact diff, destination or resource before a human approves a merge, deployment or external write.
  • Set stopping conditions. Cap worker count, run time and retries. Log tool calls and approvals so you can see what happened when a worker stalls or produces an unexpected request.

OWASP agent security guidance · Pristren’s MCP authorization guide

Start with one task you can verify from end to end. Add a stronger model when reasoning is the bottleneck, add parallel workers when independent work is waiting, and keep the final approval with someone who can read the evidence.

Frequently Asked Questions

Do all Gemini 4 models have a million-token context window?

Google lists a unified 1,048,576-token input and output window for Hydrogen, Neon, Argon and Carbon in the Gemini API. Gemini Apps has separate limits by plan.

Does the Antigravity five-hour quota apply to the Gemini API?

Antigravity quota and Gemini API rate limits are separate. Check Antigravity’s usage panel for its five-hour and weekly windows, and AI Studio for your API project’s model-specific limits.

Can every Antigravity Swarm worker edit a separate copy?

Workers share the workspace by default. The coordinator can assign separate working copies when several workers need to make changes.

Does a 95% cached-input discount reduce the whole bill by 95%?

The discount applies to input tokens the API reports as cached. Uncached input, billable output and tool charges are calculated separately.

#gemini-4#google-antigravity#ai-coding-agents#agent-security

One AI engineering post, weekly

LLM benchmarks, prompt techniques, and token-cost breakdowns, delivered to your inbox.

What should we test or explain next?

Comments

Have a question or something to add? Sign in to join the discussion.

Mahmudul Haque Qudrati — CEO & Founder · Lead AI/ML Engineer at Pristren

Mahmudul Haque Qudrati

CEO & Founder · Lead AI/ML Engineer

Software architect, full-stack engineer, and machine learning practitioner. Founder & CEO of Pristren, CTO at Venture Kick-backed PIN Sport Application GmbH (Basel, Switzerland), Software Development Lead at DailyFrame GmbH (building Dimetra patient transport software), and creator of Zlyqor. Focused on custom workflow automation, scalable web and mobile applications, and production AI/ML systems.