AI Search Quickstart for Coding Agents
Configure a Search Profile, query tenant records with a coding agent and the Contextual CLI, and check the evidence behind an answer.
Use a coding agent and the Contextual CLI to search your tenant records and explain the matching evidence. Follow this guide to prepare a small sample dataset, configure a Search Profile, run a search, and compare the answer with a known source record.
Before You Start
You need:
- A tenant with AI Search available, permission to configure a Search Profile, and permission to create and read records in the source Object Type. Creating the example Object Type also requires permission to create Object Types.
- Contextual CLI 0.17.0 or later.
- A coding agent that can run shell commands in an environment where
ctxlis onPATHand your tenant sign-in is available.
Follow Install and Sign In to install the CLI and sign in to your tenant. This walkthrough uses CLI configuration ID my-config; replace it with your configuration ID. Complete sign-in yourself before asking your coding agent to run commands.
Choose CLI or Console for each setup task below. The example uses Object Type ID equipment-articles and profile ID equipment-help. Choose unused IDs; if you change them, update the commands and profile configuration to match.
Prepare the Example Records
The synthetic data for this quickstart uses fictional equipment troubleshooting articles. Prepare an Object Type with the fields title, category, symptom, and resolution. Use three records with distinct topics:
| ID | Title | Category | Symptom | Resolution |
|---|---|---|---|---|
pump-will-not-start |
Pump will not start | Pumps | The pump makes no sound when started. | Check the power supply and reset the overload protection. |
pump-low-flow |
Pump has low flow | Pumps | The pump runs but delivers little water. | Check the inlet strainer for blockage. |
conveyor-stops |
Conveyor stops intermittently | Conveyors | The conveyor stops during operation. | Inspect the emergency-stop circuit and motor protection. |
Use id as the primary key. The searchable fields are strings; symptom is optional.
Save this single-line Object Type definition as equipment-articles.jsonl:
{"id":"equipment-articles","type":"custom","objectType":"internal","name":"Equipment Article","pluralName":"Equipment Articles","display":"default","defaultListStyle":"table","schema":{"primaryKey":"id","type":"object","properties":{"id":{"type":"string"},"title":{"type":"string"},"category":{"type":"string"},"symptom":{"type":"string"},"resolution":{"type":"string"}},"required":["id","title","category","resolution"]}}
Create the Object Type in the selected tenant:
ctxl types add \
--input-file equipment-articles.jsonl \
--config-id my-config \
--pretty
Save these three records as equipment-records.jsonl, one object per line:
{"id":"pump-will-not-start","title":"Pump will not start","category":"Pumps","symptom":"The pump makes no sound when started.","resolution":"Check the power supply and reset the overload protection."}
{"id":"pump-low-flow","title":"Pump has low flow","category":"Pumps","symptom":"The pump runs but delivers little water.","resolution":"Check the inlet strainer for blockage."}
{"id":"conveyor-stops","title":"Conveyor stops intermittently","category":"Conveyors","symptom":"The conveyor stops during operation.","resolution":"Inspect the emergency-stop circuit and motor protection."}
Create the records:
ctxl records add \
--type equipment-articles \
--input-file equipment-records.jsonl \
--config-id my-config \
--pretty
These commands create the Object Type and its three records. Keep the returned record IDs for the result check.
- Follow Creating an Object Type. Use ID
equipment-articlesand display name Equipment Article. - Use this Data Schema, then complete creation:
{
"primaryKey": "id",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"title": {
"type": "string"
},
"category": {
"type": "string"
},
"symptom": {
"type": "string"
},
"resolution": {
"type": "string"
}
},
"required": [
"id",
"title",
"category",
"resolution"
]
}
- Open the Object Type's records in the console and create the three records from the table above, including their
idvalues.
Save the records and note their IDs.
1. Create the Search Profile
Both paths create profile equipment-help over equipment-articles, with named Search Index default. Creating the profile starts indexing its source records. See Create and Manage Search Profiles for profile configuration guidance.
Save this single-line configuration as equipment-help.jsonl:
{"id":"equipment-help","name":"Equipment Help","source":{"kind":"native-object","objectType":"equipment-articles"},"template":{"language":"handlebars","body":"Title: {{title}}\nCategory: {{category}}\n{{#if symptom}}Symptom: {{symptom}}{{/if}}\nResolution: {{resolution}}"},"chunking":{"splitterId":"plain-text-window","size":1600,"overlap":10,"preserveBoundaries":true},"embedding":{"model":"voyage-4","dimensions":1024},"projections":[],"indexes":[{"id":"default","name":"Default","mode":"hybrid","topK":10,"oneResultPerDocument":true,"filters":[],"rerank":{"enabled":false,"scope":"document"}}]}
The configuration includes the source Object Type, body template, chunking, embedding settings, and named index. The chunking.overlap value 10 means 10% overlap.
Create and save the complete profile with one command:
ctxl aisearch profiles add \
--input-file equipment-help.jsonl \
--config-id my-config \
--pretty
A successful create response confirms that the profile was saved. Check indexing progress in the next step before searching.
In the left sidebar, under Connect, select AI Search, then select New profile. Under Identity, set Profile ID to equipment-help and Name to Equipment Help. Under Source, select equipment-articles as the Source object type. Leave Query predicate (optional) empty to include all three records.
Under Template, use this Body:
Title: {{title}}
Category: {{category}}
{{#if symptom}}Symptom: {{symptom}}{{/if}}
Resolution: {{resolution}}
Leave Header (optional) empty. Use these initial settings:
| Setting | Value |
|---|---|
| Chunking → Splitter | Plain-text window |
| Chunking → Size (characters) | 1,600 |
| Chunking → Overlap (%) | 10 |
| Strict windows (not recommended) | Unchecked, preserving boundaries |
| Embedding → Model | voyage-4 |
| Embedding → Dimensions | 1,024 |
| Projections | None |
Under Indexes, select Add index. Set Index ID to default, Name to Default, Mode to hybrid, and Top K to 10. Turn One result per document on and leave Rerank disabled. Leave Static filters empty.
Optional: inspect the template preview. Check that the preview uses a real sample record, labeled sample record: with a record ID. See Template and chunk preview. If it shows field placeholders, it has not demonstrated rendering against your data. Confirm that the rendered text includes the symptom and resolution, with readable labels. Check a record with optional fields missing as well. An ID for a referenced record does not provide the referenced record's descriptive text.
Use the rendered header and body to check the text that will be indexed. Chunking happens at index time. Previewing does not index records or establish search readiness.
In the bar at the bottom, select Create profile to save the profile and start indexing.
See Search Concepts and Configuration for the meaning of each setting.
2. Check Indexing Progress
Read the reported build and repair progress:
ctxl aisearch profiles progress equipment-help \
--config-id my-config \
--pretty
Each call returns a snapshot of reported progress. Run it again to check for updates. Wait for the initial build to complete, and inspect any reported record failures before running the search below.
The profile page opens with the status Indexing. Wait for the status card to show Ready. Inspect Record errors and any progress warnings before running the search below; see Read Index Status. A warning about missing recent progress does not change the index status or establish that the build failed.
Confirm the expected record is searchable with a query. Progress reports and a Ready status alone do not prove every record is current. See Keep Search Up to Date.
3. Query With Your Coding Agent
Give your coding agent this command. It must run in the same environment where you installed the CLI and signed in:
ctxl aisearch query "The pump is running but barely moving water." \
--profile equipment-help \
--index default \
--config-id my-config \
--chunks \
--pretty
Then ask:
Run this command with the Contextual CLI. Show the matching evidence and source record IDs from the actual command output. Use that evidence to explain what to inspect. If the command fails or the results do not answer the question, say so.
The command reads indexed text and search evidence; it does not change the profile or source records. The CLI returns results, and your coding agent uses those results to explain an answer.
Do not treat a plausible answer from the agent as proof that the search ran. Inspect the command and its output. Confirm that it uses your intended CLI configuration, profile, and index, then compare the source ID with the prepared Pump has low flow record.
4. Check the Result
Check that the search and answer meet these criteria:
- The coding agent runs
ctxl aisearch querywith the intended CLI configuration, profile, and index. - The result includes Pump has low flow and evidence about the inlet strainer.
- The answer cites or identifies that source record.
- The recommendation follows the retrieved resolution.
Use Query and Use Results to interpret the evidence and source references. Save the query, actual result, and source ID as the first quality check. Continue with Analyze and Improve Search Quality.