Extract Data With An Agent
This page covers schema-first extraction using GroundX Agent Harness: an agent drafts the YAML schema, creates the workflow, and helps you iterate. The underlying GroundX operations are the same ones documented in Extract Data from Documents.
Agent Harness is the promoted path for agent-driven extraction work, not a replacement for the direct SDK/API path. If you’re integrating extraction into your own application code rather than working through an agent, use Extract Data from Documents directly — this page adds an agent on top of the same workflow.
Start With The JSON You Want
Before writing anything, decide what JSON your application should get back. A utility statement, for example, might come back as:
Tell the agent what fields you need and where they should live in the response. The agent turns that into a schema — you don’t need to think in the schema format yourself.
Create One YAML File
The agent drafts a single YAML file that names the top-level JSON objects
(statement, service) and the values under each one (account_number,
due_date, total_amount_due, service_address). Each value gets a short
description, identifying labels, and instructions for reading it off the
document — GroundX uses this to find and extract the value.
The names you choose in the YAML are the names that come back in the JSON. To change the response shape, change the YAML names, not the document.
This is the same YAML format used in Extract Data from Documents — see that page for a full example file and field-level options.
Create Or Update The Workflow
Once the YAML looks right, the agent creates a GroundX workflow from it:
After changing the YAML, update the existing workflow instead of creating a new one:
Workflow updates send the full extraction settings, not a name-only patch — pass the YAML again whenever you want the custom settings to stay in effect. See Extract Data from Documents for the full set of create/update/load options.
Assign Before Ingest
This page assumes a bucket already exists — bucket_id below refers to that
bucket’s ID. If you don’t have one yet, see Create Or Select A
Bucket
for how to create one.
A workflow only runs on documents uploaded after it’s assigned. Assign the
workflow to the bucket, group, or account before you ingest anything — otherwise
get_extract has nothing to return.
Use client.workflows.add_to_account(...) instead when the workflow should be
the default for every bucket on the account.
Ingest And Poll
Upload a document to the assigned bucket with process_level="full" so GroundX
runs the workflow during ingest:
Ingest is asynchronous — don’t read the extraction until status reaches
complete.
Read The Extracted JSON
Once ingest completes, look up documents in the bucket, find the one whose
process_id matches, then request the extracted JSON:
The result uses the same names you chose in the YAML.
For chunk- or section-level custom workflow steps, get_extract can currently
return a 404 in some hosted environments even when the workflow ran correctly.
This is current platform behavior, not a sign the extraction failed; see Custom
workflow steps
for why.
Improve The Results
When a value is missing or wrong, change the smallest part of the YAML that explains the miss — not the whole schema.
The agent can compare the document against the extracted result, find which value’s description or instructions are too vague or don’t match how this document prints the value, and adjust just that part of the YAML. Then it updates the workflow, re-ingests, and reads the extraction again to confirm the fix.
Change one value at a time. If several values under the same top-level object are wrong, it’s often the shared instructions for that object that need adjusting rather than each value individually.
When To Use Agent Harness
An agent is useful throughout this loop, not just for the first draft:
- Drafting the initial schema from a plain description of what you need.
- Comparing the extracted JSON against expected values you provide, and telling you which fields matched and which didn’t.
- Inspecting the document and the extracted result together to explain why a value came back wrong or empty.
- Suggesting the smallest YAML change likely to fix a specific miss, rather than rewriting the schema from scratch.
The agent handles the schema iteration and the GroundX SDK calls shown above. How the harness turns a schema into a running workflow is internal implementation detail, documented separately in the GroundX Agent Harness project, not in this public guide.

