Search agent API
Spotlight starts searches itself, from the
line's search policy, or
when a chat that improves a station calls the
test-station-change
tool, and picks a candidate when a search finishes. No endpoint starts, stops
or reads a search, or picks a candidate. See
How Spotlight improves a station.
A search's agent calls the two endpoints below from inside its run. Only the
runner with the lease on the run may call them, with its runner token; any
other caller is answered 401. They answer JSON, and errors are
application/problem+json as on the
resource API.
| Method and path | Returns |
|---|---|
POST /api/runs/{runId}/search-candidates | 201: proposes a candidate. See Propose a candidate. |
POST /api/runs/{runId}/failure-causes | 201: records why a failing task failed. See Record a cause. |
Propose a candidate
The agent reaches it through
spotlight candidate.
Spotlight replays the candidate on the search's searched tasks at once.
| Field | Type | Description |
|---|---|---|
name | string | A slug unique in the search: lowercase letters, digits and hyphens, starting with a letter or digit, at most 63 characters. |
hypothesis | string | What the candidate is expected to improve, and why. |
station | object | The station block, as the line stores it, changed only where a search may change it. |
It answers { "candidateId", "name", "replayId" }, replayId being its replay
on the searched tasks. Proposing the same name again from the same run answers
with the candidate it proposed. A rejected proposal does not count as one of
the iteration's candidates, but the run may only try so often.
| Status | Cause |
|---|---|
404 | The run is no longer the active run of the search, or it is not a search run that this runner leases. |
409 | The iteration proposed all the candidates it may, or tried too often; another iteration uses the name already; or the iteration is a reflection, which proposes no candidates. |
422 | A name that is no slug, no hypothesis, or a station block the line rejects or that changes what a search may not. Each problem names its path. |
Record a cause
A reflection's agent, in an iteration that looks into why a stalled search's
tasks fail, reaches it through
spotlight cause. One
cause per task: recording a task's cause again replaces the one before.
| Field | Type | Description |
|---|---|---|
taskId | string | A failing task the reflection's briefing lists. |
cause | string | config when a change to the station's config could fix it; task when the task itself is why; judge when the judge judged it wrong; check when the check failed for a reason the change did not cause; infra when the run failed around the work. |
evidence | string | What in the runs shows the cause, 1 to 4,000 characters. |
suggestion | string | Optional. What a person, or the next iteration, should change, at most 4,000 characters. |
It answers { "taskId", "cause", "replayRunId" }, replayRunId being the
failing replay run the cause is about. A task cause takes the task out of the
station's replay set at its next refresh. See
How Spotlight keeps the set.
| Status | Cause |
|---|---|
404 | The run is no longer the active run of the search, it is not a search run that this runner leases, or the reflection does not look into the task. |
409 | The run's iteration proposes candidates; it looks into no causes. |
422 | A cause other than config, task, judge, check or infra; no evidence, or more than 4,000 characters of it; a suggestion over 4,000 characters. |