Unified Search
Search across all entity types in a single call.
search
Search across all entity types (profiles, agent_playbooks, user_playbooks) in a single call. The server prepares the query, then retrieves the requested entity types.
Async applications can call await client.search_async(...) with the same
request fields and response model. It uses native async HTTP, applies the
client's total timeout, and preserves task cancellation.
By default, the server applies a five-second work budget to all HTTP search routes (/api/search, /api/search_profiles,
/api/search_user_playbooks, /api/search_agent_playbooks,
/api/search_interactions, /api/rerank_user_profiles) and
GET /api/storage_stats, including
authentication, billing checks, concurrency admission, retrieval and response preparation. If that
budget expires before the complete response is accepted, it returns HTTP 504 with detail: "Request timeout",
reason: "search_deadline" and a correlation_id; no partial results are returned.
The server work budget is REFLEXIO_SEARCH_TIMEOUT_SECONDS: finite nonnegative
seconds, default 5. Zero inherits the original HTTP backstop (normally 60
seconds, or the existing synchronous/wait budget). Positive values are also
capped by that backstop. Body buffering, authentication, dispatch and retrieval
share one server-arrival deadline. Expiry returns search_deadline when the work
budget wins or backstop_timeout when the HTTP budget wins, without partial results.
A successful response must enter finalization before the work deadline. After acceptance, durable exposure recording shares the remaining original HTTP budget, with no new clock. This intentionally replaces the former additional five-second commit window: an accepted response may wait longer for writes. Admission remains held until actual workers and cleanup finish; cooperative timeouts do not forcibly terminate threads or replace an accepted durable write with a late 504. Session deduplication, applied-learning metering and completion observers run only for accepted responses. A disconnect prevents callbacks that have not claimed execution; active callbacks may finish. Durable work does not guarantee that the client received the response. Client-to-server network time is additional.
Stalled worker capacity or total storage failure can return HTTP 503. Usable partial results remain 200 with degradation metadata; an empty successful result is distinct from unavailable storage. Embedded calls do not acquire this HTTP deadline.
REFLEXIO_SEARCH_DEADLINE_ENABLED is retired and rejected, including blank
assignments or those alongside the new setting. Preserve former true with
REFLEXIO_SEARCH_TIMEOUT_SECONDS=5, or former false with 0, then remove the old
assignment. Upgrade environment and image together: older images ignore the new
input. Timing and connection recovery remain active in every mode.
REFLEXIO_SEARCH_CONCURRENCY_TIMEOUT_SECONDS is also retired and rejected.
Remove its assignment and choose the total search budget; copying the old queue
value does not preserve the old independent queue/execution policy. The default
five-second total budget now also applies to direct search and profile reranking;
zero inherits each route's original HTTP backstop. Queued requests wake on
cancellation, without a separate queue timer. Budget expiry is 504 rather than an
early queue-only 429. Per-organization concurrency limits are unchanged.
When an agent playbook is returned, user_playbooks omits source user playbooks already represented by that agent playbook. The server does not refill suppressed user playbooks, so user_playbooks may contain fewer than top_k items.
response = client.search(
query="user preferences",
user_id="user_123",
session_id="session_001",
source="api",
top_k=5,
threshold=0.45,
tags=["preferences", "support"],
)curl -X POST "${REFLEXIO_URL:-https://www.reflexio.ai}/api/search" \
-H "User-Agent: my-agent-reflexio" \
-H "Authorization: Bearer $REFLEXIO_API_KEY" \
-H "Content-Type: application/json" \
--data @- <<'JSON'
{
"query": "user preferences",
"user_id": "user_123",
"session_id": "session_001",
"source": "api",
"top_k": 5,
"threshold": 0.45,
"tags": ["preferences", "support"]
}
JSON| Prop | Type | Default | Description |
|---|---|---|---|
query | str | — | Search query text |
top_k? | int | 5 | Maximum results per entity type, from 1 through 100. |
threshold? | float | model-specific | Similarity threshold for the vector arm. Omit it to use the embedding model's default. |
agent_version? | str | — | Filter by agent version (agent_playbooks, user_playbooks) |
playbook_name? | str | — | Filter by playbook name (agent_playbooks, user_playbooks) |
user_id? | str | — | Filter by user ID (profiles, user_playbooks) and identify the user for retrieval-experiment assignment. Required for agent traffic while an experiment is active. At most 255 characters. |
source? | str | — | Filter every selected entity type by exact source. Agent playbooks match when at least one linked source user playbook has that source. Omit, pass null, or pass an empty string to disable source filtering. |
request_id? | str | — | Optional caller correlation ID for the search turn. At most 255 characters. Published exposure evidence binds to the actual publish request; search does not persist exposure records. |
session_id? | str | — | Optional caller session ID for the search turn. At most 255 characters. Enables session-scoped result deduplication and binds a returned exposure receipt to this session; publish that receipt in the same session. |
interaction_id? | int | — | Optional positive integer (minimum 1) used to attribute served results to the caller interaction. |
tags? | list[str] | — | Match entities having any requested tag (OR semantics). Omit or pass an empty list to disable tag filtering. |
entity_types? | list[str] | — | Entity types to search. Valid values: "profiles", "user_playbooks", "agent_playbooks". When unset, all are searched. |
agent_playbook_status_filter? | list[PlaybookStatus | str] | — | Agent-playbook approval statuses to include |
enable_reformulation? | bool | false | Enable query reformulation for improved search results |
enable_agent_answer? | bool | false | Enable agentic answer synthesis when the configured search backend supports it |
conversation_history? | list[ConversationTurn] | — | Prior conversation turns for context-aware query reformulation |
search_mode? | SearchMode | str | — | Search mode: "vector", "fts", or "hybrid". Accepts SearchMode enum or string. When unset, the server uses its configured default ("hybrid"). |
Example:
# Basic unified search
response = client.search(query="response quality issues", session_id="session_001")
print(f"Profiles: {len(response.profiles)}")
print(f"Agent Playbooks: {len(response.agent_playbooks)}")
print(f"User Playbooks: {len(response.user_playbooks)}")
if response.reformulated_query:
print(f"Reformulated query: {response.reformulated_query}")
for profile in response.profiles:
print(f" Profile: {profile.content[:80]}...")
for playbook in response.agent_playbooks:
print(f" Playbook: {playbook.content[:80]}...")
# Search with filters
response = client.search(
query="handling edge cases",
session_id="session_002",
agent_version="v2.1.0",
tags=["reliability", "support"],
top_k=10,
threshold=0.4
)
# Search filtered by user
response = client.search(
query="product preferences",
user_id="user_123",
session_id="session_003",
top_k=5
)curl -X POST "${REFLEXIO_URL:-https://www.reflexio.ai}/api/search" \
-H "User-Agent: my-agent-reflexio" \
-H "Authorization: Bearer $REFLEXIO_API_KEY" \
-H "Content-Type: application/json" \
--data @- <<'JSON'
{
"query": "response quality issues",
"session_id": "session_001"
}
JSON
curl -X POST "${REFLEXIO_URL:-https://www.reflexio.ai}/api/search" \
-H "User-Agent: my-agent-reflexio" \
-H "Authorization: Bearer $REFLEXIO_API_KEY" \
-H "Content-Type: application/json" \
--data @- <<'JSON'
{
"query": "handling edge cases",
"session_id": "session_002",
"agent_version": "v2.1.0",
"tags": ["reliability", "support"],
"top_k": 10,
"threshold": 0.4
}
JSON
curl -X POST "${REFLEXIO_URL:-https://www.reflexio.ai}/api/search" \
-H "User-Agent: my-agent-reflexio" \
-H "Authorization: Bearer $REFLEXIO_API_KEY" \
-H "Content-Type: application/json" \
--data @- <<'JSON'
{
"query": "product preferences",
"user_id": "user_123",
"session_id": "session_003",
"top_k": 5
}
JSONPublished exposure receipts
Enterprise user-playbook search results may include an opaque exposure_receipt.
Preserve it with the matching user-playbook ID in the Assistant interaction’s
retrieved_learnings when publishing. The server records exposure atomically with
that interaction, using the version served by search. Search itself writes no
exposure ledger row. Claude-smart and OpenClaw preserve receipts automatically.
Missing or rejected receipts remain incomplete published evidence; they do not recover served-version fingerprints from the current playbook. Receipts describe client-declared published injections, not proof of actual causal use.