---
title: "Context for a prompt"
method: POST
path: "/v1/agents/{agent}/context"
tags: ["agents"]
---

# Context for a prompt

`POST /v1/agents/{agent}/context`

## Request

- Base URL: `https://innernet.live/api`
- URL: `https://innernet.live/api/v1/agents/{agent}/context`
- Auth: HTTP bearer

One block of text ready for a system prompt, in three lowercase sections: what the agent knows, what it may know of the person it works for (only what its settings let it read, each with whose words they are: "they said", "noted" or "inferred"), and what it knows of this user (when `user_id` is given). Ranked, then trimmed from the bottom to `budget_tokens` (about four characters a token). A search, so the `read` scope is enough.

## Path parameters

- `agent` string, required

## Request body

- object
  - `query` string
  - `user_id` string
  - `run_id` string
  - `budget_tokens` integer

## Response `200`

OK

- object
  - `text` string: Empty when there is nothing to add.
  - `memories` AgentMemory[]: The memories the block was built from.
    - `id` string, uuid
    - `agent` string: The agent's slug.
    - `content` string, nullable
    - `kind` 'fact' | 'preference' | 'episode' | 'procedure' | 'instruction' | 'note'
    - `subject` 'agent' | 'owner' | 'user': Who it is about: the agent's own knowledge, the person who owns the agent, or one of its users.
    - `user_id` string, nullable: Your end user, when `subject` is `user`.
    - `run_id` string, nullable
    - `tags` string[]
    - `metadata` object
    - `importance` integer
    - `confidence` number, nullable
    - `immutable` boolean
    - `source` 'api' | 'extract' | 'dashboard' | 'import'
    - `event_at` string, date-time, nullable
    - `expires_at` string, date-time, nullable
    - `supersedes` string, uuid, nullable: The memory this one is the next version of.
    - `superseded_at` string, date-time, nullable: Set once a newer version has replaced this one.
    - `about_you` object, nullable: Set when the memory is about the person who owns the agent: where it stands with them.
      - `state` 'held' | 'kept' | 'declined' | 'auto'
      - `dimension` string, nullable
    - `created_at` string, date-time
    - `updated_at` string, date-time
    - `score` number: Only on recall and context results: 0 to 1.
  - `person` object[]: The person's facts it carries (same shape as recall).

## Other responses

- `400`: Error: a field is wrong; `detail.field` names it (`invalid`)
- `401`: Error
- `403`: Error: this key cannot read (`forbidden`)
- `404`: Error: no such agent for this key (`not_found`)
- `423`: Error: the agent is paused (`paused`)
- `429`: Error: over the agent's reads a minute (`rate_limited`; `Retry-After: 60`)
- `503`: Error: agents are not switched on yet (`unavailable`)

---

[API](https://skmtc.dev/innernet/apis/innernet-api.md) · [All operations](https://skmtc.dev/innernet/apis/innernet-api/llms.txt) · [OpenAPI document](https://skmtc.dev/innernet/apis/innernet-api/revisions/1ee09aec71a9?raw)
