AI Agents

Reviewing an external agent's replies

Ask XBASE to review an external agent's reply before it goes to the contact, with the output guardrails set up on the agent.

Updated on

An external agent generates the reply outside XBASE. With the Review agent replies (guardrails) scope (guardrails:review), it asks XBASE to review the reply before sending it, with the same output guardrails set up on the agent.

Request

POST https://api.xbase.app/api/external/v1/agents/{agentId}/output-review

agentId is the external agent's id in XBASE. An agent from another workspace, or one that is not external, returns 404.

FieldTypeRequiredRule
turnKeytextyesId of the contact's message, up to 128 characters. Repeating the same turnKey identifies the same turn
attempt1 or 2yes2 when the agent has already redone the reply once
messagetextyesContact's message, up to 4,000 characters
replytextyesReply the agent wants to send, up to 8,000 characters
instructionstextnoAgent's instructions, up to 40,000 characters
recentConversationtextnoRecent excerpt of the conversation, up to 3,000 characters
sourcestextnoResults of tools and searches used in the reply, up to 20,000 characters
threadIdtextnoConversation in XBASE, from the same workspace
curl -X POST https://api.xbase.app/api/external/v1/agents/$AGENT_ID/output-review \
  -H "Authorization: Bearer $XBASE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "turnKey": "msg-8812",
    "attempt": 1,
    "message": "Do you deliver on Saturday?",
    "reply": "Yes, we deliver every day, including Sunday.",
    "threadId": "c1d7f0b2-…"
  }'

Response

200 response:

{
  "verdict": "rejected",
  "triggered": ["grounding"],
  "severity": "grave",
  "action": "retry",
  "considerations": {
    "fixed": ["A resposta afirma algo que não está nas instruções."],
    "feedback": { "problemas": ["…"], "afirmacoes_sem_base": ["…"], "orientacao": "…" }
  },
  "holdingMessage": null,
  "reviewId": "4e0b…"
}
actionWhat the agent does
sendSends the reply. Comes when it was approved, when the review was uncertain, when the guardrail only records or when no output guardrail is on
retryFirst rejection: redo the reply using considerations and discard the blocked reply
send_with_tagSecond minor rejection: send it
holdSecond serious rejection: do not send the reply. Send holdingMessage and hand the conversation over to the team

Recommended flow

  1. The agent generates the reply and calls the review with attempt: 1.
  2. With send, it sends. With retry, it redoes the reply using the considerations and calls again with attempt: 2 and the same turnKey.
  3. On the second call, it follows the action: send or send_with_tag send; hold sends the holdingMessage and hands over to the team.

With threadId, the review shows up in the Chatcenter conversation.

Frequently asked questions

See also

On this page