Step 1: check the limits
max_upload_bytes is the largest file you can send. The default is 10 MB. One file at a time per agent. At most 2,000 pieces per file.
Step 2: upload the file
strategy=structure splits the text at headings, which suits a handbook. Use auto when you are not sure.
Success: status 202. The file was converted and split. Learning starts now.
turns_total: 64: the handbook became 64 pieces. Each piece becomes one observation.source_id: save it. Answers point to the file with this id.deferred: truemeans a scanned document that is too long to convert inside one request. Priors accepted it and continues in the background. Poll the status.
413 document_too_large: the file is larger than 10 MB. Split the PDF.413 document_too_many_turns: more than 2,000 pieces. Split the file, or setmax_chars=4000.413 document_too_many_pagesordocument_too_large_for_ocr: the scan has more pages, or is larger, than text recognition accepts. Split the file.409 document_uploaded_elsewhere: an upload of this file in another thread stopped partway. Finish it there withfinish-learning, or sendallow_duplicate=trueto read it again here.400 encrypted_document: remove the password.400 document_needs_ocr: the pages are scanned, and text recognition is not available. Export a PDF that contains text.429 rate_limit_exceeded: only one upload every 10 seconds per subject. WaitRetry-Afterseconds.502 document_service_unavailable,ocr_failed, ordocument_pages_unexpected: the document converter or text recognition failed. The file is fine. Wait, then try again.503 ocr_busy: text recognition is busy with other uploads. Try again in a few minutes.
Step 3: follow the learning
status is committed.
If it stops:
failed: readerror. Usually one piece could not be read. CallPOST .../threads/{thread_id}/sources/{source_id}/finish-learningto finish it from the stored copy, which reads and charges only what is left. See Sources.interrupted: a Priors restart paused it. It resumes by itself. Keep polling.
Step 4: upload a second file
You do not need to wait for the first file. An agent reads one file at a time, so a second file sent now is accepted with"queued": true and starts by itself when the first one is committed. Plain text and Markdown work too:
202 at once with "duplicate": true and costs nothing. Into another thread of this agent it returns 409 document_already_ingested instead, because what the first read learned is already searchable from every thread. Its document_state is completed when the first upload already finished, or ingesting when the first upload is still running and your call joined it.
Step 5: ask a question and receive a citation
200.
citations[0].href downloads the handbook. Show it as a link next to the answer. verified is false here, because the handbook reached the answer through a memory, not as a file attached to this message. That is the normal case for documents.
With observe-and-respond instead of chat, the same information arrives as used_source_ids.
Step 6: see which files the agent holds
What this walkthrough showed
- One upload gives one
observation_id, and you poll it in the same way as forobserve. - Files belong to the agent. Upload them in any thread. Every thread can point to them.
- Upload files one after another for one agent. For different agents, three uploads can run at the same time in your organization.