SPB Git

Repository Public

results.md 3.8 KB 70 lines markdown

1# Results and state23> For the complete documentation index, see [llms.txt](/llms.txt). Markdown versions of documentation pages are available by appending `.md` to the page URL.45When you run an agent, the result is more than just the final answer. It's also the handoff boundary, the next-turn continuation surface, and the resumable snapshot when a run pauses for review.67## Choose the result surface you need89Most applications only need a small set of result properties:1011| If you need                                          | Use                                                                                 |12| ---------------------------------------------------- | ----------------------------------------------------------------------------------- |13| The final answer to show the user                    | `finalOutput` in TypeScript or `final_output` in Python              |14| Local replay-ready history                           | `history` in TypeScript or `to_input_list()` in Python               |15| The specialist that should usually own the next turn | `lastAgent` in TypeScript or `last_agent` in Python                  |16| OpenAI-managed response chaining                     | `lastResponseId` in TypeScript or `last_response_id` in Python       |17| Pending approvals and a resumable snapshot           | `interruptions` plus `state` in TypeScript or `to_state()` in Python |1819Those are the guide-level surfaces to learn first. Richer run items, raw model responses, and detailed diagnostics still belong in the SDK docs and reference material.2021## What to carry into the next turn2223Use the result in a way that matches your continuation strategy:2425- If your application owns full local history, reuse `history` in TypeScript or `to_input_list()` in Python.26- If you are using a session, keep passing the same session and let the SDK load and persist history for you.27- If you are using server-managed continuation, pass only the new user input and reuse the stored ID instead of replaying the full transcript.28- After handoffs, reuse `lastAgent` in TypeScript or `last_agent` in Python when that specialist should stay in control for the next turn.2930## Interrupted runs return state, not a final answer3132Approval flows are the main case where a result is intentionally incomplete.3334- `finalOutput` in TypeScript or `final_output` in Python can35  stay empty because the run hasn't actually finished.36- `interruptions` tells you which pending tool calls need a decision.37- `state` in TypeScript or `to_state()` in Python is the saved38  snapshot you pass back into the runtime after approving or rejecting those39  items.4041That same state surface is what you serialize when a review might happen later rather than in the same request.4243## Richer item and diagnostics surfaces4445The SDK also exposes richer run items and diagnostics for applications that need more than the high-level surfaces above. That includes item-level tool and handoff records, raw model responses, guardrail results, and usage details.4647Those are useful for audits, custom interfaces, and deep debugging, but they don't need to be the first thing most developers learn on this site.4849## Next steps5051Once you know which result surfaces matter, continue with the guide that explains how those surfaces get produced or inspected.52535455  [Running agents56575859        Connect result handling back to the runtime loop and continuation60      strategy.](https://developers.openai.com/api/docs/guides/agents/running-agents)61  [Guardrails and human review62636465        See how paused runs return interruptions and resumable state.](https://developers.openai.com/api/docs/guides/agents/guardrails-approvals)66  [Integrations and observability67686970        Use traces when you need to inspect the richer workflow record.](https://developers.openai.com/api/docs/guides/agents/integrations-observability)
Files main
Menu

Theme