Skip to main content

Gemini file slicing: selective context for agents

Google added native file slicing to the Gemini API so an agent can inspect specific parts of documents, spreadsheets, audio, and video without loading the whole file on every turn. The opportunity is not only lower token usage: it is separating discovery, authorization, detailed reading, and evidence so context becomes measurable, reproducible, and revocable.

Gemini APIMultimodal contextDocument agentsInference costs
Wasyra Lab
AI systems and operations architecture
Published
min read
7 min read
Categoría
AI Systems
5controls for governing document context
A multimodal archive passes through a selection aperture that keeps only relevant pages, cells, audio, and video with their provenance.

Chapter 01

What changes with native file slicing?

Context stops being a whole block attached to every request and becomes an explicit decision about which evidence the model may see on each turn.

Gemini native file slicing lets a team upload a file once and request only pages, cell ranges, or audio and video intervals in each interaction. For a product team, the important change is architectural: the agent can explore with an inexpensive representation, locate likely evidence, and enlarge only the fragment it needs. That reduces irrelevant context, but it also creates a control point where the system can record what was read, why it was read, and under which permission. A sound design separates five controls: slice selection, source authorization, the evidence packet, answer evaluation, and a fallback when the slice is insufficient. The model should not choose context without boundaries, and the backend should not assume that fewer tokens mean higher accuracy. The useful promise is an auditable route from the original file to the final claim, with a repeatable read and a way to expand scope when evidence is incomplete.

Google announced the capability on November 23, 2026, one America/Lima calendar day before this publication. According to the announcement, the API can select document pages and layers, spreadsheet tabs and visible ranges, and audio or video intervals and layers. Billing applies to the parts Gemini inspects. This is a platform capability, not evidence that every document agent will be more accurate or cheaper in production: those outcomes depend on the corpus, the selection controller, reread frequency, and the model being used.

Chapter 02

The slice is a contract, not an invisible optimization

A serious pipeline should preserve two distinct objects. The first is the original file, identified by URI, hash, version, owner, and access policy. The second is a context request declaring modality, range, resolution, layers, and purpose. For example, reading text from every page to locate a table is a different operation from rendering page 18 at high resolution to interpret its footnotes. If both actions remain hidden inside a prompt, the team loses the ability to explain costs, reproduce an answer, or revoke access to a source.

Defaults are also part of the contract. The announcement says that when processing options are omitted, documents and slides use layout-preserving page images, while spreadsheets include evaluated values, formulas, and sheet names. A convenient default may be too broad for sensitive information or unnecessarily expensive for a simple lookup. Teams should declare layers positively and reject ambiguous requests in regulated workflows instead of relying on implicit provider behavior.

Explicit decisions by modality before sending context to the model.
SourceMinimum selectionRisk to watch
PDF or presentationPages, text or image layer, and resolutionLosing layout, notes, or cross-page context
SpreadsheetSheet, visible range, data, formulas, and visualsConfusing a displayed value with its formula or unit
Audio or videoInterval, transcript, audio, frames, fps, and resolutionExcluding the moment that changes the meaning

Chapter 03

How do you design the skim, zoom, and evidence loop?

Consider a hypothetical example: an agent prepares a note for a procurement committee from a 140-page contract, a pricing workbook, and a negotiation recording. In the skim phase, it extracts contract text and the audio transcript with broad scope and low resolution. Its output is not a final answer but structured candidates: pages 42–45, cells D18:H24, and minutes 31:20–34:10, each with a reason and confidence. A deterministic controller validates that those resources belong to the case and that the user may read them before requesting detail.

In the zoom phase, the system requests images of the selected pages, values and formulas from the range, and audio plus frames from the interval. It then builds an immutable evidence packet with the source URI, version, exact slice, timestamp, model, and digest of the processed content. The generator answers only from that packet and returns references the interface can open. If it finds a contradiction—for example, the contract limits a discount that the workbook applies—it should not average it away or hide it: it should request a neighboring slice or escalate to human review.

This pattern does not require a single model. A fast model can propose candidates while a more capable one interprets tables or exceptions. What should remain stable across providers is the slice contract and evidence packet. That makes quality and cost comparable without rewriting the entire document workflow, and it prevents an API migration from silently changing what data the agent sees.

Chapter 04

How do you evaluate a context controller?

Do not evaluate only the final answer. Build a frozen set where each case has authorized sources, required slices, distractor slices, expected claims, and abstention conditions. Run two layers: slice retrieval and evidence-grounded generation. The first measures whether the controller included sufficient fragments and avoided prohibited ones; the second measures faithfulness, coverage, citations, and contradiction handling. Separating them reveals whether an answer failed because the model reasoned poorly or because it never received the correct page.

Record at least slice precision and recall, inspected tokens per accepted answer, expansion count, latency to sufficient evidence, and scope violations. The important denominator is an evaluator-accepted answer, not a completed API call. A token reduction accompanied by more omissions or more human reviews is not efficiency. Use shadow traffic before changing defaults, compare against the whole-file pipeline, and stratify results by modality, size, and document complexity.

  • Test neighboring slices and references that cross pages, sheets, or time boundaries.
  • Include updated files to test versioning and cache invalidation.
  • Measure abstention when permission or evidence prevents task completion.
Optimize tokens per accepted answer, not tokens per call. The second metric can improve while the product gets worse.

Chapter 05

Five limits that context savings do not solve

First, a slice can exclude the exception that changes the conclusion. Second, text extraction can lose diagrams, footnotes, or spatial relationships. Third, a workbook requires the system to distinguish formulas, evaluated values, units, and hidden cells. Fourth, a file may contain malicious instructions: selecting less content reduces surface area, but it does not eliminate prompt injection. Fifth, uploading once and reusing a URI requires retention, deletion, residency, and revocation policies consistent with the document's classification.

The defense is a combination of technical boundaries and product rules. The backend enforces maximum ranges, allowed sources, and authorized layers; the model may propose, but it cannot expand privileges. The system marks file content as untrusted data, separates instructions from evidence, and blocks write tools during reading. The interface shows source and scope, lets the reviewer open the fragment, and provides a path to expand context or correct the selection. Logs should retain enough identifiers and digests for audit without indiscriminately copying sensitive content.

The cover is a conceptual illustration of the selection flow; it is not a Gemini screenshot or a measured result.

Chapter 06

Adopt the capability when you can explain every fragment

File slicing deserves a pilot if your agent currently resends whole documents, runs local tools only to cut files, or cannot attribute a claim to a page, cell, or interval. Start with one modality and one high-volume task, keep the whole-file pipeline as a control, and define the accepted improvement in advance: lower cost per approved answer, lower latency without coverage loss, or better data isolation. Do not generalize from a clean-PDF demo to contracts, workbooks, and video without separate tests.

The final decision should record five pieces: who selects, who authorizes, which evidence is retained, how it is evaluated, and when the system expands or aborts. If your team needs to turn multimodal files into a verifiable AI workflow, Wasyra can help design the context contract, evaluation harness, and operations without coupling the product to a single provider.

FAQ

Frequently asked questions

Does file slicing automatically improve accuracy?

No. It reduces irrelevant context and can improve attribution, but an incorrect slice can exclude necessary evidence. It must be evaluated against whole-file loading on domain cases.

What should the evidence packet retain?

Source URI and version, exact slice, layers, resolution, timestamp, model, digest, and references that let a person open the reviewed fragment.

How should real savings be measured?

Use tokens and latency per accepted answer, including expansions, retries, and human review. Measuring only tokens per call can hide coverage loss.

Written by

Wasyra Lab

AI systems and operations architecture

Wasyra Lab publishes practical frameworks for designing AI agents, automations, and operating flows that survive production.

AI AgentsGuardrailsOperations
More from this author

Series

AI systems that actually reach production

A series on agents, copilots, and guardrails for bringing AI into real work without breaking trust or operations.

Posts in this series

Keep reading

Keep reading