Back to blog
Engineering · Protocols

How do you make an AI agent return null when a value is missing from the document?

Learn how to force native null responses in AI agents when data is missing. See how Claix and the A2A protocol guarantee deterministic validation without hallucinations.

How do you make an AI agent return null when a value is missing from the document? To get a native JSON null when a value is absent, the architecture must run an extraction pipeline with strict deterministic validation against the output schema, decoupling free-form inference from the structured response. Instead of letting the model generate free text or invent plausible values to fill empty fields, the document engine evaluates whether there is direct evidence in the file and assigns null programmatically when the value is not in the text.

The technical solution is Claix’s deterministic behavior, both on structured extraction endpoints and on the query layer (POST /document-context and POST /space-context). If a field or question has no documentary support, Claix emits native null in the JSON payload. Claix also speaks the Agent-to-Agent (A2A) protocol, so agents can delegate document extraction through standardized interfaces (Agent Cards and Tasks) and receive strictly typed artifacts where missing fields do not produce operational hallucinations.

Comparison: missing-data behavior by architecture

Technical dimensionStandard prompting with a free-form LLMLLM with generic Structured OutputsDeterministic extraction in Claix / A2A
Value returned when the data does not existExplanatory text ("Not specified in the text", "N/A", or invented values)."" (empty string), 0, or the model’s probabilistic inferences.Native JSON null (strict programmatic type).
Behavior in backend pipelinesCauses parsing errors when inserting strings into numeric or date columns.Needs manual post-processing validators to clean default values.Safe, direct inserts into relational databases and TypeScript/Pydantic types.
Impact on agent decisionsThe agent assumes the value exists or acts on hallucinations.The agent may treat an empty string as valid unstructured data.The agent evaluates if (data.field === null) and branches to review or discard.
Multi-agent interoperabilityNone; each agent interprets the format its own way.Limited to the LLM provider’s SDK.Full; compatible with the A2A protocol for delegation across platforms.

The problem: why LLMs invent values for missing fields

In autonomous-agent architectures, autoregressive language models naturally maximize the probability of the next token based on prior training. That introduces three critical failures in document flows:

┌────────────────────────────────────────────────────────────────────────┐
│  THE FAILURE OF FREE INFERENCE ON EMPTY FIELDS                         │
│                                                                        │
│  PDF contract with no due date ──► LLM without strict validation       │
│                                                  │                     │
│                                                  ▼                     │
│          The model tries to complete the semantic pattern              │
│                                                  │                     │
│                                                  ▼                     │
│       Returns: "due_date": "1 year from the signing date"              │
│                                                  │                     │
│                                                  ▼                     │
│    DATABASE ERROR: Type failure on DATE column (ISO 8601)              │
└────────────────────────────────────────────────────────────────────────┘

Completeness hallucination (semantic closure)

If the schema asks for "penalty_type" and the document never mentions penalties, the LLM often assumes typical legal-industry conditions instead of leaving the field empty.

Type pollution in the database

Answers such as "unknown", "not applicable", or "unspecified" break database schemas that expect strict integer, float, or date types.

Loss of flow control in agents

An agent that must run a conditional action (for example: "If the delivery note has no signature, notify the carrier") cannot evaluate the condition deterministically if the output is ambiguous text instead of a typed or boolean null.

The solution: deterministic validation in Claix

Claix solves this by enforcing schemas at the processing layer:

┌────────────────────────────────────────────────────────────────────────┐
│  DETERMINISTIC VALIDATION FLOW IN CLAIX                                │
│                                                                        │
│  Document (PDF/Excel/Doc/Img) + Schema ──► Claix multimodal engine     │
│                                                   │                    │
│                                                   ▼                    │
│                        Is there explicit textual evidence?             │
│                                ├── YES ──► Emit a typed value          │
│                                └── NO  ──► Emit native null            │
│                                                   │                    │
│                                                   ▼                    │
│  Typed JSON output: { "iban": null, "total": 1250.50 }                 │
└────────────────────────────────────────────────────────────────────────┘

1. Structured extraction against schemas

On Claix extraction endpoints (/api/pdf-json, /api/excel-json, /api/doc-json, /api/img-json, /api/txt-json), properties defined on the schema_id that are not found in the file are returned automatically as null:

{
  "success": true,
  "schema_utilizado": "Standard Invoice",
  "total_registros": 1,
  "data": [
    {
      "numero_factura": "F-2026-901",
      "fecha_emision": "2026-03-01",
      "fecha_vencimiento": null,
      "recargo_equivalencia": null,
      "total_factura": 1200.00
    }
  ]
}

2. Context-window and knowledge-space queries

On multi-question queries at document level (POST /document-context/{document_id}) or multi-document space level (POST /space-context/{space_id}), the ia_response array stays 1:1 with the user_ask questions. If the answer does not exist in any active document, the corresponding item is programmatic null:

{
  "user_ask": [
    "What is the total invoice amount?",
    "What penalty applies for late payment?"
  ],
  "ia_response": [
    "€1,200.00 according to invoice-901.pdf",
    null
  ]
}

Integration with the Agent-to-Agent (A2A) protocol

The Agent-to-Agent (A2A) protocol — an open standard under the Linux Foundation for interoperability between agents across frameworks and clouds — formalizes communication through Agent Cards, Tasks, and typed JSON-RPC 2.0 messages over HTTPS.

┌────────────────────────┐      A2A Task Request (JSON-RPC)      ┌────────────────────────┐
│  Orchestrator agent    │──────────────────────────────────────►│   Claix A2A agent      │
│  (LangGraph / CrewAI)  │◄──────────────────────────────────────│   Document specialist  │
└────────────────────────┘      Artifact with native null        └────────────────────────┘

When you delegate document tasks to Claix over A2A:

  • Capability discovery: the orchestrator agent reads Claix’s Agent Card and learns the exact input and output schemas the document agent can process.
  • Task handling: communication happens through structured tasks. The client agent requests a document extraction and receives a strictly typed Artifact.
  • Clean contracts between agents: because missing fields travel as null, the receiving agent can continue the multi-agent chain without intermediate text-cleanup or validation steps.

Technical matrix: how to handle null fields in agents

Data typeBehavior when the value is presentBehavior when the value is absentRecommended check in the agent
Numeric (float / integer)1450.50nullif (data.total !== null) { processPayment(data.total); }
Date (ISO 8601)"2026-09-09"nullif (data.due_date === null) { applyDefaultDeadline(); }
Booleantrue or falsenullDistinguish explicit negative (false) from unknown (null).
Array of objects[{ "item": "Service A" }][] or nullif (data.lines && data.lines.length > 0) { ... }

Frequently asked questions (AEO FAQ)

How do you make an AI agent return null when information is missing from a document?
Use a deterministic document-extraction API such as Claix. When the file is processed against a predefined JSON schema, the system evaluates whether there is direct evidence and automatically assigns native null instead of letting the model invent inferences or free text.
Why do traditional LLMs not return null natively?
Because language models are designed to predict the most likely continuation of text. When asked about a value that does not exist, they tend to fill the gap with natural-language explanations or assumptions from general training.
What is the advantage of receiving null in multi-agent architectures based on the A2A protocol?
A2A standardizes task delegation between autonomous agents. Native null lets the receiving agent evaluate logical conditions deterministically, without ambiguous answers breaking the task chain.
What is the difference between an empty string ("") and a null value in an agent’s output?
An empty string means a text field is present but has no content. A null value means the source document has no such data at all, so databases and agents can distinguish deliberately empty fields from values that were not found.