﻿# Exa query, objective, and systemPrompt guide different stages

Assign Exa query, objective, systemPrompt, and outputSchema to their actual roles so retrieval intent, task context, and generated output do not become one opaque prompt.

Author: Retrivium editorial team
Updated: 2026-11-03
Canonical URL: https://retrivium.ai/journal/guide-exa-query-objective-systemprompt/
Language: en

## Separate the search turn from the whole task

An agent comparing database backup methods may issue a search about restoration constraints. Its current query should describe that immediate information need. The broader task still matters: the application needs material suitable for an operational comparison, not a general introduction. Keep those levels separate so the search request remains interpretable.

## Put the broader purpose in objective

Exa's [best-practices guide](https://exa.ai/docs/search/best-practices) defines `objective` as the task a search serves. It can explain the preferred document type and specific facts needed from results. A manual tool wrapper should preserve that field explicitly rather than pasting the entire agent transcript into `query`, where unrelated instructions can obscure the immediate retrieval target.

## Keep query focused on candidates

The [Search reference](https://exa.ai/docs/reference/search) defines the query and broader objective separately. For the backup example, the query can locate restoration documentation while objective explains the comparison's operational purpose. Store both values in the run record. This allows a reviewer to determine whether the wrong sources followed from a poor query or from a misunderstood larger goal.

## Guide synthesis with its own controls

The [quickstart](https://exa.ai/docs/search/quickstart) distinguishes `systemPrompt` instructions from `outputSchema` shape. Use those when requesting generated output, validating eligibility for the selected search mode. An instruction to emphasize recovery prerequisites is different from a schema requiring a prerequisites field; neither alone establishes that retrieval found supporting evidence for that field.

For a structured comparison, keep unknown prerequisites explicit. A polished response format cannot compensate for an absent source, and a detailed objective does not turn every preferred source into a hard allowlist. Apply documented request filters when candidate eligibility truly requires them.

## Diagnose one layer at a time

Freeze the candidate requirement while testing a revised objective, then separately test a revised output instruction. Inspect both retrieved pages and generated fields. If the same evidence yields a clearer explanation, the improvement concerns synthesis. If different authoritative pages are found, the retrieval change deserves its own analysis.

The local guides to [task contracts](/journal/learn-codex-task-contract/) and [progressive reading](/journal/learn-codex-progressive-reading/) help structure that separation. Keep small reviewed examples that fail at different layers. The resulting integration can explain which input needs correction without treating every unsuccessful answer as a reason to increase search depth or replace the model.
