Typescript sdk

Artifact Components

Copy page

Learn how to use artifact components to store and retrieve data from the agent

Artifacts are structured components that capture and store source information when agents interact with tools or other agents. They act as a record-keeping system, automatically documenting where information comes from during tool and agent interactions.

How Artifacts Work

When an agent uses a tool (whether that's another agent or a utility tool), the response is automatically parsed to create artifacts. These artifacts store:

  • The source of the information (tool/agent used)
  • The relevant content from the response
  • Metadata about the interaction

Defining Artifact Components

Artifact components are defined when creating an agent using the artifactComponents property:

const agent = agent({
  // ... other agent config
  artifactComponents: [
    {
      id: "document-artifact",
      tenantId,
      name: "Document Artifact",
      description:
        "Structured factual information extracted from search results",
      summaryProps: {
        type: "object",
        properties: {
          title: {
            type: "string",
            description: "Title of the source document",
          },
          url: { type: "string", description: "URL of the source document" },
          record_type: {
            type: "string",
            description: "Type of record (documentation, blog, guide, etc.)",
          },
        },
        required: ["title", "url", "record_type"],
      },
      fullProps: {
        type: "object",
        properties: {
          content: {
            type: "array",
            items: {
              type: "object",
              properties: {
                type: {
                  type: "string",
                  description: "Type of content (text, image, video, etc.)",
                },
                text: {
                  type: "string",
                  description: "The actual text content",
                },
              },
              required: ["type", "text"],
            },
            description:
              "Array of structured content blocks extracted from the document",
          },
        },
        required: ["content"],
      },
    },
  ],
});

The summaryProps is used in the agent's context. The fullProps is used to store extra information about the artifact, stored in the database.

Automatic Artifact Creation

When an agent uses a tool or delegates to another agent:

  1. The tool/agent processes the request and returns a response
  2. The response is automatically parsed according to the artifact component schema
  3. An artifact is created containing the parsed information
  4. The artifact is associated with any data components (facts, clarifying questions, etc.) that use this information

Using Artifacts with Data Components

Artifacts work hand-in-hand with data components to maintain traceability. For example:

  1. An agent uses a tool to fetch information
  2. The response is automatically captured as an artifact
  3. The agent creates a fact component using this information
  4. The artifact is automatically linked to the fact component

This creates a clear chain of evidence showing where each piece of information originated.

Example Flow

// Example of how artifacts are created and used
const factsAgent = agent({
  id: "facts",
  tools: {
    facts_tool: inkeepFactsTool, // When this tool is used...
  },
  prompt:
    "Use the facts_tool to fetch information and create a fact component followed by an artifact component.",
  artifactComponents: [
    {
      id: "document-artifact",
      // ... artifact schema definition
    },
  ],
  dataComponents: [
    {
      id: "fact",
      // ... fact component definition that will be linked to artifacts
    },
  ],
});

In this example, when the facts_tool is used:

  1. The tool returns information
  2. An artifact is automatically created with the response
  3. The agent can create fact components using this information
  4. The facts are automatically linked to their source artifacts