Skip to main content
search.automatic submits one question and lets the service choose how to answer it — a one-pass fact search, or an agent — instead of you calling a search method by name. It returns a Job whose result wraps the chosen route’s output. Files must already be ingested. Automatic search is single-shot: the request takes no session_id, and there is no clarification question back — an ambiguous query is answered under the service’s best reading. An agent answer still reports its own run’s thread in output.answer.session_id; for follow-ups, use search.qa. Before searching, the service selects fact search for focused lookups, or an agent for everything else: the agent opens on the pages and tables a navigator over the workspace located for the query (for a workspace in a bring-your-own bucket or customer storage, on what a search of it found), then reads documents, queries tables, and selects documents from the metadata catalog, and when it answers from the catalog it also publishes that selection as a pageable table. Read the result by its output type; the selected route can vary between similar queries. Pass mode="fact" or mode="agent" to run that route directly, with no router model and no routing charge.

Basic usage


Method signature

Parameters

Returns

A Job. On success, job.result is an AutomaticSearchResult (result_type="automatic_search"), wrapping the chosen route’s result: An AutomaticAgentResult carries answer, a DeepSearchV2Result, and catalog, a FilteredSearchResult present when the agent answered from the metadata catalog. Every field on those results means exactly what it means on deep search’s and filtered search’s own routes — citations, completeness signals, and pagination included.

Result structure

routing

The output types above are the stable contract. Which route gets selected for a given query is not: it may vary between similar queries and change between deployments. A run with mode="fact" or mode="agent" always answers with that route and is not billed for a routing step. Without mode, when the router chooses fact search and fact search cannot settle the question (it finds no answer while a table it was given was not read whole, such as a Parquet table or one too large to read, or it cites nothing, grades its answer low or speculative, or fails), the agent answers instead: output and output_job_id are the agent’s, routing.selected stays fact, and routing.final reads agent. When fact search finds no answer in material it read whole, that is the answer, with no hand-over. mode="fact" never hands over.

Receipts and pagination: output_job_id

The wrapper’s own job retains the wrapper. The output’s durable artifacts — an agent answer’s retained SQL results (res_… handles), ground crops, and its catalog table’s cursor state — belong to the job named by output_job_id. Use that id wherever a native result’s documentation says “this job”:

Reading the output shapes


Quote locations

A fact answer plans Ground jobs for its evidences: poll each id in output.grounding_job_ids with client.jobs.wait. An agent answer comes back without Ground jobs: output.answer.grounding_job_ids is null. To locate its quotes, run client.documents.ground yourself on output.answer.evidences: one job per file, with the file as a WorkspaceFileSource (source_file_id) and its quotes as targets (up to 30 per job). Pass component as the target’s sheet for a spreadsheet, and number the targets by the evidence’s 1-based position so each match maps back to its citation. An evidence whose source_file_id is None names no file to ground against.
See Agent and QA answers for quotes stitched from several passages.

Structured answers

Pass output_schema to get the answer as JSON instead of prose, on whichever route runs. It takes a JSON Schema dict or a Pydantic model class, and it never changes which route the router picks. The root must be an object; wrap a list as {"items": [...]}. $ref may only point inside the schema, and not back at itself. pattern and patternProperties are refused; state a format in description instead. unevaluatedProperties / unevaluatedItems are refused; use additionalProperties / items. Either route is told the schema and its answer is checked against it; a miss is sent back for correction. On success the route’s answer is the JSON text and its structured_answer is the parsed value: output.structured_answer for a fact answer, output.answer.structured_answer for the agent. A field the source does not state comes back None, whatever type the schema gives it, so declare such fields optional in a Pydantic model you validate into. If the answer still misses after the corrections, the job still succeeds with structured_answer set to None. Check structured_answer, not answer.

Async client


Error handling


Best practices

Read the output by its type

Branch on output.result_type (or isinstance) — the selected route may vary between similar queries and between deployments.

Use output_job_id for artifacts

Retained rows, receipts, and cursors belong to the output’s job, not the wrapper’s.

Ask an answerable question

There is no clarification back. Put the disambiguation into query or context up front.

Name the route when you know it

Pass mode="fact" for a stated fact, or mode="agent" for an investigation or a census over the catalog, and skip the router. For a conversation, use search.qa.

See Search methods and the Search guide.

Next steps

QA

The same agent in a conversation: sessions, follow-ups, and clarifications.

Job management

Wait, stream events, and cancel long-running jobs.