- It learns from the message you send, in the same way as
observe. - It searches the agent’s memory for the memories that relate to the message.
Answer length: detail
Every answering call takes detail. It tells the agent how much to write. On observe-and-enrich and observe-and-respond it sets the length of response_context. On chat and chat/stream it sets the length of the answer.
detail is an instruction to the agent, not a cut. Priors never trims the text to make it fit, so an answer never stops mid-sentence. A brief answer can still be a little longer than 4 sentences when the question needs it. If your own model has a hard limit on input size, use max_context_chars instead; see the next section.
observe-and-enrich: memory for your own model
Use this call when your product already has a language model. Priors returns the memories that relate to the message. Your model writes the answer.
observe. You can add:
detail(brief,standard, ordetailed) to set how much the agent writes. See Answer length.max_context_chars(100 to 100,000) to put a hard limit on the size of the returned text.request_idto match this call with your own logs, and to look up later whether the message was learned.
max_context_chars is a hard cut, not an instruction about length. The agent writes its whole answer, and Priors then trims the text to that many characters, so a limit shorter than the answer leaves the reader with a sentence that stops mid-word. Omitting it means no trimming. Set it only when your own model has a small context window. To get shorter text, send detail: brief, which changes what gets written.
Your own model writes the answer, so Priors has no answer to learn. To have the answer remembered, send it back with observe and speaker set to your assistant’s name.
The success response
When the agent has no related memories,
response_context is empty. This is a success, not an error. Your model answers from the message alone.
observe-and-respond: an answer from Priors
Use this call when you want Priors to write the answer.
The success response
The response has the same fields asobserve-and-enrich. The difference is the meaning of response_context: here it is the answer. Show it to the user. Do not send it to another model.
max_context_chars trims the answer. It is the same hard cut described above: the answer is written in full, then cut to that many characters. detail sets the length of the answer without a cut.
The agent learns its own answer. Like chat, observe-and-respond learns the answer it writes, so a later question can build on it. Send "learn_reply": false in two cases:
- You also send the answer back as an observation. Otherwise it is learned twice.
- Answers must not become memory, for example when they are drafts that a person reviews.
Errors for observe-and-enrich and observe-and-respond
The table below lists every error. 401 and 503 service_unavailable can happen on any call; see Errors.
chat: one message in a chat
Use chat when you build a chat screen. It takes one message from the user, writes an answer, saves both in the thread, and returns links to the files the answer used.
The success response
chat/stream: the same message, answer sent piece by piece
chat/stream takes the same request body. It returns server-sent events, so your screen can show the answer while it is written. The table below lists the events.
A stream always ends with exactly one
complete event or one error event.
Errors for chat and chat/stream
The first table lists errors where your request is wrong. Correct the request before you send it again.
The second table lists errors where your request is correct but Priors cannot answer now. Wait, then send the same request again with the same
turn_id.
On
chat/stream, an error that happens after the stream has started arrives as the error event, with the same code values.
Messages that were not learned
An answering call returns its answer first and learns the message after. Rarely, writing the memory fails. A message that fails is never learned later, so Priors tells you about it. Every answering response has alearning list. It holds the messages of this thread that were not learned and that no earlier response reported. It is almost always empty.
To check one request, call
GET .../threads/{thread_id}/learning?request_id=.... It lists every turn of that request as learned, pending, or not_learned. Without request_id, it returns the turns of the thread that were not learned, newest first, 50 per page. Send next_cursor as before for the next page.
observe or observe-file report on their observation status instead. See Learning.
Summary: which call to use
- You have your own model and prompt:
observe-and-enrich. - You want an answer and nothing else:
observe-and-respond. - You want a chat with history, an answer sent piece by piece, and links to files:
chat/stream. - You want the agent to remember without answering:
observe.