Skip to main content
Tool results are untrusted input. Averta checks them before they re-enter the model loop.

Responses API

For Responses API, tool results are function_call_output items.
const nextResponse = await client.responses.create({
  model: process.env.OPENAI_MODEL ?? "gpt-5.4-mini",
  input: [
    ...response.output,
    {
      type: "function_call_output",
      call_id: functionCall.call_id,
      output: JSON.stringify({
        matches: ["Password reset links expire after 24 hours."],
      }),
    },
  ],
  tools,
});
The wrapper extracts the new function_call_output items and checks them before forwarding the continuation to OpenAI.

Chat Completions

For Chat Completions, tool results are tool role messages.
const nextCompletion = await client.chat.completions.create({
  model: process.env.OPENAI_MODEL ?? "gpt-5.4-mini",
  messages: [
    ...messages,
    completion.choices[0]!.message,
    {
      role: "tool",
      tool_call_id: "call_123",
      content: JSON.stringify({
        matches: ["Password reset links expire after 24 hours."],
      }),
    },
  ],
  tools,
});

Block Behavior

If policy blocks the tool result:
  • the wrapper throws AvertaSdkError
  • the continuation request is not sent to OpenAI
  • the model does not see the returned tool content

Decision Callback

client = wrapOpenAI(client, {
  onDecision(event) {
    if (event.checkpointType === "tool_result") {
      console.log(event.tool.name, event.decision.decision);
    }
  },
});

Debugging

SymptomCheck
No tool-result decisionConfirm the continuation contains only provider-native tool-result items for the current turn.
Tool result blocks unexpectedlyInspect the returned content for prompt injection or unsafe instructions.
Tool name is missing in logsConfirm the original tool call was checked and has a stable call_id.