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
- Enumerate run-result and item types, marking final answers, refusals, and pending work. [openai-results]
- Render a final answer only when
result.final_output is not Noneand the run is complete; approval pauses leave itNone. [openai-results] - Use
result.new_itemsto distinguishMessageOutputItem,ToolCallItem,ToolCallOutputItem,HandoffCallItem, and approval items. [openai-results] - Retain result-type information for diagnosis without exposing internal prompts or tool arguments. [openai-results]
- 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
- Python 3.10+, openai-agents compatible with the pinned revision, and authorized model-provider credentials (except local mock tests)
Permissions
- Use a local or isolated test environment; use least privilege and approval for external data or side effects
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
- 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