Memory API

The Memory API enables management of agent memory and context for improved task performance.

Create Memory

Create a new memory entry for an agent or fleet.

from agentic_fleet import Memory

memory = Memory.create(
    owner_id="agt_123abc",
    owner_type="agent",
    content={
        "key_insights": ["insight1", "insight2"],
        "context": "Important project context...",
        "preferences": {
            "style": "concise",
            "format": "markdown"
        }
    },
    tags=["project_x", "code_review"]
)

HTTP Request

POST /v1/memory

Request Body

{
  "owner_id": "agt_123abc",
  "owner_type": "agent",
  "content": {
    "key_insights": ["insight1", "insight2"],
    "context": "Important project context...",
    "preferences": {
      "style": "concise",
      "format": "markdown"
    }
  },
  "tags": ["project_x", "code_review"]
}

Response

{
  "memory_id": "mem_789xyz",
  "owner_id": "agt_123abc",
  "owner_type": "agent",
  "content": {
    "key_insights": ["insight1", "insight2"],
    "context": "Important project context...",
    "preferences": {
      "style": "concise",
      "format": "markdown"
    }
  },
  "tags": ["project_x", "code_review"],
  "created_at": "2025-02-24T15:30:00Z"
}

Query Memory

Query memory entries based on various criteria.

memories = Memory.query(
    owner_id="agt_123abc",
    tags=["project_x"],
    content_query="code review preferences",
    limit=10
)

HTTP Request

GET /v1/memory/search

Query Parameters

ParameterTypeDescription
owner_idstringFilter by owner ID
owner_typestringFilter by owner type
tagsarrayFilter by tags
content_querystringSearch within memory content
limitintegerMaximum number of memories to return
offsetintegerNumber of memories to skip

Response

{
  "memories": [
    {
      "memory_id": "mem_789xyz",
      "owner_id": "agt_123abc",
      "owner_type": "agent",
      "content": {
        "key_insights": ["insight1", "insight2"],
        "context": "Important project context...",
        "preferences": {
          "style": "concise",
          "format": "markdown"
        }
      },
      "tags": ["project_x", "code_review"],
      "created_at": "2025-02-24T15:30:00Z"
    }
  ],
  "total": 1,
  "has_more": false
}

Update Memory

Update an existing memory entry.

memory = Memory.update(
    "mem_789xyz",
    content={
        "key_insights": ["updated_insight1", "insight2"],
        "context": "Updated project context..."
    }
)

HTTP Request

PATCH /v1/memory/{memory_id}

Request Body

{
  "content": {
    "key_insights": ["updated_insight1", "insight2"],
    "context": "Updated project context..."
  }
}

Response

{
  "memory_id": "mem_789xyz",
  "owner_id": "agt_123abc",
  "owner_type": "agent",
  "content": {
    "key_insights": ["updated_insight1", "insight2"],
    "context": "Updated project context..."
  },
  "tags": ["project_x", "code_review"],
  "updated_at": "2025-02-24T16:00:00Z"
}

Delete Memory

Delete a memory entry.

Memory.delete("mem_789xyz")

HTTP Request

DELETE /v1/memory/{memory_id}

Response

{
  "deleted": true,
  "memory_id": "mem_789xyz"
}

Memory Types

Common memory content types:

TypeDescription
CONTEXTTask or project context
PREFERENCESUser or agent preferences
INSIGHTSKey learnings and observations
HISTORYInteraction history
SKILLSAgent capabilities and expertise

Best Practices

  1. Memory Organization

    • Use consistent tagging
    • Structure content hierarchically
    • Include relevant metadata
    • Regular cleanup of outdated memories
  2. Content Management

    • Keep content concise and relevant
    • Use structured data when possible
    • Include timestamps for temporal context
    • Regular updates to maintain accuracy
  3. Performance

    • Index frequently accessed memories
    • Implement caching for common queries
    • Batch updates when possible
    • Regular optimization of memory storage