Skip to content

Commit a23fe13

Browse files
authored
docs: update configuration details (#2507)
1 parent 35aaaf6 commit a23fe13

4 files changed

Lines changed: 81 additions & 9 deletions

File tree

docs/config.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## API keys and clients
44

5-
By default, the SDK looks for the `OPENAI_API_KEY` environment variable for LLM requests and tracing, as soon as it is imported. If you are unable to set that environment variable before your app starts, you can use the [set_default_openai_key()][agents.set_default_openai_key] function to set the key.
5+
By default, the SDK uses the `OPENAI_API_KEY` environment variable for LLM requests and tracing. The key is resolved when the SDK first creates an OpenAI client (lazy initialization), so set the environment variable before your first model call. If you are unable to set that environment variable before your app starts, you can use the [set_default_openai_key()][agents.set_default_openai_key] function to set the key.
66

77
```python
88
from agents import set_default_openai_key
@@ -65,6 +65,26 @@ from agents import set_tracing_disabled
6565
set_tracing_disabled(True)
6666
```
6767

68+
If you want to keep tracing enabled but exclude potentially sensitive inputs/outputs from trace payloads, set [`RunConfig.trace_include_sensitive_data`][agents.run.RunConfig.trace_include_sensitive_data] to `False`:
69+
70+
```python
71+
from agents import Runner, RunConfig
72+
73+
await Runner.run(
74+
agent,
75+
input="Hello",
76+
run_config=RunConfig(trace_include_sensitive_data=False),
77+
)
78+
```
79+
80+
You can also change the default without code by setting this environment variable before your app starts:
81+
82+
```bash
83+
export OPENAI_AGENTS_TRACE_INCLUDE_SENSITIVE_DATA=0
84+
```
85+
86+
For full tracing controls, see the [tracing guide](tracing.md).
87+
6888
## Debug logging
6989

7090
The SDK defines two Python loggers (`openai.agents` and `openai.agents.tracing`) and does not attach handlers by default. Logs follow your application's Python logging configuration.
@@ -98,16 +118,18 @@ logger.addHandler(logging.StreamHandler())
98118

99119
### Sensitive data in logs
100120

101-
Certain logs may contain sensitive data (for example, user data). If you want to disable this data from being logged, set the following environment variables.
121+
Certain logs may contain sensitive data (for example, user data).
102122

103-
To disable logging LLM inputs and outputs:
123+
By default, the SDK does **not** log LLM inputs/outputs or tool inputs/outputs. These protections are controlled by:
104124

105125
```bash
106-
export OPENAI_AGENTS_DONT_LOG_MODEL_DATA=1
126+
OPENAI_AGENTS_DONT_LOG_MODEL_DATA=1
127+
OPENAI_AGENTS_DONT_LOG_TOOL_DATA=1
107128
```
108129

109-
To disable logging tool inputs and outputs:
130+
If you need to include this data temporarily for debugging, set either variable to `0` (or `false`) before your app starts:
110131

111132
```bash
112-
export OPENAI_AGENTS_DONT_LOG_TOOL_DATA=1
133+
export OPENAI_AGENTS_DONT_LOG_MODEL_DATA=0
134+
export OPENAI_AGENTS_DONT_LOG_TOOL_DATA=0
113135
```

docs/running_agents.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ Sessions automatically:
128128
- Stores new messages after each run
129129
- Maintains separate conversations for different session IDs
130130

131+
!!! note
132+
133+
Session persistence cannot be combined with server-managed conversation settings
134+
(`conversation_id`, `previous_response_id`, or `auto_previous_response_id`) in the
135+
same run. Choose one approach per call.
136+
131137
See the [Sessions documentation](sessions/index.md) for more details.
132138

133139

docs/sessions/index.md

Lines changed: 43 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,43 @@ result = await Runner.run(
222222
)
223223
```
224224

225+
### Async SQLite sessions
226+
227+
Use `AsyncSQLiteSession` when you want SQLite persistence backed by `aiosqlite`.
228+
229+
```bash
230+
pip install aiosqlite
231+
```
232+
233+
```python
234+
from agents import Agent, Runner
235+
from agents.extensions.memory import AsyncSQLiteSession
236+
237+
agent = Agent(name="Assistant")
238+
session = AsyncSQLiteSession("user_123", db_path="conversations.db")
239+
result = await Runner.run(agent, "Hello", session=session)
240+
```
241+
242+
### Redis sessions
243+
244+
Use `RedisSession` for shared session memory across multiple workers or services.
245+
246+
```bash
247+
pip install openai-agents[redis]
248+
```
249+
250+
```python
251+
from agents import Agent, Runner
252+
from agents.extensions.memory import RedisSession
253+
254+
agent = Agent(name="Assistant")
255+
session = RedisSession.from_url(
256+
"user_123",
257+
url="redis://localhost:6379/0",
258+
)
259+
result = await Runner.run(agent, "Hello", session=session)
260+
```
261+
225262
### SQLAlchemy sessions
226263

227264
Production-ready sessions using any SQLAlchemy-supported database:
@@ -315,12 +352,13 @@ Use meaningful session IDs that help you organize conversations:
315352

316353
- Use in-memory SQLite (`SQLiteSession("session_id")`) for temporary conversations
317354
- Use file-based SQLite (`SQLiteSession("session_id", "path/to/db.sqlite")`) for persistent conversations
355+
- Use async SQLite (`AsyncSQLiteSession("session_id", db_path="...")`) when you need an `aiosqlite`-based implementation
356+
- Use Redis-backed sessions (`RedisSession.from_url("session_id", url="redis://...")`) for shared, low-latency session memory
318357
- Use SQLAlchemy-powered sessions (`SQLAlchemySession("session_id", engine=engine, create_tables=True)`) for production systems with existing databases supported by SQLAlchemy
319-
- Use Dapr state store sessions (`DaprSession.from_address("session_id", state_store_name="statestore", dapr_address="localhost:50001")`) for production cloud-native deployments with support for
320-
30+ database backends with built-in telemetry, tracing, and data isolation
358+
- Use Dapr state store sessions (`DaprSession.from_address("session_id", state_store_name="statestore", dapr_address="localhost:50001")`) for production cloud-native deployments with support for 30+ database backends with built-in telemetry, tracing, and data isolation
321359
- Use OpenAI-hosted storage (`OpenAIConversationsSession()`) when you prefer to store history in the OpenAI Conversations API
322360
- Use encrypted sessions (`EncryptedSession(session_id, underlying_session, encryption_key)`) to wrap any session with transparent encryption and TTL-based expiration
323-
- Consider implementing custom session backends for other production systems (Redis, Django, etc.) for more advanced use cases
361+
- Consider implementing custom session backends for other production systems (for example, Django) for more advanced use cases
324362

325363
### Multiple sessions
326364

@@ -493,6 +531,8 @@ For detailed API documentation, see:
493531
- [`OpenAIConversationsSession`][agents.memory.OpenAIConversationsSession] - OpenAI Conversations API implementation
494532
- [`OpenAIResponsesCompactionSession`][agents.memory.openai_responses_compaction_session.OpenAIResponsesCompactionSession] - Responses API compaction wrapper
495533
- [`SQLiteSession`][agents.memory.sqlite_session.SQLiteSession] - Basic SQLite implementation
534+
- [`AsyncSQLiteSession`][agents.extensions.memory.async_sqlite_session.AsyncSQLiteSession] - Async SQLite implementation based on `aiosqlite`
535+
- [`RedisSession`][agents.extensions.memory.redis_session.RedisSession] - Redis-backed session implementation
496536
- [`SQLAlchemySession`][agents.extensions.memory.sqlalchemy_session.SQLAlchemySession] - SQLAlchemy-powered implementation
497537
- [`DaprSession`][agents.extensions.memory.dapr_session.DaprSession] - Dapr state store implementation
498538
- [`AdvancedSQLiteSession`][agents.extensions.memory.advanced_sqlite_session.AdvancedSQLiteSession] - Enhanced SQLite with branching and analytics

mkdocs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,11 @@ plugins:
155155
- ref/extensions/handoff_filters.md
156156
- ref/extensions/handoff_prompt.md
157157
- ref/extensions/litellm.md
158+
- ref/extensions/tool_output_trimmer.md
158159
- ref/extensions/memory/sqlalchemy_session.md
160+
- ref/extensions/memory/async_sqlite_session.md
161+
- ref/extensions/memory/redis_session.md
162+
- ref/extensions/memory/dapr_session.md
159163
- ref/extensions/memory/encrypt_session.md
160164
- ref/extensions/memory/advanced_sqlite_session.md
161165
- locale: ja

0 commit comments

Comments
 (0)