跳转到内容
EN

给智能体一段经历

先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。

POST/agent/v1/agents/{agent_id}/consolidations● 支持

请求参数

  • agent_idstring必填

    path: Agent id from agents.create or agents.list, the eight character identity number or the handle; the agent must belong to your organization. Also accepts an 8-character identity number (0–9, A–Z); malformed, absent and foreign references return 404, and response ids always use agent_….

  • messagesarray可选

    The experience as a conversation, oldest first, at most 200 messages and 60000 characters in all, with at least one user message; send this or text, not both.

    展开子字段 (3)
    • rolestring必填

      Who spoke: user is the person, assistant is the agent.

      取值 userassistant
    • contentstring必填

      What was said, as plain text.

    • atstring可选

      RFC 3339 time this message happened; defaults to occurred_at, must not be later than occurred_at and not earlier than the message above it.

  • textstring可选

    The experience as one piece of text, taken as a single user message; send this or messages, not both; at most 60000 characters.

  • occurred_atstring必填

    RFC 3339 time the experience happened, not in the future; the engram is stamped with it, so recall orders the memory by when it happened and not by when you sent it.

  • aboutarray可选

    Entity ids or ref: ids the experience is about, as hints for consolidation; optional, at most 50.

  • idempotency_keystring可选

    Your own key for this experience, scoped to the agent; the same key with the same body returns the first consolidation, with a different body is 409. Omit it and a hash of the body is the key.

返回

202

经历成为该智能体的一个 origin=imported 的会话,事件时间为经历发生的时间,随后归档并走普通的巩固流程。

错误按 Anthropic 错误格式返回(type / message / request_id),参见 错误码

请求示例

curl
# 先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。
curl https://api.deepraxis.com/agent/v1/agents/agent_123/consolidations \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"客户李先生来电:新加坡仓的季度报价改按月结,币种用新加坡元,总价下周一前确认。","occurred_at":"2026-11-02T09:30:00Z","idempotency_key":"call-li-2026-11-02"}'
Python
# 先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。
import requests

opts = dict(
    base_url="https://api.deepraxis.com/agent",
    api_key="$PRAXIS_API_KEY",
)

# /agent 是我们自己的 Managed Agents 形状,直接发 HTTP 请求(Bearer 认证)
resp = requests.post(
    f"{opts['base_url']}/v1/agents/agent_123/consolidations",
    headers={"Authorization": f"Bearer {opts['api_key']}"},
    json={"text":"客户李先生来电:新加坡仓的季度报价改按月结,币种用新加坡元,总价下周一前确认。","occurred_at":"2026-11-02T09:30:00Z","idempotency_key":"call-li-2026-11-02"},
)
print(resp.status_code, resp.json())
TypeScript
// 先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。
const opts = {
  baseURL: "https://api.deepraxis.com/agent",
  apiKey: "$PRAXIS_API_KEY",
};

// /agent 是我们自己的 Managed Agents 形状,直接发 HTTP 请求(Bearer 认证)
const resp = await fetch(`${opts.baseURL}/v1/agents/agent_123/consolidations`, {
  method: "POST",
  headers: { Authorization: `Bearer ${opts.apiKey}`, "Content-Type": "application/json" },
  body: JSON.stringify({"text":"客户李先生来电:新加坡仓的季度报价改按月结,币种用新加坡元,总价下周一前确认。","occurred_at":"2026-11-02T09:30:00Z","idempotency_key":"call-li-2026-11-02"}),
});
console.log(resp.status, await resp.json());

响应示例 202

{
  "id": "cns_1e66df0ead03e8112e5e4785c4f9229a",
  "session_id": "sesn_1e66df0ead03e8112e5e4785c4f9229a",
  "status": "queued"
}

响应

HTTP 202

Accepted: the experience is held by an imported session and its consolidation is queued; poll agents.consolidations.retrieve with id.

application/json

名称 类型 说明
id string Consolidation id (cns_...), the id to pass to agents.consolidations.retrieve; derived from the agent and the idempotency_key (or the body), so a replay returns the same id.
session_id string The imported session (sesn_...) that holds the episode: its events are your messages at the times you gave, it is archived, and it is readable with sessions.events.list.
status string Where the consolidation is: queued, running, done or failed.
engram_id string The engram the pass wrote, present only when status is done and the experience held something worth keeping; recall reads it back.
error string Why the pass failed, present only when status is failed.