Skip to Content
Docs

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 ctxl is on PATH and 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:

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:

Terminal
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:

JSONL
{"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:

Terminal
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.

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:

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:

Terminal
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.

See Search Concepts and Configuration for the meaning of each setting.

2. Check Indexing Progress

Read the reported build and repair progress:

Terminal
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.

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:

Terminal
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 query with 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.