Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions fix(examples): avoid blocking event loop during OPG approval
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Summary

Makes the async example scripts non-blocking during Permit2 approval.

Several examples call `llm.ensure_opg_approval(...)` inside `async def main()`. That method is synchronous, and its approval polling path uses blocking sleep internally. In async examples, this can block the event loop and propagate a bad asyncio usage pattern to users copying the official examples.

This PR updates the async examples to run the approval step with `await asyncio.to_thread(...)`, keeping the examples event-loop-safe without changing SDK behavior.

## Problem

The following example scripts are async:

- `examples/llm_chat.py`
- `examples/llm_chat_streaming.py`
- `examples/llm_tool_calling.py`
- `examples/llm_multi_turn_conversation.py`

Each of them called:

```python
llm.ensure_opg_approval(...)
Loading