Dashboard
Memory

Function calling

Retrieve memory from any model tool loop.

Function calling is the preferred Memory integration when your application already owns the model request. The model decides whether current context needs long-term memory; your server owns identity and credentials.

#Function declaration

{
  "name": "halo_retrieve_end_user_memory",
  "description": "Retrieve relevant long-term memory for this end user.",
  "parameters": {
    "type": "object",
    "properties": {
      "sessionData": {
        "type": "object",
        "description": "Current conversation and application state."
      },
      "query": {
        "type": "string",
        "description": "Optional retrieval focus."
      },
      "limit": {
        "type": "number",
        "description": "Maximum raw records to return."
      }
    },
    "required": ["sessionData"]
  }
}

#Execute the function

curl -X POST \
  https://api.agihalo.com/api/v1/memory/functions/halo_retrieve_end_user_memory \
  -H "Authorization: Bearer $HALO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "projectKey": "customer-product",
    "endUserKey": "user_123",
    "arguments": {
      "sessionData": {
        "messages": [
          {
            "role": "user",
            "content": "What format do I prefer for weekly reports?"
          }
        ]
      },
      "query": "weekly report preference",
      "limit": 5
    }
  }'

#Use the response

HALO immediately selects retrievable topics and linked processed raw exchanges. The response includes selectedTopicKeys,selectionReason, overallSummary,topics, rawEntries, and a compactfunctionResponse.

{
  "name": "halo_retrieve_end_user_memory",
  "projectKey": "customer-product",
  "endUserKey": "user_123",
  "selectedTopicKeys": ["report_preferences"],
  "selectionReason": "The user is asking about report format.",
  "overallSummary": "The user prefers concise weekly reports.",
  "functionResponse": {
    "requestId": "memory_request_id",
    "rawEntries": [
      {
        "id": "raw_entry_id",
        "topic": { "topicKey": "report_preferences" },
        "requestRaw": { "messages": [] },
        "responseRaw": { "role": "assistant", "content": "..." }
      }
    ]
  }
}

If no scope exists, HALO returns the same shape with empty topic and raw arrays. Treat that as an ordinary first-time-user state.

#Capture after the answer

Retrieval never implies a write. Call capture after your model has produced the final assistant message.

curl -X POST https://api.agihalo.com/api/v1/memory/capture \
  -H "Authorization: Bearer $HALO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "projectKey": "customer-product",
    "endUserKey": "user_123",
    "sessionData": {
      "messages": [
        {
          "role": "user",
          "content": "Keep my weekly reports short and send them in the morning."
        }
      ]
    },
    "response": {
      "role": "assistant",
      "content": "I will keep them concise and morning-ready."
    }
  }'