登録して招待リンクを共有すると、動画再生報酬と紹介報酬を獲得できます。

cv usk
@cv_usk
AI / Software Research Notes AI Agent, LLMOps, MLOps, Software Architecture 投稿は個人の意見です。
参加 May 2026
280 フォロー中    415 ファン
# Useful but Little-Known Features of OpenAI Agent SDK 🌍 Did you know you can save an agent's state when it pauses for human approval and resume it later? With `to_state()` and interruptions, you can pause and resume agent runs that require approval workflows. 📌 Title: Pause/Resume with to_state() and Interruptions 🔗 URL: 🧩 Overview When a tool requires human approval, `result.interruptions` holds the pending approval requests. Call ` to capture the current execution as a resumable `RunState` snapshot, then use `state.approve()` or `state.reject()` for each interruption. Finally, pass the modified state back with ` state)` to resume. This works with direct tools, nested handoffs, and ` runs alike. 🛠 How to use it ```python from agents import Agent, Runner agent = Agent(name="Assistant", instructions="Use tools when needed.") result = await "Delete temp files...") # Check for pending interruptions if result.interruptions: # Capture a resumable state snapshot state = # Approve or reject each interruption for interruption in result.interruptions: state.approve(interruption) # state.reject(interruption) # to deny # Resume with the approved state result = await state) ``` 🏗 Building it into production ・Serialize `RunState` to a database for asynchronous approval workflows ・Integrate with Slack buttons or admin dashboards: approve, then ` to resume ・For streaming runs, fully consume `stream_events()` before accessing interruptions ・Approve or reject interruptions individually for fine-grained access control 💡 Use cases 🔐 Pre-approval for destructive operations like file deletion or data modification 💳 Human double-check before processing payments 📋 Multi-stage approval workflows with escalation 🔄 Checkpointing long-running processes for later resumption ⚠️ Watch out For streaming runs, accessing interruptions before fully consuming `stream_events()` yields incomplete results. Also, `RunState` is tied to the agent configuration at capture time. Resuming with a modified agent definition may cause unexpected behavior. ✨ Use to_state() to build safe agent workflows with human judgment in the loop. #OpenAIAgentSDK# #AIAgent#
もっと見る