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
Agents do nothing by themselves – you **run** them with the `Runner` class or the `run()` utility.
13
15
@@ -95,6 +97,32 @@ Each call to `runner.run()` (or `run()` utility) represents one **turn** in your
95
97
96
98
See [the chat example](https://github.com/openai/openai-agents-js/tree/main/examples/basic/chat.ts) for an interactive version.
97
99
100
+
### Server-managed conversations
101
+
102
+
You can let the OpenAI Responses API persist conversation history for you instead of sending your entire local transcript on every turn. This is useful when you are coordinating long conversations or multiple services. See the [Conversation state guide](https://platform.openai.com/docs/guides/conversation-state?api-mode=responses) for details.
103
+
104
+
OpenAI exposes two ways to reuse server-side state:
105
+
106
+
#### 1. `conversationId` for an entire conversation
107
+
108
+
You can create a conversation once using [Conversations API](https://platform.openai.com/docs/api-reference/conversations/create) and then reuse its ID for every turn. The SDK automatically includes only the newly generated items.
109
+
110
+
<Code
111
+
lang="typescript"
112
+
code={conversationIdExample}
113
+
title="Reusing a server conversation"
114
+
/>
115
+
116
+
#### 2. `previousResponseId` to continue from the last turn
117
+
118
+
If you want to start only with Responses API anyway, you can chain each request using the ID returned from the previous response. This keeps the context alive across turns without creating a full conversation resource.
119
+
120
+
<Code
121
+
lang="typescript"
122
+
code={previousResponseIdExample}
123
+
title="Chaining with previousResponseId"
124
+
/>
125
+
98
126
## Exceptions
99
127
100
128
The SDK throws a small set of errors you can catch:
0 commit comments