> ## Documentation Index
> Fetch the complete documentation index at: https://infino.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Ask the retrieval sub-agent

> The retrieval sub-agent, named for what a caller delegates to it: a model
writes queries over the database's tables until one validates, and the
rows of that query come back as facts, never as prose (unless `answer`
asks for a written answer beside them).

Preview: this route may change between releases. It needs the agent APIs enabled on your account, and answers 403 until they are.



## OpenAPI

````yaml /api-reference/openapi.json post /v1/sub_agent/{database}
openapi: 3.1.0
info:
  title: Infino API
  description: >-
    The Infino hosted data-plane API: per-database table operations — create,
    ingest, search, and SQL.
  version: 0.1.0
servers:
  - url: https://api.platform.infino.ws
    description: Infino Cloud
security:
  - api_key: []
tags:
  - name: Databases
    description: Create, list, and delete the databases in your account.
  - name: Tables
    description: Create, drop, and list tables, and describe a table's schema.
  - name: Rows
    description: Append, update, and delete rows.
  - name: Search
    description: BM25, vector, and hybrid search, token and exact match, count, and SQL.
  - name: Agent
    description: >-
      Preview routes for agents: table cards, join keys, line search, result
      checks, graph lookups, and the retrieval sub-agent. They need the agent
      APIs enabled on your account.
  - name: Hydrate
    description: >-
      Preview routes for loading a dataset: start a load of files from object
      storage into a table, follow it, cancel or clear it, and run a sync pass.
paths:
  /v1/sub_agent/{database}:
    post:
      tags:
        - Agent
      summary: Ask the retrieval sub-agent
      description: >-
        The retrieval sub-agent, named for what a caller delegates to it: a
        model

        writes queries over the database's tables until one validates, and the

        rows of that query come back as facts, never as prose (unless `answer`

        asks for a written answer beside them).


        Preview: this route may change between releases. It needs the agent APIs
        enabled on your account, and answers 403 until they are.
      operationId: sub_agent
      parameters:
        - name: database
          in: path
          description: Target database.
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SubAgentRequest'
            example:
              question: Which services logged a timeout calling `billing-api` last week?
              table: logs
              projection:
                - service
                - ts
              k: 2
        required: true
      responses:
        '200':
          description: >-
            The facts: the rows of the query that validated (it ran on the
            database, returned rows, and the rows contain what the question
            asked for: its numbers, names, quoted terms and identifiers; the
            statement's text counts for nothing; or, for an aggregate (a GROUP
            BY, a COUNT, SUM, AVG, MIN or MAX), it returned a non-zero number),
            the top `k` of them (10 by default, up to the deployment's limit),
            ranked against the question by the deployment's embedding model when
            the query left their order to the engine (`coverage.ranker` names
            it; absent when the query's own order stands), each with the table
            it came from, plus the statement they came from and how many rows it
            returned in all. A question whose queries retrieved nothing still
            returns 200: after three failed attempts `terminate` is `escalated`
            and `error` carries the sub-agent's account of the problem for the
            caller to act on; a turn or wall cap is named the same way, with
            `facts` empty. `inference_tokens` is the one figure for the model
            work: the tokens the sub-agent's calls consumed, prompt and
            completion together, the count this call's inference was billed on.
            What the inference was billed is in the
            `x-infino-inference-nanodollars` response header.
          headers:
            x-infino-inference-nanodollars:
              schema:
                type: integer
                format: int64
                minimum: 0
              description: >-
                What this call's inference was billed, in billionths of a US
                dollar.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubAgentResponse'
              example:
                facts:
                  - table: logs
                    row:
                      service: checkout
                      ts: '2026-03-02T10:14:07Z'
                      message: timeout calling billing-api after 30s
                  - table: logs
                    row:
                      service: invoicing
                      ts: '2026-03-03T08:41:55Z'
                      message: 'billing-api: request timeout'
                coverage:
                  rows_total: 37
                  rows_returned: 2
                  truncated: true
                statement: >-
                  SELECT service, ts, message FROM bm25_search('logs',
                  'message', 'timeout billing-api', 20)
                terminate: answered
                turns: 2
                retries: 0
                inference_tokens: 4210
        '400':
          description: >-
            Invalid request body; a `projection` naming no column of any table
            in scope; `k`, or more `facts`, than the deployment's limit; `facts`
            without `answer` and `table`; or a database with no tables.
        '401':
          description: Missing or invalid API key.
        '402':
          description: >-
            The account is suspended for non-payment, or its free period has
            ended.
        '403':
          description: >-
            The agent APIs are not enabled for this account, or the API key
            lacks read access to this database.
        '404':
          description: >-
            The database does not exist; the named `table` is not a described
            table of it; or none of the named `tables` is. The message lists the
            tables the database does have described.
        '410':
          description: The database is being purged.
        '429':
          description: >-
            The database's model pool is full: as many sub-agent calls as it
            serves at once are in progress, and one more would only queue until
            its wall cap. Transient: retry after the `Retry-After` interval when
            one is given (the wait one call takes here), else shortly.
        '501':
          description: This deployment has no answering model configured.
        '502':
          description: >-
            The service could not read the answer computed for this request.
            Transient: retry.
        '503':
          description: >-
            No table of the database has been described yet (a table is
            described shortly after it is created), or the database is still
            activating. Transient: retry after the `Retry-After` interval.
      security:
        - api_key: []
components:
  schemas:
    SubAgentRequest:
      type: object
      description: |-
        `POST /v1/sub_agent/{database}`: a question about the database's data,
        and how to scope and bound the retrieval that answers it. An unknown
        field is refused.
      required:
        - question
      properties:
        answer:
          type: boolean
          description: |-
            Compose a written answer from the facts as well: once the facts are
            final, a model is shown them with every line numbered as it is in
            the source and writes the answer for a developer, citing the facts'
            lines. The facts still come back beside it, and the answer's
            citations are checked against them, repaired where the facts say
            where a citation belongs, and, on a deployment that runs a grading
            model, graded against the lines they cite (`coverage.answer` reports
            all of it). A caller that writes its own prose leaves this off and
            reads the facts.
        context:
          type:
            - string
            - 'null'
          description: |-
            Text shown to the model beside the question and not part of it: a
            description of the data, a hint, a convention. Nothing in it is
            required of the result.
        facts:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/Fact'
          description: >-
            The rows to write the answer from, when the caller already holds
            them

            from its earlier calls: the retrieval does not run, the writer is

            shown these rows and no others, and the answer's citations are

            checked against them. A row given by its place alone (`path` and a

            line inside it, `start_line`, on a code table, or a table's key

            cells) is read back from the table, so the writer sees its lines as

            the index holds them; a row given with other cells is shown as

            given. Requires `answer: true` and `table`; more rows than the

            deployment's facts limit is refused.
        include_transcript:
          type: boolean
          description: |-
            Return the whole conversation, every model reply and tool result,
            as `transcript` beside the facts.
        k:
          type:
            - integer
            - 'null'
          description: |-
            Facts returned at most: 10 when omitted, as many as asked otherwise,
            up to the deployment's limit (1,000 by default; above it the request
            is refused). The sub-agent's searches fetch a multiple of this many
            rows (10 times by default) as the candidates ranked against the
            question before the top `k` go back.
          minimum: 0
        max_turns:
          type:
            - integer
            - 'null'
          description: |-
            Fewer turns than the deployment allows, when the caller wants a
            cheaper answer; a value above the deployment's cap is lowered to it.
          minimum: 0
        max_wall_secs:
          type:
            - integer
            - 'null'
          format: int64
          description: |-
            A shorter wall-clock budget than the deployment allows, in seconds;
            a value above the deployment's cap is lowered to it.
          minimum: 0
        playbook:
          type:
            - string
            - 'null'
          description: |-
            A playbook of learned notes for the sub-agent to read beside its
            instructions: the label the notes were stored under, the
            `session_id` of the database's memory rows of kind `playbook`. The
            notes nearest the question are recalled once per call. Omitted, no
            playbook is read.
        projection:
          type:
            - array
            - 'null'
          items:
            type: string
          description: >-
            The columns a search or `find` fact carries beside the text and the

            score, for a caller who knows which columns place a row (a code

            table's `path`, `start_line`, `end_line`), each applied to the
            tables

            that have it. Omitted, a fact carries the table's key columns, or
            the

            engine's row id when it has none. A list naming no column of any

            table is refused.
        question:
          type: string
          description: |-
            The question, in natural language, about the database's data. What
            the question names (its numbers, names, quoted terms and
            identifiers) is what a validated result must contain, so put only
            the question here.
        table:
          type:
            - string
            - 'null'
          description: >-
            The one table the question is about, when the database holds
            several.

            The sub-agent is then shown that table's card alone, so it cannot

            wander to a sibling. A name that is not a described table of the

            database is refused with 404. Omitted (and with no `tables`), every

            table's card is shown.
        tables:
          type: array
          items:
            type: string
          description: |-
            The tables the question is about, when it is about more than one and
            less than all: the sub-agent is shown their cards alone and may join
            them. With `table` too, the scope is both. A table named here with
            no card yet (or no such table) is left out of the scope and listed
            in the response's `left_out`; the request is refused with 404 only
            when none of the named tables has a card and no `table` is given.
      additionalProperties: false
    SubAgentResponse:
      type: object
      description: |-
        The answer as the caller receives it (`POST /v1/sub_agent/{database}`):
        the facts and what produced them, and one figure for the model work.
        `inference_tokens` is the count the call's inference was billed on, so
        a bill can be checked against the responses. Always `200` once the
        sub-agent ran: a run that hit its turn or wall cap, or lost its model,
        reports that in `terminate` and `error` rather than as an HTTP failure,
        so a client can tell "nothing retrieved" from "the request was wrong".
      required:
        - facts
        - coverage
        - terminate
        - turns
        - retries
        - inference_tokens
      properties:
        answer:
          type:
            - string
            - 'null'
          description: |-
            The written answer, when the request asked for one (`answer: true`)
            and facts were there to write from: what the facts show, for a
            developer, citing their lines. Absent otherwise.
        coverage:
          $ref: '#/components/schemas/Coverage'
          description: |-
            How much of what the query returned `facts` holds, and what ordered
            them.
        error:
          type:
            - string
            - 'null'
          description: |-
            Why the run ended without facts, when it did: the model's failure;
            or, after three attempts validated no query (`terminate:
            escalated`), the sub-agent's own account of the problem, for the
            caller to act on. Absent otherwise.
        facts:
          type: array
          items:
            $ref: '#/components/schemas/Fact'
          description: >-
            The facts: the top `k` of the rows the validated query returned,

            ranked against the question when the query left their order to the

            engine (`coverage.ranker` names what ranked them), in the query's
            own

            order when it chose one. Every row is the database's; empty when the

            sub-agent ended with nothing retrieved.
        inference_tokens:
          type: integer
          format: int64
          description: |-
            Tokens the sub-agent's model calls consumed over the whole run,
            prompt and completion together, the composed answer's included: the
            count this call's inference was billed on.
          minimum: 0
        left_out:
          type: array
          items:
            type: string
          description: |-
            Tables of the question's scope the sub-agent was not shown, because
            no card describes them yet: nothing of theirs is in the facts, so an
            empty or partial answer says nothing about them. Absent when every
            table in scope was consulted.
        retries:
          type: integer
          description: Times a query or an answer was sent back to the model.
          minimum: 0
        statement:
          type:
            - string
            - 'null'
          description: |-
            The query the facts came from: SQL, or a search call written as the
            SQL it equals, or a `find` call. It is how to get every row again.
            Absent when the sub-agent ended with nothing retrieved.
        terminate:
          $ref: '#/components/schemas/TerminateReason'
          description: How the sub-agent's run ended.
        transcript:
          type:
            - array
            - 'null'
          items:
            type: object
          description: |-
            The conversation, when the request asked for it
            (`include_transcript: true`): every model reply and tool result, in
            order, each a JSON object. Absent otherwise.
        turns:
          type: integer
          description: Model turns the run took.
          minimum: 0
    Fact:
      type: object
      description: 'One fact: a row the query returned, with the table it came from.'
      required:
        - row
      properties:
        row:
          type: object
          description: The row's cells by column name, as the database holds them.
        table:
          type:
            - string
            - 'null'
          description: |-
            The table the row belongs to, when the query searched one table;
            absent for a SQL statement, which may join several.
    Coverage:
      type: object
      description: |-
        How much of what the query returned the response holds, and what
        ordered it.
      required:
        - rows_total
        - rows_returned
        - truncated
      properties:
        answer:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/AnswerCoverage'
              description: >-
                The composed answer's accounting, when the request asked for one
                and

                facts were there to write from: which model wrote it, how long
                it

                took, its tokens, and how many of its citations fall inside the
                facts

                it was shown. Absent when no answer was composed.
        ranker:
          type:
            - string
            - 'null'
          description: |-
            What ordered `facts`: the embedding model whose similarity to the
            question ranked the query's candidates. Absent when the query's own
            order stands: it ordered by a column, grouped, was a `find`,
            returned one row, or no embedding model could be reached.
        repoint:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/RepointCoverage'
              description: >-
                The re-pointing pass after the grading, when the deployment runs
                one

                and the question named an identifier: which identifiers it read
                off

                the question, which it looked up in the index because no kept
                row

                held them on a line of code, how many places it put to the
                model,

                and which places it added to the facts. Absent when no pass ran.
        rows_returned:
          type: integer
          description: 'Rows in `facts`: all of them, or the top `k`.'
          minimum: 0
        rows_total:
          type: integer
          description: Rows the query returned in all.
          minimum: 0
        triage:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/TriageCoverage'
              description: >-
                The grading pass over the ranked candidates, when the deployment

                runs one: what scored them, how many it scored and dropped
                before

                the top `k` were taken, and what went wrong when it could not.

                Absent when no pass ran.
        truncated:
          type: boolean
          description: Whether rows were left out.
    TerminateReason:
      type: string
      description: |-
        How the sub-agent's run on a question ended: `answered` (a query
        validated, or under an answer contract an answer was given), `turn_cap`
        (the turn budget ran out), `wall_cap` (the wall-clock budget ran out),
        `error` (the model failed after retries), or `escalated` (three attempts
        validated no query, and the question is handed back to the caller with
        the sub-agent's account of the problem in `error`).
      enum:
        - answered
        - turn_cap
        - wall_cap
        - error
        - escalated
    AnswerCoverage:
      type: object
      description: |-
        What composing the written answer did: who wrote it, what it cost, and
        how its citations held up against the facts.
      required:
        - model
        - ms
        - prompt_tokens
        - completion_tokens
        - citations
        - held
      properties:
        citations:
          type: integer
          description: |-
            `path:line` and `path:start-end` citations in the answer as it
            stands, after any repair.
          minimum: 0
        completion_tokens:
          type: integer
          format: int64
          description: |-
            The writing call's completion tokens, counted into the response's
            `inference_tokens`.
          minimum: 0
        error:
          type:
            - string
            - 'null'
          description: |-
            Why no answer came back, when none did: the call's failure in a
            sentence. The facts stand.
        graded:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/GradeCoverage'
              description: >-
                The grade of each held citation's sentence against the lines it

                cites, and the moves it led to, when the deployment runs a
                grading

                model. Absent when it does not.
        held:
          type: integer
          description: Citations that fall inside a fact of that path the model was shown.
          minimum: 0
        model:
          type: string
          description: The model that wrote the answer.
        ms:
          type: integer
          format: int64
          description: |-
            How long the whole answer stage took, in milliseconds: the writing,
            the citation repair, the per-sentence grade and the re-pointing
            together.
          minimum: 0
        prompt_tokens:
          type: integer
          format: int64
          description: |-
            The writing call's prompt tokens, counted into the response's
            `inference_tokens`.
          minimum: 0
        repaired:
          type: array
          items:
            type: string
          description: |-
            Citations the repair rewrote against the facts, each
            `as written -> as it stands (why)`: a bare name written out, a range
            moved to where the identifier beside it sits in the shown lines.
        revised:
          type: boolean
          description: |-
            Whether the answer here is a second one, written after the first did
            not validate and the writer was told what was wrong with it. A
            second answer is kept only when it is wrong in fewer ways than the
            first; either way both calls' tokens are counted. Omitted when
            false.
        unheld:
          type: array
          items:
            type: string
          description: |-
            The citations that do not, as written: a file the model was never
            shown, or a bare name several shown files carry.
        unknown_names:
          type: array
          items:
            type: string
          description: |-
            Names the answer writes in backticks that no row it was shown holds,
            each once. The writer is told to write from the rows and nothing
            else, so a name in none of them was recalled or invented rather than
            read. Reported, not edited: the checks move where a citation points,
            never what a claim says.
        unplaced:
          type: array
          items:
            type: string
          description: |-
            Citations that kept their path and lost their line numbers, with
            why: no shown line of that file placed them.
        unrevised:
          type:
            - string
            - 'null'
          description: |-
            Why an answer found to have faults went back unrevised, then the
            faults it stands with, each the sentence the writer would have been
            told. One fault ships as it is; two or more call for a second
            writing call, which is made only when the writing model's rate limit
            has room for it and kept only when it is wrong in fewer ways. Absent
            when the answer validated or was revised.
        wrote_ms:
          type: integer
          format: int64
          description: |-
            How long the writing model's own call or calls took, of that, in
            milliseconds. The rest of `ms` is the service's work on the answer.
          minimum: 0
    RepointCoverage:
      type: object
      description: |-
        What the re-pointing pass did after the grading: the facts a caller
        cites from re-pointed at the place the question is about, when none of
        them held it.
      required:
        - model
        - identifiers
        - looked_up
        - places
        - added
        - ms
        - tokens
      properties:
        added:
          type: array
          items:
            type: string
          description: |-
            The places added to the front of the facts, as `path:line` of the
            line the identifier sits on; one at most per identifier.
        error:
          type:
            - string
            - 'null'
          description: |-
            Why a lookup or a choice did not happen, when one did not: the
            failure in a sentence. The facts are left as they were.
        identifiers:
          type: array
          items:
            type: string
          description: The identifiers read off the question, in its order.
        looked_up:
          type: array
          items:
            type: string
          description: |-
            The identifiers looked up in the index: those no kept row held on a
            line of code.
        model:
          type: string
          description: The grading model that chose among the places.
        ms:
          type: integer
          format: int64
          description: |-
            How long the pass took, in milliseconds, its calls in flight
            together.
          minimum: 0
        places:
          type: integer
          description: Candidate places put to the model, over every identifier looked up.
          minimum: 0
        tokens:
          type: integer
          format: int64
          description: |-
            Input tokens the pass's calls read. Billed as inference at the
            grading model's rate, and kept apart from the response's
            `inference_tokens`, which is priced at the answering model's.
          minimum: 0
    TriageCoverage:
      type: object
      description: |-
        What the grading pass did to a query's ranked candidates: each row
        scored against the question, and those under the cut dropped before the
        top `k` were taken.
      required:
        - model
        - scored
        - dropped
        - ms
      properties:
        dropped:
          type: integer
          description: Rows dropped for scoring under the cut.
          minimum: 0
        error:
          type:
            - string
            - 'null'
          description: |-
            Why a batch of rows was kept unscored, when one was: the call's
            failure in a sentence. Rows of a failed batch are kept as ranked.
        model:
          type: string
          description: The grading model that scored the rows.
        ms:
          type: integer
          format: int64
          description: |-
            How long the pass took, in milliseconds, every call in flight
            together.
          minimum: 0
        scored:
          type: integer
          description: Rows put to the model.
          minimum: 0
        tokens:
          type: integer
          format: int64
          description: |-
            Input tokens the pass's calls read. Billed as inference at the
            grading model's rate, and kept apart from the response's
            `inference_tokens`, which is priced at the answering model's: one
            count over two rates would misstate the cost.
          minimum: 0
    GradeCoverage:
      type: object
      description: |-
        What grading the answer's citations did: every held citation's sentence
        put to the grading model with the lines it cites, the ones it doubted
        moved to the place it chose among the other shown occurrences of their
        identifier, or left standing and named.
      required:
        - model
        - graded
        - ms
        - tokens
      properties:
        doubted:
          type: array
          items:
            type: string
          description: |-
            Citations it doubted that stayed where they were: no other shown
            place held their identifier, or it chose none.
        error:
          type:
            - string
            - 'null'
          description: |-
            Why a grade or a move did not happen, when one did not: the failure
            in a sentence. The answer stands as it was.
        graded:
          type: integer
          description: Citations put to it.
          minimum: 0
        model:
          type: string
          description: The grading model.
        moved:
          type: array
          items:
            type: string
          description: Citations it doubted and moved, each `from -> to`.
        ms:
          type: integer
          format: int64
          description: How long the grade and the moves took, in milliseconds.
          minimum: 0
        tokens:
          type: integer
          format: int64
          description: |-
            Input tokens the grading calls read. Billed as inference at the
            grading model's rate, and kept apart from the response's
            `inference_tokens`, which is priced at the answering model's.
          minimum: 0
  securitySchemes:
    api_key:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.