Knowledge
Summary
Knowledge gives an agent content to answer from: web pages, text you send and uploaded documents. This guide adds a workspace source and an agent-owned source, links the workspace source into the agent’s library, waits for the sources to be ready and publishes the agent, which freezes the library’s content for new calls. It does not cover the rest of the draft or explicit snapshots; see Build and publish an agent and Deprecations.
Facts
Steps
Set AGENT_ID to the id of the agent, from listAgents or from the answer of createAgent.
1. Add a workspace source
A workspace source can be linked into the library of any agent of the workspace. The workspace routes need an explicit owner.
The answer is 202 with the source. Set SOURCE_ID to its id. A URL that is not a permitted
public address is not refused at once: the source later reads state: failed with
failure: outbound_destination_refused. To upload a file, send it as multipart to
POST /knowledge/sources/upload.
2. Add an agent-owned source
An agent-owned source joins that agent’s library at once and never becomes usable by another agent. The agent routes fix the owner by the path and refuse owner fields in the body.
The answer is 202 with the source. To upload a file for the agent, send it as multipart to
POST /agents/{agent_id}/knowledge/sources/upload.
3. Link the workspace source into the agent’s library
Linking is set membership: linking a linked source changes nothing. It accepts a workspace source
or the agent’s own source, never a source that another agent owns. To unlink a workspace source,
send DELETE to the same path with a new Idempotency-Key. Unlinking never deletes content or
changes a published version, and an agent’s own source cannot be unlinked: delete or archive the
source instead.
4. Wait for the sources to be ready
Read each source until its state is ready. A read never starts ingestion.
state is an open list: treat a value you do not know as unknown, never as success.
5. Publish knowledge
The agent’s direct library determines the next publication’s knowledge. Read the draft for its current publication ETag, then publish with it. Library membership and source state or revision changes all change that ETag.
Publication freezes the library’s content automatically, as retrieval data or bounded prompt context. Library changes and source refreshes take effect in calls after you publish again; existing published versions never change, and calls already running keep their knowledge. See Build and publish an agent for what else a publish freezes.
Rules
- MUST wait for each library source to be
readybefore you publish, and resolve afailedsource first. - MUST read the draft again after a library or source change, and validate or publish with the new ETag.
- MUST send the source’s ETag in
If-Matchon reingest. - MUST NOT link a source that another agent owns, or an archived source.
- MUST archive, not delete, a source that a retained snapshot or published version cites.
- Every source has a fixed owner, chosen when it is created and never changed. Ownership decides which agent may select a source; it is not a permission. Access follows the key’s capabilities.
- An archived agent refuses library changes and agent-owned source creation with
409 agent_archived. - Legacy draft knowledge fields (
retrieval_snapshot_id,fallback_source_ids) do not select the knowledge used by publication, and do not block unlinking, archive or delete. See Deprecations.
The agent library
GET /agents/{agent_id}/knowledge/sources lists the agent’s library. Each item has a relation:
owned for the agent’s own sources, shared for workspace sources linked into the library.
Archived sources are left out unless you ask for state=archived.
Reingest
POST /knowledge/sources/{source_id}/reingest creates a new ingestion revision and answers 202.
It takes the source’s ETag (from step 4) in If-Match and a new Idempotency-Key. Existing
published versions keep their knowledge, and a state or revision change to a library source changes
the publication ETag of each agent that uses it. Reingest keeps ownership: an agent-owned source
never becomes usable by another agent.
Archive or delete
Two commands take a source out of use. Choose by whether anything still needs its content.
References are checked inside the same operation, so a publish and a delete cannot race. Delete
takes no If-Match. An archived source can still be listed with state=archived.
Resource keys
Archiving keeps a source’s resource_key taken; deleting frees it. A resource_key filter on a
list finds the source whatever its owner or state, archived included. See
Resource keys.
Verify
Expected output after step 4: both sources in items, the linked one with "relation": "shared"
and the agent’s own one with "relation": "owned", each with "state": "ready".