stackbone rag

stackbone rag targets a running agent installation. With no --agent it uses the local-dev installation linked to the current project, so stackbone dev must be running. See target resolution. Every verb accepts --json and emits the standard envelope.

Operate the managed retrieval index bound to the targeted installation. The document and query verbs require --collection <name>. jobs takes it as an optional filter, and retry/cancel address a job by id and take none.

Command Purpose
stackbone rag collections list List collections with per-collection document and chunk counts.
stackbone rag collections create <name> Create an empty collection. --hybrid turns on hybrid search, with --number-format.
stackbone rag collections update <name> Change hybrid search or the number format of a collection.
stackbone rag collections remove <name> Delete a collection and every document under it. Requires --yes.
stackbone rag list List documents in --collection. --limit is 1-200 (default 50), with --cursor.
stackbone rag get <docId> Download a document original to stdout (or --out <path>).
stackbone rag ingest <path> Upload a local .txt/.md/.pdf (≤ 25 MiB) into --collection, staging an async job. Set document values with --metadata.
stackbone rag query <text> Run a similarity query over --collection. --topk is 1-50 (default 10), --model, --no-hybrid, --filter and --ranges.
stackbone rag remove <docId> Delete a document (cascades to its chunks). Requires --yes.
stackbone rag jobs List async ingest jobs, optionally filtered by --collection. Same paging as list.
stackbone rag retry <jobId> Re-enqueue a failed ingest job. Requires --yes.
stackbone rag cancel <jobId> Cancel a non-terminal ingest job. Requires --yes.

list and jobs page with --limit/--cursor, described under pagination. The four verbs marked above refuse to run without --yes, described under destructive verbs.

JSON payload

// rag ingest
{ "schema_version": 1, "job_id": "job_1", "status": "queued" }

// rag query
{ "schema_version": 1,
  "items": [{ "id": "doc_1", "chunk_idx": 0, "score": 0.83, "content": "…", "metadata": {} }],
  "dimensions": 1536, "embedded_with": "text-embedding-3-small" }

// rag jobs
{ "schema_version": 1,
  "items": [{ "id": "job_1", "collection": "docs", "status": "failed", "attempts": 0,
              "error": "…", "created_at": "2026-06-01T10:00:00Z", "finished_at": null }],
  "nextCursor": null, "prevCursor": null }

A job holds one of five statuses: queued, running, succeeded, failed, cancelled. One job is one ingest run, so attempts is always 0: a retry starts a new run rather than counting against the old one.

retry takes a failed job and re-ingests the original the upload stored. The answer carries a new job id, and the failed job keeps its own history. retry refuses a job in any other state ("Only a failed ingest run can be retried.") and exits 1.

cancel takes a job that has not reached a terminal state and flips it to cancelled. It also stops the ingest's next steps: a step that is already running finishes, and none starts after it. cancel refuses a terminal job ("Job is already in a terminal state.") and exits 1. Both verbs answer with the job and the status it now holds: { "schema_version": 1, "id": "job_1", "status": "queued" }.

jobs filters on --collection after it reads the page, so a filtered page can come back with fewer rows than --limit and a nextCursor still set. Keep following the cursor until it is null rather than stopping on a short page.

ingest stores the file, records the document, then hands the parsing, chunking and embedding to the installation's workflow runtime. ingest refuses in two cases, and both exit 1.

Upload the same bytes twice into one collection and the second one comes back as a duplicate. The check is per collection, so the same file in a second collection still goes through.

An installation with no workflow runtime has nothing to ingest with, so the upload fails with rag_ingest_unavailable. That is a workspace that ships no workflows, or a stackbone dev that has not armed them yet. ingest already recorded the document, so this refusal leaves it staged and a second attempt at the same file comes back as a duplicate. Remove the staged document first, then ingest again:

stackbone rag remove <docId> --collection docs --yes
stackbone rag ingest ./handbook.md --collection docs

rag query <text> embeds the query text server-side with the deployment's configured model provider, then runs the similarity search against --collection. The response carries the ranked chunks, the vector dimensions and the model it embedded with (embedded_with). A deployment with no model provider has nothing to embed the text with, so the query fails and exits 1. See local development → model provider.

Documents ingested here live under the reserved rag/ key prefix of the installation's object store, which stackbone storage refuses to write to or delete from.

Exit codes: 0 ok · 4 not found (unknown collection, document or job, or a box too old to run collections update) · 5 permission (destructive verb without --yes) · 1 generic (missing --collection, a --number-format other than eu or us, a collections update with nothing to change or on a paused collection, an unsupported file type, a file over 25 MiB, a duplicate document, no workflow runtime to ingest with, no model provider to embed a query with, a retry or cancel the job's state does not allow). See exit codes.

Set metadata and filter queries

Supply document values with --metadata, then use --filter and --ranges to restrict eligible chunks when you query.

Command Flag Value
rag ingest --metadata '<json object>' Document metadata. Every chunk inherits these values.
rag query --filter '<json object>' A containment filter that must match alongside every range.
rag query --ranges '<json array>' Number or calendar-date ranges over metadata fields.

Choose your own metadata field names and store one invoice or product per document. Split a file containing several entities before you ingest it. Use JSON numbers for amounts, such as 1250, and real YYYY-MM-DD strings for dates. The string "1250" does not match a number range.

Create invoice-october.txt in your current directory with this text:

Hosting invoice for October. Total: 1250. Date: 2026-10-31.

Create a collection and upload the file with its values. If invoices already exists, choose a new collection name throughout this example.

stackbone rag collections create invoices
stackbone rag ingest ./invoice-october.txt --collection invoices \
  --metadata '{"total":1250,"fecha":"2026-10-31","team":"support"}' --json

Keep the upload's job_id. Run the following command again while that job is queued or running. Find the entry whose id matches your job_id, and continue only when its status is succeeded. Follow nextCursor if the job is on a later page. If it is failed or cancelled, resolve that job before querying.

stackbone rag jobs --collection invoices --json

Once the job succeeds, query for support expenses over 500 in October:

stackbone rag query "hosting expenses" --collection invoices --topk 10 \
  --filter '{"team":"support"}' \
  --ranges '[{"field":"total","type":"number","gt":500},{"field":"fecha","type":"date","gte":"2026-10-01","lte":"2026-10-31"}]' \
  --json

The containment filter and both ranges must match. gt: 500 excludes 500; use gte: 500 to include it. The date bounds gte and lte include both 1 October and 31 October. Results are the best matching chunks, limited by --topk. Use a structured query when you need every matching document or a total.

Invalid JSON or invalid flag values fail with a suggestion before an upload or query request. See metadata containment and number/date range rules for the complete filter contract.

A search by meaning can miss an exact string: a product code, a reference, a surname. A collection with hybrid search answers a text query with two searches, by meaning and by exact terms, and merges the two lists. Hybrid search is off by default. Turn it on when you create the collection, or later with collections update:

stackbone rag collections create catalogue --hybrid
stackbone rag query "1239asd/OK" --collection catalogue
Flag Verb What it does
--hybrid collections create, collections update Turns hybrid search on. Without it, a new collection searches by meaning only.
--number-format eu|us collections create, collections update How the collection reads numbers and dates: eu (03/11/2026 is 3 November, the default) or us (03/11/2026 is March 11).
--no-hybrid collections update Turns hybrid search off on the collection.
--no-hybrid query Searches by meaning only for this one query, also on a hybrid collection.

The number format decides how the search for exact terms reads prices and dates in your chunks:

Text in a chunk eu reads it as us reads it as
03/11/2026 3 November 2026 March 11, 2026
03-11-2026 3 November 2026 March 11, 2026
2026-11-03 3 November 2026 3 November 2026
1.250,00 € 1250 euros not an amount
1,250.00 € not an amount 1250 euros

So on an eu collection, 1250 euros finds 1.250,00 €, 3 de noviembre de 2026 finds 03/11/2026, and 3 de noviembre finds it in any year. A date with a month name (3 de noviembre de 2026, November 3, 2026) reads the same in both formats. The full rules are in stackbone.rag → prices and dates. Any value other than eu or us fails before the request and exits 1.

The rules for exact terms, and the advice to keep queries short and copy codes as they are written, are in stackbone.rag → hybrid search. A query of up to 3 words matches a chunk that holds all of them, and a longer query a chunk that holds at least 2. When no chunk holds enough of them, the answer is the same as a search by meaning alone. stackbone rag query searches the text as you type it: splitting a long text into one search per question is a retrieve option of the SDK.

With --json, collections list and collections create show hybrid_enabled and number_format for each collection. An older box leaves both out. Each hit of a hybrid query carries mixed_score, the merged score the list is ordered by. Optional dense_rank and lexical_rank give the hit's 1-based position in the meaning and exact-term searches. A missing leg omits its rank. Older boxes omit both ranks. A current box can return:

{
  "schema_version": 1,
  "items": [
    {
      "id": "doc_7",
      "chunk_idx": 0,
      "score": 0.41,
      "mixed_score": 0.0325,
      "dense_rank": 2,
      "lexical_rank": 1,
      "content": "Ref (1239asd/OK), en stock.",
      "metadata": {}
    }
  ],
  "dimensions": 1536,
  "embedded_with": "text-embedding-3-small"
}

score stays the similarity by meaning. The human output prints score, so on a hybrid collection the scores are not always in descending order, and a hit found by its exact terms can have a low score.

Studio's search dialog labels ranked hits meaning, exact or both. Hovering the label shows the positions, for example meaning #2 · exact #1. A search by embedding, --no-hybrid, a collection without hybrid search, or an older box returns no ranks and shows no source label. The CLI table output stays the same; use --json to see the ranks.

Change hybrid search on an existing collection

collections update turns hybrid search on or off, or changes the number format, on a collection that already holds documents. Pass at least one flag. A flag you leave out keeps its current value:

stackbone rag collections update catalogue --hybrid --number-format us
stackbone rag collections update catalogue --no-hybrid

The box recomputes the exact terms of every chunk from the text it already stores, with the new number format. After --number-format us, 11 de marzo de 2026 finds 03/11/2026 and 3 de noviembre de 2026 no longer does. It calls no embedding model, so the change costs nothing at your model provider. While it runs, the collection is paused: a search or an ingest into it fails with rag_collection_unavailable. The command prints Rebuilding collection catalogue… on stderr and waits until the box answers, which usually takes seconds:

Rebuilding collection catalogue…
Updated collection catalogue: hybrid search on, number format us.

With --json, stdout carries only the result:

{
  "schema_version": 1,
  "collection": { "name": "catalogue", "hybrid_enabled": true, "number_format": "us" }
}

The command refuses in these cases:

Case What you see Exit
No --hybrid, --no-hybrid or --number-format Nothing to change on collection <name>., before any request 1
The collection is paused by a model change or another update rag_collection_unavailable. Run the command again once it is ready 1
The recompute fails The collection stays paused. Run the same command again to retry 1
The box predates this command This box cannot change the search settings of a collection. 4

A hybrid collection indexed before this release keeps its old exact terms, so its prices and dates match only as they are written. Run collections update with the settings it already has to recompute them:

stackbone rag collections update catalogue --hybrid
BUILT WITH ❤️ FROM CANADA AND SPAIN