Skip to content

Commit 0724103

Browse files
authored
docs: improve doc coverage for Dapr sessions and advanced model settings (#2587)
1 parent 253f241 commit 0724103

File tree

5 files changed

+76
-2
lines changed

5 files changed

+76
-2
lines changed

docs/examples.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ Check out a variety of sample implementations of the SDK in the examples section
5858
- Advanced SQLite session storage
5959
- Redis session storage
6060
- SQLAlchemy session storage
61+
- Dapr state store session storage
6162
- Encrypted session storage
62-
- OpenAI session storage
63+
- OpenAI Conversations session storage
64+
- Responses compaction session storage
6365

6466
- **[model_providers](https://github.com/openai/openai-agents-python/tree/main/examples/model_providers):**
6567
Explore how to use non-OpenAI models with the SDK, including custom providers and LiteLLM integration.

docs/models/index.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,36 @@ english_agent = Agent(
204204
)
205205
```
206206

207+
#### Common advanced `ModelSettings` options
208+
209+
When you are using the OpenAI Responses API, several request fields already have direct `ModelSettings` fields, so you do not need `extra_args` for them.
210+
211+
| Field | Use it for |
212+
| --- | --- |
213+
| `parallel_tool_calls` | Allow or forbid multiple tool calls in the same turn. |
214+
| `truncation` | Set `"auto"` to let the Responses API drop the oldest conversation items instead of failing when context would overflow. |
215+
| `prompt_cache_retention` | Keep cached prompt prefixes around longer, for example with `"24h"`. |
216+
| `response_include` | Request richer response payloads such as `web_search_call.action.sources`, `file_search_call.results`, or `reasoning.encrypted_content`. |
217+
| `top_logprobs` | Request top-token logprobs for output text. The SDK also adds `message.output_text.logprobs` automatically. |
218+
219+
```python
220+
from agents import Agent, ModelSettings
221+
222+
research_agent = Agent(
223+
name="Research agent",
224+
model="gpt-5.2",
225+
model_settings=ModelSettings(
226+
parallel_tool_calls=False,
227+
truncation="auto",
228+
prompt_cache_retention="24h",
229+
response_include=["web_search_call.action.sources"],
230+
top_logprobs=5,
231+
),
232+
)
233+
```
234+
235+
Use `extra_args` when you need provider-specific or newer request fields that the SDK does not expose directly at the top level yet.
236+
207237
Also, when you use OpenAI's Responses API, [there are a few other optional parameters](https://platform.openai.com/docs/api-reference/responses/create) (e.g., `user`, `service_tier`, and so on). If they are not available at the top level, you can use `extra_args` to pass them as well.
208238

209239
```python
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
# ::: agents.extensions.memory.dapr_session.DaprSession
1+
# `DaprSession`
22

3+
::: agents.extensions.memory.dapr_session.DaprSession

docs/sessions/index.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ Use this table to pick a starting point before reading the detailed examples bel
204204
| `AsyncSQLiteSession` | Async SQLite with `aiosqlite` | Extension backend with async driver support |
205205
| `RedisSession` | Shared memory across workers/services | Good for low-latency distributed deployments |
206206
| `SQLAlchemySession` | Production apps with existing databases | Works with SQLAlchemy-supported databases |
207+
| `DaprSession` | Cloud-native deployments with Dapr sidecars | Supports multiple state stores plus TTL and consistency controls |
207208
| `OpenAIConversationsSession` | Server-managed storage in OpenAI | OpenAI Conversations API-backed history |
208209
| `OpenAIResponsesCompactionSession` | Long conversations with automatic compaction | Wrapper around another session backend |
209210
| `AdvancedSQLiteSession` | SQLite plus branching/analytics | Heavier feature set; see dedicated page |
@@ -377,6 +378,36 @@ session = SQLAlchemySession("user_123", engine=engine, create_tables=True)
377378

378379
See [SQLAlchemy Sessions](sqlalchemy_session.md) for detailed documentation.
379380

381+
### Dapr sessions
382+
383+
Use `DaprSession` when you already run Dapr sidecars or want session storage that can move across different state-store backends without changing your agent code.
384+
385+
```bash
386+
pip install openai-agents[dapr]
387+
```
388+
389+
```python
390+
from agents import Agent, Runner
391+
from agents.extensions.memory import DaprSession
392+
393+
agent = Agent(name="Assistant")
394+
395+
async with DaprSession.from_address(
396+
"user_123",
397+
state_store_name="statestore",
398+
dapr_address="localhost:50001",
399+
) as session:
400+
result = await Runner.run(agent, "Hello", session=session)
401+
print(result.final_output)
402+
```
403+
404+
Notes:
405+
406+
- `from_address(...)` creates and owns the Dapr client for you. If your app already manages one, construct `DaprSession(...)` directly with `dapr_client=...`.
407+
- Pass `ttl=...` to let the backing state store expire old session data automatically when the store supports TTL.
408+
- Pass `consistency=DAPR_CONSISTENCY_STRONG` when you need stronger read-after-write guarantees.
409+
- The Dapr Python SDK also checks the HTTP sidecar endpoint. In local development, start Dapr with `--dapr-http-port 3500` as well as the gRPC port used in `dapr_address`.
410+
- See [`examples/memory/dapr_session_example.py`](https://github.com/openai/openai-agents-python/tree/main/examples/memory/dapr_session_example.py) for a full setup walkthrough, including local components and troubleshooting.
380411

381412

382413
### Advanced SQLite sessions

mkdocs.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ plugins:
124124
- ref/models/multi_provider.md
125125
- ref/mcp/server.md
126126
- ref/mcp/util.md
127+
- ref/mcp/manager.md
127128
- Tracing:
128129
- ref/tracing/index.md
129130
- ref/tracing/create.md
@@ -166,6 +167,15 @@ plugins:
166167
- ref/extensions/memory/dapr_session.md
167168
- ref/extensions/memory/encrypt_session.md
168169
- ref/extensions/memory/advanced_sqlite_session.md
170+
- Experimental Codex:
171+
- ref/extensions/experimental/codex/codex_tool.md
172+
- ref/extensions/experimental/codex/codex.md
173+
- ref/extensions/experimental/codex/codex_options.md
174+
- ref/extensions/experimental/codex/thread.md
175+
- ref/extensions/experimental/codex/thread_options.md
176+
- ref/extensions/experimental/codex/turn_options.md
177+
- ref/extensions/experimental/codex/events.md
178+
- ref/extensions/experimental/codex/items.md
169179
- locale: ja
170180
name: 日本語
171181
build: true

0 commit comments

Comments
 (0)