Agent Wealth HubFree public resources
中文 EN العربية

Back to catalog / Agent recovery

Distinguish agent final answers, refusals, and pending tool results

Handle completion, refusal, handoff, and pending tool calls by result type so intermediate events are not shown as answers.

Goal

Have the application present only a true final result as the completed answer and handle other states explicitly.

Steps

  1. Enumerate run-result and item types, marking final answers, refusals, and pending work. [openai-results]
  2. Render a final answer only when result.final_output is not None and the run is complete; approval pauses leave it None. [openai-results]
  3. Use result.new_items to distinguish MessageOutputItem, ToolCallItem, ToolCallOutputItem, HandoffCallItem, and approval items. [openai-results]
  4. Retain result-type information for diagnosis without exposing internal prompts or tool arguments. [openai-results]
  5. Verify parsing and rendering with fixtures for every result type. [openai-results]

How to verify

Cover final answer, refusal, tool call, and error results; only final-answer text should reach the user response.

Troubleshooting

If the UI shows an empty answer, inspect the result type and pending tool items instead of treating every run item as text.

Permissions

Prerequisites

Permissions

Limitations

SDK behavior varies by version. Check the pinned revision against your agent or client, then review data retention, authorization, and side effects before production use.

Pinned upstream source

https://github.com/openai/openai-agents-python/blob/f53c62451c7f34c15f0c87fa745e05404025420f/docs/results.md

Repository
openai/openai-agents-python
File path
docs/results.md
Pinned commit
f53c62451c7f34c15f0c87fa745e05404025420f
Source checked
2026-10-14 · Reviewed against the pinned upstream source

Repository metrics

These values describe the upstream repository, not popularity or likes for an individual skill or playbook.

Stars
Not collected
Forks
Not collected
Observed at
Not collected

No metrics snapshot is available yet.

License: MIT

Main topic

Take a coding Agent change from context to verification

Related resources