跳转到内容
EN

给智能体发消息

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

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

请求参数

  • agent_idstring必填

    path: 接受 agent_… ID、8 位身份编号(如 NA7P479J)或 handle,三者指向同一个智能体。只对个人与 General 智能体成立:消息落到调用者与该智能体的主会话——每人一个,首次调用自动创建,之后每次都是同一个。服务型(service)与 assume 智能体没有主会话,返回 400(服务型走 A2A,或显式创建会话)。

  • eventsarray必填

    要发送给会话的事件列表。

返回

200

与 POST /agent/v1/sessions/{主会话}/events 相同,按智能体寻址;首次调用创建主会话并由数据库保证每人每智能体唯一。service、assume 智能体返回 400(用 A2A 或显式建会话)。

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

请求示例

curl
# 先调用「创建智能体」,用返回的智能体 ID 替换示例 ID。
curl https://api.deepraxis.com/agent/v1/agents/agent_123/events \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"events":[{"type":"user.message","content":[{"type":"text","text":"你好"}]}]}'
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/events",
    headers={"Authorization": f"Bearer {opts['api_key']}"},
    json={"events":[{"type":"user.message","content":[{"type":"text","text":"你好"}]}]},
)
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/events`, {
  method: "POST",
  headers: { Authorization: `Bearer ${opts.apiKey}`, "Content-Type": "application/json" },
  body: JSON.stringify({"events":[{"type":"user.message","content":[{"type":"text","text":"你好"}]}]}),
});
console.log(resp.status, await resp.json());

响应示例 200

{
  "data": [
    {
      "id": "d21e4176-41d6-430d-ae13-3b713adde51e",
      "type": "user.message",
      "message_id": "596f8898-4bf8-4df8-9417-6624e593dc01",
      "processed_at": null,
      "praxis_sender": {
        "type": "member",
        "id": "usr_xzk7ar3hzbrsdfdvc6w8nxxf"
      },
      "content": [
        {
          "type": "text",
          "text": "你好"
        }
      ]
    }
  ]
}

响应

HTTP 200

Successful response

application/json

名称 类型 说明
data array<object> Sent events
data[].id string Unique identifier for this event. / Event id, unique within the session. Use it to refer to this event, for example in user.tool_confirmation or user.steer.
data[].content array<object> Array of content blocks comprising the user message. / The result content returned by the tool. / The result content returned by the tool. / System content blocks. Text-only.
data[].type string Always user.message. A message from the user to the agent, with content blocks. / Always user.interrupt. The user interrupted the running turn. / Always user.tool_confirmation. The user's decision to allow or deny a tool call that waits for approval. / Always user.custom_tool_result. The user's result for a custom tool call. / Always user.define_outcome. The user defined the outcome the agent should reach. / Always user.tool_result. The user's result for a client-side tool call. / Always system.message. A message produced by the platform rather than the user or the agent. / Always user.steer. Receipt that a queued user.message was injected into the running turn.
data[].processed_at null | string | string | null | string | null | string | string A timestamp in RFC 3339 format / RFC 3339 time at which the server processed the event; null while a queued input has not started running.
data[].praxis_context object Untrusted page context for this user message only. Resend on each turn when needed; never added to system instructions. The complete JSON value must be at most 4096 UTF-8 bytes; invalid values return 400 INVALID_PARAMS. Empty items are treated as absent. Available only on /agent/v1.
data[].session_thread_id null | string | string | null If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread. / Set by the server to the subagent thread this confirmation was routed to. Omitted when it was routed to the primary thread. / Set by the server to the subagent thread this result was routed to. Omitted when it was routed to the primary thread. / Set by the server to the subagent thread this result was routed to. Omitted when it was routed to the primary thread. / Envelope field, not part of this event's own payload: the public sthr_ thread id of the row (null when the row has none), added by the shared projection in apps/api/src/routes/managed-session-events.ts whenever the row carries one (#4480). No writer of this event runs under a thread today, so it is declared for the frame shape rather than produced here.
data[].result string UserToolConfirmationResult enum
data[].tool_use_id string The id of the agent.tool_use or agent.mcp_tool_use event this result corresponds to, which can be found in the last session.status_idle event's stop_reason.event_ids field. / The id of the agent.tool_use event this result corresponds to, which can be found in the last session.status_idle event's stop_reason.event_ids field.
data[].deny_message string Feedback for a deny result, at most 4000 characters. Appended to the model-visible refusal and persisted on the confirmation. Omit when no feedback is needed.
data[].permission_mode string With result=allow and full_access_available=true, switch this session to full access before allowing this call. Other values or ineligible active requests return 400. Repeated or late replies are successful no-ops.
data[].custom_tool_use_id string The id of the agent.custom_tool_use event this result corresponds to, which can be found in the last session.status_idle event's stop_reason.event_ids field.
data[].is_error null | boolean Whether the tool execution resulted in an error.
data[].description string What the agent should produce. Copied from the input event.
data[].max_iterations null | number Evaluate-then-revise cycles before giving up. Default 3, max 20.
data[].outcome_id string Server-generated outc_ ID for this outcome. Referenced by span.outcome_evaluation_* events and the session's outcome_evaluations list.
data[].rubric object Rubric for grading the quality of an outcome.
data[].event_id string Id of the event this event refers to.
data[].message_id string Envelope field, not part of this event's own payload: the transcript message id of the row, added by the shared projection in apps/api/src/routes/managed-session-events.ts whenever the row carries one (#4480). No writer of this event stamps a message id today, so it is declared for the frame shape rather than produced here.