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

# Build with an AI agent

> Give a coding agent the API contracts, implementation brief, and acceptance checks.

Give your coding agent one result to implement and the exact sources it should use. Start with a read-only API client or extend the complete learning tutorial into your application.

You need a project the agent can inspect and a server-side environment for `ADAPT1_API_KEY`. Give the agent the variable name, never the key's value.

## Give the agent a bounded build brief

Choose one prompt. Replace the application requirement at the end, then run it in your repository.

<CodeGroup>
  ```text Read-only integration theme={null}
  Add a server-side Adapt-1 integration to this repository.

  First inspect the language, framework, package manager, test runner,
  environment-variable conventions, and server/client boundary.

  Read:
  - https://docs.reilabs.org/docs/neuroadapt/quickstart.md
  - https://docs.reilabs.org/docs/neuroadapt/request-contracts.md
  - https://docs.reilabs.org/neuroadapt-openapi.json
  - https://docs.reilabs.org/docs/neuroadapt/errors-and-reliability.md

  Implement:
  - Follow the repository's existing HTTP-client and error-handling patterns.
  - Read ADAPT1_API_KEY from the server environment; never expose or log it.
  - Default ADAPT1_BASE_URL to
    https://rei-neuroadapt-api.reilabs.org/api/v1.
  - Add one function accepting a nonempty message and sending
    POST {baseUrl}/memory/query with:
    {
      "session_id": "ignored",
      "user_message": <the caller's message>,
      "top_k": 5,
      "include_reasoning": true,
      "update_memory_state": false
    }
  - Send Authorization: Bearer <ADAPT1_API_KEY> and JSON content type.
  - Validate the request against MemoryQueryRequest and validate the response
    fields the application consumes. Do not fabricate a response model.
  - Add a finite timeout and useful errors for missing configuration, non-2xx
    status, malformed JSON, unexpected shape, and transport failure.
  - Return the structured result directly; an LLM is not required.
  - Add placeholder variable names to .env.example, not a real secret.
  - Test with mocked HTTP. Do not call live services or write persistent state.
  - Include a short application usage example.

  Run the repository's relevant formatting, linting, type checks, and tests.
  Report the files changed, commands run, and results. Identify assumptions
  and untested behavior explicitly. Do not make unrelated changes.

  Application requirement:
  [Describe the API route, server action, job, or CLI that should use the result.]
  ```

  ```text Learning workflow theme={null}
  Extend this repository with one Adapt-1 learning workflow.

  Read:
  - https://docs.reilabs.org/docs/adapt-1/getting-started.md
  - https://docs.reilabs.org/docs/neuroadapt/first-learned-result.md
  - https://docs.reilabs.org/docs/neuroadapt/request-contracts.md
  - https://docs.reilabs.org/docs/neuroadapt/discovery-transition-projection.md
  - https://docs.reilabs.org/neuroadapt-openapi.json
  - https://docs.reilabs.org/docs/neuroadapt/errors-and-reliability.md

  Before implementation:
  - Describe the result, inputs available before it, observable target/outcome,
    Domain scope, and state lifecycle for the application requirement below.
  - Use the first-learned-result tutorial only if an observation-to-target
    prediction is the right relationship. Otherwise select the relevant
    documented feedback, sequential, or trajectory guide.
  - The checked-in OpenAPI snapshot is incomplete for Domain learning and
    trajectory workflows. Identify guide-documented fields missing from it.
    Do not invent fields or delete essential learning configuration merely
    to match that incomplete snapshot. Report actual source conflicts.

  Implement one complete loop:
  - Keep API calls and ADAPT1_API_KEY on the server.
  - Use a fresh Domain for an independent test; persist its ID for reconnecting.
  - Supply only information available before the requested result. Withhold
    the target at prediction time; do not insert a solved policy or answer.
  - Preserve request intent before writes and sanitized responses afterward.
  - Check transport success and learner admission separately.
  - Handle accumulating state, missing diagnostics, and abstention explicitly.
  - Consume the actual route-defined result, not a client-side substitute.
  - Inspect the later result and applicable learner-state diagnostics.
  - Never automatically retry ambiguous writes or reset existing state.
  - Mock the network in automated tests. Do not make live writes without
    explicit authorization and a dedicated test credential.

  Run the repository's relevant checks. Report which parts were schema-checked,
  which follow the written guides, which were mock-tested, and which were
  actually live-tested. Do not claim live behavior from a mocked response.

  Application requirement:
  [Describe the result and the observations or outcomes your application owns.]
  ```
</CodeGroup>

## Sources the agent should use

| Source                                                            | Purpose                                                         |
| ----------------------------------------------------------------- | --------------------------------------------------------------- |
| [Documentation index](/llms.txt)                                  | Find the relevant pages                                         |
| [Choose a workflow](/docs/adapt-1/getting-started)                | Select the result, state scope, and learning relationship       |
| [Quickstart](/docs/neuroadapt/quickstart)                         | Confirm the base URL, authentication, and first request         |
| [HTTP and contracts](/docs/neuroadapt/request-contracts)          | Understand isolation, read/write controls, and schema coverage  |
| [OpenAPI snapshot](/neuroadapt-openapi.json)                      | Validate fields and limits that the snapshot actually describes |
| [Errors and reliability](/docs/neuroadapt/errors-and-reliability) | Handle timeouts and ambiguous stateful writes                   |

<Tip>
  When the agent cannot read web pages, supply the relevant Markdown pages and OpenAPI file locally. Refresh them before changing the integration; do not let an old local snapshot become an invented API contract.
</Tip>

## Review the implementation

<Steps>
  <Step title="Check the request boundary">
    Confirm the versioned base URL, bearer header, field names, types, and state scope. `session_id: ignored` is a compatibility placeholder, not a tenant selector. Do not allow browser code to read the API key.
  </Step>

  <Step title="Check result handling">
    Reject malformed or unexpected responses. Treat empty evidence, accumulating state, and abstention according to the route. A confidence field is not automatically a correctness probability; a stored write is not automatically an admitted update.
  </Step>

  <Step title="Check state and retries">
    Verify which operations can change state. Preserve Domain IDs for continued use, avoid resets as setup shortcuts, and reconcile an ambiguous write before resubmitting it. Mock tests must not call the live API.
  </Step>

  <Step title="Verify independently">
    Run the direct request in the quickstart with a dedicated test key before debugging the application integration. Then run the generated application path. Keep sanitized failures and actual response records; never paste authorization headers into a prompt.
  </Step>
</Steps>

An optional language layer can articulate an already validated result. Keep the original structured result and its evidence available; do not replace the API integration with a language model that guesses what Adapt-1 would return.

## Extend one workflow at a time

<CardGroup cols={2}>
  <Card title="Continuity and correction" href="/docs/neuroadapt/build-an-assistant-with-persistent-context">
    Add retained evidence without inventing a Domain requirement.
  </Card>

  <Card title="Discovery configuration" href="/docs/neuroadapt/discovery-examples">
    Change the target or discovered structure with a matching event contract.
  </Card>

  <Card title="Feedback from execution" href="/docs/neuroadapt/make-behavior-improve-from-feedback">
    Bind a measured outcome to the actual decision or context.
  </Card>

  <Card title="Numeric control" href="/docs/machina/configuration">
    Keep trajectory configuration, executor settings, and recovery semantics distinct.
  </Card>
</CardGroup>
