Apply to my task
arXiv:2602.05447 ★ 91 Feb 5, 2026

File-Native Context Engineering: How to Structure Knowledge for LLMs in Files

Key result

The finding: For strong models, giving files and search tools beat stuffing everything into the prompt — modestly. 9,649 experiments on SQL generation showed that frontier and frontier-lab models (Claude, GPT, Gemini) became +2.7 points more accurate on average when they looked up data in files via grep/read instead of reading it from the prompt. But for some open-source models, files hurt badly: Qwen lost 21.9 points and Llama Maverick 13.9. The trick: a navigable knowledge base instead of a monolithic context. You spread information across files (schema.yaml, rules.md, navigator.md) — the model finds the relevant chunk on its own and reads only that. It is meant to sidestep "lost in the middle" and keep the context small.

01

TL;DR

File-Native Context Engineering is a principle for organizing an LLM's context: instead of cramming everything into one prompt, you spread knowledge across files (data schemas, documentation, rules), and the model finds what it needs through file operations. The study tested this on SQL generation: 9,649 experiments, 11 models, 4 formats (YAML, Markdown, JSON, TOON), schemas from 10 to 10,000 tables. Two approaches were compared: File Agent (the model reads files on demand via grep/read) vs. Prompt Baseline (the entire database schema in the prompt up front).

The main finding torpedoes one-size-fits-all recipes: the file-based approach works differently for different models. Frontier and frontier-lab models (Claude, GPT, Gemini) were on average +2.7 points more accurate when they searched files instead of reading from the prompt (one of them, Gemini 2.5 Flash, was slightly worse with files). Open-source models showed mixed results: Kimi and Llama Scout performed about the same, DeepSeek lost 3.3 points, and Qwen and Llama Maverick fell flat with files, losing 21.9 and 13.9 points. The author's hypothesis: differing quality of tool-use training. Format did not significantly affect aggregate accuracy (YAML 75.4%, Markdown 74.9%, JSON 72.3%, TOON 72.3%), but it did affect efficiency: averaged over the 11 models, JSON, TOON and Markdown used 28-60% more tokens than YAML.

The method tackles scale through domain partitioning: instead of one file with 10,000 tables, several files of ~250 tables each (sales, customers, inventory). The model first figures out which domain holds the table it needs, then reads only that file. Navigation accuracy stayed high even at 10,000 tables (tested with Claude models only, on finding the right schema information rather than writing full SQL). An unexpected effect: the compact TOON format (~25% smaller file size) used 38% more tokens than YAML on average — a "grep tax". Each grep hit returns denser text, and some models don't know TOON's syntax, so they make extra search attempts: on a 1,000-table schema Claude Haiku used about 2.1x the tokens it needed with YAML, and in the worst case 16 grep attempts versus 3.

Want this for your own case? Apply this study to your task: AI adapts its method to what you are working on and writes the prompt.

02

Method Blueprint

File-Native Architecture (our adaptation for ChatGPT/Claude Projects; the paper tested agents with grep/read tools, not chat projects):

SETUP:
1. Structure your knowledge → files by topic/domain
   - schema.yaml — data structure
   - navigator.md — overview and descriptions
   - rules.md — business rules

2. Pick a format → YAML for compactness, MD for readability

3. Partition very large sets → files by domain (the paper's single files worked up to 1,000 tables; it partitioned 10,000 tables into ~250 per domain)

USING IT IN A CHAT:
1. Upload the files to a project/chat
2. Give a task → the model finds the right files on its own
3. The model reads only what's relevant → less "lost in the middle"

The paper recommends the file approach for frontier models (it tested Claude Opus 4.5, GPT-5.2, Gemini 2.5 Pro), the file approach with validation first for cheaper models from the same labs, and the whole schema in the prompt for open-source models.

03

Example

Our illustration, not an example from the paper.

Task: You run an online store with 300+ products across 15 categories. You need to answer questions about products, stock and specs quickly — but stuffing the whole catalog into the prompt is clunky.

Prepare the files:

catalog_navigator.md:

# Catalog navigator

## Structure
- electronics.yaml — electronics (smartphones, laptops, headphones)
- clothing.yaml — apparel (T-shirts, jeans, shoes)
- home.yaml — home goods (cookware, textiles, decor)
...

## How to search
If the question is about specs → look in the matching .yaml
If it's about stock → the stock_quantity field
If it's about prices → the price_usd field

electronics.yaml:

category: Electronics
tables:
  - name: smartphones
    description: Smartphones from all brands
    columns:
      - name: model
        type: string
        description: Phone model
      - name: price_usd
        type: integer
        description: Price in US dollars
      - name: stock_quantity
        type: integer
        description: Units in stock
      - name: ram_gb
        type: integer
        description: RAM in GB

  - name: laptops
    description: Laptops
    columns:
      - name: model
      - name: price_usd
      - name: processor
      - name: screen_inches

Upload the files to a project → ask your questions:

"Which smartphones with 8+ GB of RAM are in stock for under $500?"

Result: The model reads navigator.md → realizes it needs electronics.yaml → opens it → finds the smartphones table → reads its structure → returns results filtered by ram_gb ≥ 8, price_usd ≤ 500, stock_quantity > 0. Instead of processing all 300 products in the prompt, it read only the relevant chunk.

04

Why It Works

The LLM's weakness: "Lost in the middle" — models make worse use of information from the middle of a long context. This known effect (Liu et al.) is what motivates selective retrieval; the paper itself did not measure it. Cram a huge schema into the prompt and the model may miss the table it needs if it lands mid-list. Plus, a big context = lots of tokens = expensive and slow.

The LLM's strength: Frontier models are generally good at using tools (file read, search) — it's part of their training. They know how to break a task into steps: "find which file it's in → read the file → find what's needed in it → use it".

How the method exploits this: The file-native approach turns one big context into a navigable knowledge base. The model reads only what it needs right now. Navigator.md provides a map → the model orients itself → reads a specific file → gets the exact slice of data. That is meant to sidestep "lost in the middle" and keep the context small. But it depends on the model: some open-source models did much worse with files, which the author suspects reflects weaker tool-use training.

Control levers:

  • File granularity: one file for 10 domains vs. 10 files, one per domain → more files = more precise search, but more navigation steps
  • Format: YAML eats fewer tokens during retrieval (compact key-value), Markdown is friendlier for humans
  • Navigator.md: the more detailed the domain descriptions → the more accurately the model picks the file on the first try
  • Partition size: 50 vs. 500 objects per file → smaller partitions = less noise in each file, but more navigation steps
05

Prompt Template

File structure for file-native context:

1. Navigator file (navigator.md or _index.yaml):

# Navigator: {system name}

## Knowledge structure
- {file_1}.yaml — {what it contains}: {short description}
- {file_2}.yaml — {what it contains}: {short description}
...

## How to search
If the question is about {task_type_1} → look in {file_1}
If the question is about {task_type_2} → look in {file_2}

## Formats
All .yaml files use the structure:
{description of the data format}

2. Data files (YAML for compactness):

domain: {domain name}
description: {what it describes}

entities:
  - name: {entity name}
    description: {what it is}
    fields:
      - name: {field}
        type: {type}
        description: {what it means}
      - name: {field_2}
        type: {type}
        description: {what it means}

  - name: {entity_name_2}
    fields:
      ...

How to use it: 1. Create navigator.md — a map of all files 2. Split the data by domain/topic into separate .yaml/.md files 3. Upload all files to a ChatGPT Project / Claude Project / via file upload 4. Write your tasks — the model will find the right file through the navigator

Partitioning for large volumes (>500 objects): - Split by domain: ~250 objects per file - Give files descriptive names: sales_schema.yaml, customers_schema.yaml - In navigator.md, define clear domain boundaries

🚀 Quick start — paste into a chat with your files uploaded:

I have {description of the data/system}. Help me structure it in a file-native format:
1. Split it by domain (ideally ~250 objects per file)
2. Create a navigator.md with a map of the files
3. For each domain, create a .yaml file using the template above

My system: {description}

The model will ask about your data structure, relationships and how to split things up — because it needs to understand the domain boundaries to partition effectively. It'll take the template and build a structure for your data.

06

Limitations

⚠️ Model-specific: Some open-source models (Qwen 3 32B, Llama 4 Maverick) fall flat with the file-based approach and lose 22 and 14 points of accuracy. Always test on small data before scaling up. The frontier models tested (Claude Opus 4.5, GPT-5.2, Gemini 2.5 Pro) did best with files, but the gain was modest (a few points).

⚠️ Application domain: The study was tested on SQL generation — a structured, unambiguous task. For creative work where context = inspiration (write in author X's style), the effect may differ. We'd expect it to fit reference information best — schemas, documentation, rules, catalogs — but only database schemas were tested (TPC-DS).

⚠️ Grep tax for custom formats: If you use an unfamiliar format (not YAML/JSON/Markdown), some models spend more tokens searching because they don't know the patterns. TOON used 38% more tokens than YAML on average; for Claude Haiku the overhead grew to about 2.1x at 1,000 tables, while Claude Opus stayed around 1.4x.

⚠️ Platform barrier: The paper tested agents with grep/read tools; ChatGPT Projects, Claude Projects and API file search are our suggested equivalents, not tested setups. Doesn't work in a plain chat without file upload (you'll have to copy-paste).

07

How They Tested It

The team took TPC-DS — a standard database schema benchmark (24 tables, retail domain: customers, sales, inventory). They derived 100 SQL queries (20 per difficulty level) from TPC-DS query patterns, of varying difficulty: from simple (L1: "find a customer") to complex (L5: multi-step queries with subqueries and window functions). The model's job: generate correct SQL from a natural-language question.

They tested 11 models (Claude Opus 4.5 / Haiku 4.5, GPT-5.2 / GPT-5 mini, Gemini 2.5 Pro / Flash, DeepSeek V3.2, Kimi K2, Llama 4 Maverick / Scout, Qwen3 32B) in two modes: (1) File Agent — the model searches schema.yaml via grep/read, (2) Prompt Baseline — the whole schema in the prompt at once. Across 4 formats: YAML, Markdown, JSON, TOON. Scoring used Jaccard similarity of query results: if the model's result set overlapped the ground truth by at least 0.9, it's a success.

Why the results came out this way: The paper doesn't pin down the mechanism. Frontier models (+2.7 points with files on average) read only the relevant parts of the schema; whether that helped by avoiding "lost in the middle" wasn't measured. For open-source models the author hypothesises differences in tool-use training: Qwen lost 21.9 points and Llama Maverick 13.9 with files, DeepSeek 3.3, while Kimi and Llama Scout were about even. Model capability mattered most overall: a 21-point gap between frontier (86.0%) and open-source (64.6%) models, larger than any format or architecture effect.

The surprise: TOON (a compact format, ~25% smaller file) used 38% more tokens than YAML on average. The logic: each grep hit returns denser text, and some models don't know TOON syntax → they try DDL/JSON/YAML patterns → every failed attempt adds tokens. For Claude Haiku this grew with schema size (about 2.1x YAML at 1,000 tables; worst case 16 grep attempts versus 3), while Claude Opus stayed around 1.4x. With partitioning, there was no measurable growth in this tax up to 10,000 tables. Meanwhile, format didn't significantly affect aggregate accuracy — only efficiency (individual models, especially open-source ones, did have format preferences). This showed that file size ≠ runtime tokens: what matters isn't how compact the file is, but how familiar the patterns are for efficient search.

Practical insight: Don't optimize your format for file size — optimize for a grep-friendly structure. YAML won not because it's compact but because models know the patterns (tables:, columns:, name:). Scaling works not by shrinking the file but by partitioning: at 10,000 tables the schema was split into domains of ~250 tables with an index file, so the per-query context stayed bounded.

08

What the Files Looked Like (Our Reconstruction)

The paper does not print its schema or navigator files. It says the schemas were TPC-DS in four formats and that every format came with an identical navigator.md giving a schema overview and table descriptions. The two files below are our reconstruction of what such files look like, not the paper's originals.

YAML Schema Format (our illustration):

tables:
  - name: store_sales
    description: Sales transactions at physical stores
    columns:
      - name: ss_sold_date_sk
        type: integer
        description: Date key for sale transaction
      - name: ss_item_sk
        type: integer
        description: Item key, references item table
      - name: ss_customer_sk
        type: integer
        description: Customer key
      - name: ss_quantity
        type: integer
        description: Quantity sold
      - name: ss_sales_price
        type: decimal
        description: Price at which item was sold
    foreign_keys:
      - column: ss_sold_date_sk
        references: date_dim.d_date_sk
      - column: ss_item_sk
        references: item.i_item_sk
      - column: ss_customer_sk
        references: customer.c_customer_sk

  - name: customer
    description: Customer dimension
    columns:
      - name: c_customer_sk
        type: integer
        description: Customer surrogate key
      - name: c_current_addr_sk
        type: integer
        description: Current address key
      - name: c_first_name
        type: string
      - name: c_last_name
        type: string

Navigator.md structure (our illustration):

# Schema Navigator

## Overview
TPC-DS retail data warehouse schema with 24 tables across 4 domains:
- Sales (store_sales, web_sales, catalog_sales)
- Customers (customer, customer_address, customer_demographics)
- Items (item, warehouse, inventory)
- Time (date_dim, time_dim)

## How to search
For questions about:
- Sales transactions → store_sales, web_sales, catalog_sales
- Customer information → customer, customer_address
- Product details → item, warehouse
- Time periods → date_dim, time_dim

## Relationships
All sales tables link to:
- date_dim via *_sold_date_sk
- item via *_item_sk
- customer via *_customer_sk

Context: In the study, navigator.md was identical across all formats; only the format of the schema files changed. The author also advises investing in clear disambiguation rules in the navigator rather than in format tweaks.

09

Adaptations and Extrapolations

💡 Adaptation for business processes: Not just for database schemas — it applies to any structured knowledge.

Example: a customer support knowledge base

support_navigator.md:

# Support knowledge base

## Structure
- billing_rules.yaml — pricing rules, subscriptions, refunds
- technical_specs.yaml — product specs, compatibility
- common_issues.yaml — common problems and fixes
- escalation_rules.yaml — when to escalate to L2/L3

## How to search
If the question is about payment/refunds → billing_rules.yaml
If it's "it doesn't work" → common_issues.yaml, the section for that product
If it's about specs → technical_specs.yaml

common_issues.yaml:

product: iOS mobile app
issues:
  - symptom: "Push notifications aren't arriving"
    causes:
      - Turned off in iOS settings
      - Permission not granted on first launch
      - Beta version of the app
    solution: |
      1. Settings → {App name} → Notifications → turn on
      2. If that doesn't help → reinstall the app (it will ask for permission again)
      3. If beta → update to the stable version from the App Store
    escalate_if: "The problem persists after steps 1-3"

  - symptom: "The interface is laggy"
    causes:
      - iOS version below 15
      - Low storage on the device
    solution: |
      1. Check iOS: Settings → General → About
      2. If iOS 14 → suggest updating
      3. Check storage → Settings → General → Storage

Upload it to a project → the chat becomes L1 support with instant access to procedures.

🔧 Technique: partition by usage frequency → token optimization

Instead of partitioning only by domain, split into hot (frequently needed) and cold (rarely needed):

_index.yaml:

partitions:
  hot:
    file: frequent_queries.yaml
    description: The 20% of entities that show up in 80% of questions
    use_case: ["pricing", "availability", "top 10 products"]

  cold:
    file: full_catalog.yaml
    description: Full catalog for rare queries
    use_case: ["niche specs", "rare categories"]

Expected effect (our idea, not tested in the paper): most queries read only the hot file (smaller, more relevant) → fewer tokens → faster → cheaper. Fall back to cold only if nothing turns up in hot.

💡 Extrapolation: combine with Chain-of-Thought for complex queries

Task: {a complex query that needs data from several domains}

Step 1: Decomposition
Break the task into subtasks. For each subtask, determine which files are needed.

Step 2: Navigation
For each file:
- Read the navigator.md section about this file
- Find the needed entity via grep
- Read only the relevant section

Step 3: Synthesis
Combine the data from all sources and answer the original question.

Available files: {list from navigator.md}

This combines file-native retrieval with explicit reasoning — for tasks where you need to pull data from 3+ domains.

10

Resources

Structured Context Engineering for File-Native Agentic Systems: Evaluating Schema Accuracy, Format Effectiveness, and Multi-File Navigation at Scale (2026)

  • TPC-DS Benchmark: https://www.tpc.org/tpcds/
  • Model Context Protocol: https://modelcontextprotocol.io/
  • TOON Format: https://toonformat.dev/
  • Spider Benchmark (text-to-SQL): arXiv:1809.08887
  • "Lost in the Middle" (Liu et al., 2024): arXiv:2307.03172
  • Context Engineering Survey (Mei et al., 2025): arXiv:2507.13334

Author: Damon McMillan, HxAI Australia

Research digest

Key result

The finding: For strong models, giving files and search tools beat stuffing everything into the prompt — modestly. 9,649 experiments on SQL generation showed that frontier and frontier-lab models (Claude, GPT, Gemini) became +2.7 points more accurate on average when they looked up data in files via grep/read instead of reading it from the prompt. But for some open-source models, files hurt badly: Qwen lost 21.9 points and Llama Maverick 13.9. The trick: a navigable knowledge base instead of a monolithic context. You spread information across files (schema.yaml, rules.md, navigator.md) — the model finds the relevant chunk on its own and reads only that. It is meant to sidestep "lost in the middle" and keep the context small.

Principle

Instead of "everything in one prompt" → a structure of files by domain. Navigator.md provides a map ("electronics here, apparel there"); the model checks the map → understands where to look → reads a specific file → gets only the relevant part. For 10,000 tables, not one file but partitions of ~250 tables plus an index file (sales, customers, inventory). The model picks the domain first, then reads the file. It's like a library with a catalog — you don't flip through every book, you go to the right room.

Why it works

Frontier models are trained for tool use — they know how to break a task into steps (find the file → read it → extract what's needed). Targeted reading keeps the context small — instead of 10k tables in the prompt, the model works with a ~250-table domain. JSON, TOON and Markdown used 28-60% more tokens than YAML during retrieval (11-model average) — YAML's compact key-value lines return less text per grep hit. But there's a catch: the custom TOON format (~25% more compact by file size) used 38% more tokens than YAML on average, and for Claude Haiku about 2.1x at 1,000 tables. Its lines are denser, and some models don't know its syntax and make extra grep attempts — the "grep tax". Some open-source models lose a lot with files (Qwen -21.9 points), likely due to weaker tool-use training (the author's hypothesis) — the paper recommends giving them everything in the prompt.

When to apply

Reference information where navigation accuracy matters: data schemas, API documentation, product catalogs, company knowledge bases. Most useful when the volume is large — for small sets it's simpler to put it in the prompt (our rule of thumb; the paper only tested database schemas). Our suggested equivalents for chat use: ChatGPT Projects, Claude Projects, APIs with file search (the paper tested agents with grep/read tools). NOT a fit for creative tasks where the whole context = inspiration (an author's style, atmosphere). And for open-source models results were mixed: some did much worse with files, so the paper recommends the whole schema in the prompt for them.

Mini recipe

1. Create navigator.md: a map of all files describing what lives where. Example: `electronics.yaml — smartphones, laptops, headphones | clothing.yaml — T-shirts, jeans, shoes` 2. Split the data by domain: in the paper, single files worked fine up to 1,000 tables; at 10,000 it used domains of ~250 tables each. Split as soon as one file gets unwieldy 3. Pick a format: YAML if saving tokens matters, Markdown if people will read the files. DON'T use custom formats (grep tax) 4. .yaml file structure: ```yaml domain: Name entities: - name: entity fields: - name: field type: type description: what it means ``` 5. Upload the files to a project (ChatGPT/Claude Projects) → write your tasks, the model will find what it needs 6. Test on small data if you're using an open-source model

Examples

[BAD]: `I run an online store with 300 products in 15 categories. Here's the full catalog: [copy-paste of every product with specs]. Find smartphones with 8 GB of RAM under $500` [GOOD]: You create files: - `navigator.md` (a map of categories) - `electronics.yaml` (smartphones, laptops with fields model, ram_gb, price_usd, stock) - `clothing.yaml`, `home.yaml`... Upload them to a project → write: `Which smartphones with 8+ GB of RAM are in stock under $500?` The model reads the navigator → understands it needs electronics.yaml → opens it → finds the smartphones table → filters by ram_gb ≥ 8, price_usd ≤ 500, stock > 0. It read 50 products instead of 300.

In plain words

The gist of File-Native Context Engineering is that we stop force-feeding the model giant walls of text and start treating it like a normal employee. Instead of making the model memorize a ten-thousand-table database schema, we give it navigation tools and access to a file system. The model no longer tries to keep everything in its head — it just goes and "reads" the right file when a specific question comes up. It's a fundamental shift: we move from bloated prompts to agentic logic, where the AI decides for itself which part of the documentation to study right now.

It's the difference between a student who tries to memorize the entire library before an exam and a pro who knows which shelf holds the right reference book. The first one will inevitably stumble on the details, get lost in the middle of the list and spit out muddled nonsense. The second simply opens the right page and gives a precise answer. A study of 9,649 experiments found that this works for the strongest models: with files they were a few points more accurate than with the whole schema in the prompt. But it is not a free win — several open-source models did clearly better with everything in the prompt.

The paper tested 11 models and found out what actually matters. It turns out that the model itself matters most: strong and weak models were 21 points apart, far more than any format or setup effect. The format (YAML, Markdown, JSON) did not significantly change accuracy overall, but YAML was the cheapest in tokens. When an AI agent searches with grep and the schema is split by domain, it still finds the right tables even at 10,000 tables. The key insight: a clear hierarchy, obvious names and a good index file help the machine find its way.

Everything was tested on SQL and databases, but the idea is worth trying elsewhere. It could help with complex projects, whether it's support for an online store with thousands of products or a huge corporation's knowledge base. Instead of paying for massive context windows and waiting forever while the model digests megabytes of text, you simply sort the info into folders. SEO for documents inside the system becomes more important than the text itself, because now we're optimizing content for the AI agent's "eyes".

Bottom line: the "stuff everything into the prompt" era officially ended when databases outgrew the kiddie sandbox. The future belongs to structured context and models that know how to use files. If your knowledge base is large and you use a strong model, split it into files, add navigation and give the agent search tools. With a weaker open-source model, test first — the whole thing in the prompt may still work better.

AI lab assistant

Apply this study to your task

Describe what you're working on. AI takes the method and the measured results from this paper and adapts them to your case, or writes a ready prompt built on them.

Based on File-Native Context Engineering: How to Structure Knowledge for LLMs in Files arXiv:2602.05447

Sign in to apply this study New accounts get 50 free credits.