You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+116-1Lines changed: 116 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,10 +12,119 @@ The OpenAI Agents SDK is a lightweight yet powerful framework for building multi
12
12
1.[**Agents**](https://openai.github.io/openai-agents-python/agents): LLMs configured with instructions, tools, guardrails, and handoffs
13
13
2.[**Handoffs**](https://openai.github.io/openai-agents-python/handoffs/): A specialized tool call used by the Agents SDK for transferring control between agents
14
14
3.[**Guardrails**](https://openai.github.io/openai-agents-python/guardrails/): Configurable safety checks for input and output validation
15
-
4.[**Tracing**](https://openai.github.io/openai-agents-python/tracing/): Built-in tracking of agent runs, allowing you to view, debug and optimize your workflows
15
+
4.[**Sessions**](#sessions): Automatic conversation history management across agent runs
16
+
5.[**Tracing**](https://openai.github.io/openai-agents-python/tracing/): Built-in tracking of agent runs, allowing you to view, debug and optimize your workflows
16
17
17
18
Explore the [examples](examples) directory to see the SDK in action, and read our [documentation](https://openai.github.io/openai-agents-python/) for more details.
18
19
20
+
## Sessions
21
+
22
+
The Agents SDK provides built-in session memory to automatically maintain conversation history across multiple agent runs, eliminating the need to manually handle `.to_input_list()` between turns.
23
+
24
+
### Quick start
25
+
26
+
```python
27
+
from agents import Agent, Runner, SQLiteSession
28
+
29
+
# Create agent
30
+
agent = Agent(
31
+
name="Assistant",
32
+
instructions="Reply very concisely.",
33
+
)
34
+
35
+
# Create a session instance
36
+
session = SQLiteSession("conversation_123")
37
+
38
+
# First turn
39
+
result =await Runner.run(
40
+
agent,
41
+
"What city is the Golden Gate Bridge in?",
42
+
session=session
43
+
)
44
+
print(result.final_output) # "San Francisco"
45
+
46
+
# Second turn - agent automatically remembers previous context
Copy file name to clipboardExpand all lines: docs/index.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,7 @@ The [OpenAI Agents SDK](https://github.com/openai/openai-agents-python) enables
5
5
-**Agents**, which are LLMs equipped with instructions and tools
6
6
-**Handoffs**, which allow agents to delegate to other agents for specific tasks
7
7
-**Guardrails**, which enable the inputs to agents to be validated
8
+
-**Sessions**, which automatically maintains conversation history across agent runs
8
9
9
10
In combination with Python, these primitives are powerful enough to express complex relationships between tools and agents, and allow you to build real-world applications without a steep learning curve. In addition, the SDK comes with built-in **tracing** that lets you visualize and debug your agentic flows, as well as evaluate them and even fine-tune models for your application.
10
11
@@ -21,6 +22,7 @@ Here are the main features of the SDK:
21
22
- Python-first: Use built-in language features to orchestrate and chain agents, rather than needing to learn new abstractions.
22
23
- Handoffs: A powerful feature to coordinate and delegate between multiple agents.
23
24
- Guardrails: Run input validations and checks in parallel to your agents, breaking early if the checks fail.
25
+
- Sessions: Automatic conversation history management across agent runs, eliminating manual state handling.
24
26
- Function tools: Turn any Python function into a tool, with automatic schema generation and Pydantic-powered validation.
25
27
- Tracing: Built-in tracing that lets you visualize, debug and monitor your workflows, as well as use the OpenAI suite of evaluation, fine-tuning and distillation tools.
0 commit comments