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: docs/en/sgr-api/SGR-Description-API.md
+23-7Lines changed: 23 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -117,9 +117,18 @@ Create a chat completion for research tasks. This is the main endpoint for inter
117
117
-`max_tokens` (integer, optional, default: 1500): Maximum number of tokens for generation
118
118
-`temperature` (float, optional, default: 0): Generation temperature (0.0-1.0). Lower values make output more deterministic
119
119
120
-
**Special Behavior - Clarification Requests:**
120
+
**Special Behavior - Resuming an Agent in Clarification State:**
121
121
122
-
If `model` contains an agent ID (format: `{agent_name}_{uuid}`) and the agent is in `waiting_for_clarification` state, this endpoint will automatically route to the clarification handler instead of creating a new agent.
122
+
This endpoint supports two ways to resume an agent that is waiting for clarification:
123
+
124
+
| Mode | Trigger | Conversation handling |
125
+
|---|---|---|
126
+
|**Stateless (full-context)**| Agent ID found anywhere inside `messages` text | Agent's conversation is **replaced entirely** with the incoming `messages`|
127
+
|**Stateful (delta)**| Agent ID passed as the `model` field value | Incoming `messages` are **appended** to the existing conversation |
128
+
129
+
Use the **stateless mode** when integrating with a standard OpenAI-compatible chat UI that re-sends the full message history on every request. The agent detects its own ID in the message content, overwrites its conversation snapshot, and resumes execution.
130
+
131
+
Use the **stateful mode** when your client tracks context itself and only sends new messages as a delta. Pass the agent ID (format: `{agent_name}_{uuid}`) as the `model` field value.
## POST `/agents/{agent_id}/provide_clarification`
323
332
324
-
Provide clarification to an agent that is waiting for input. Resumes agent execution after receiving clarification messages.
333
+
Provide clarification to an agent that is waiting for input. Resumes agent execution after receiving clarification messages. This endpoint operates in **stateful (delta) mode**: the provided messages are *appended* to the agent's existing conversation history.
334
+
335
+
!!! tip "Alternative via `/v1/chat/completions`"
336
+
If you are using a standard OpenAI-compatible client that re-sends the full message history on each turn, prefer the **stateless mode** of `POST /v1/chat/completions`: embed the agent ID anywhere in the message text (the format `agent {agent_id} started` is already included by the agent itself at startup) and send the full context as `messages`. The server will detect the ID, replace the agent's conversation with the incoming snapshot, and resume execution.
325
337
326
338
**Path Parameters:**
327
339
@@ -342,7 +354,7 @@ Provide clarification to an agent that is waiting for input. Resumes agent execu
342
354
343
355
**Request Parameters:**
344
356
345
-
-`messages` (array, required): Clarification messages in OpenAI format (ChatCompletionMessageParam). Can contain multiple messages for complex clarifications.
357
+
-`messages` (array, required): New clarification messages in OpenAI format (ChatCompletionMessageParam). These are appended to the existing conversation — send only the new user replies, not the full history.
346
358
347
359
**Request:**
348
360
@@ -365,7 +377,7 @@ curl -X POST "http://localhost:8010/agents/sgr_agent_12345-67890-abcdef/provide_
365
377
366
378
**Streaming Response:**
367
379
368
-
Returns streaming response (SSE format) with continued research after clarification. The agent resumes execution from the point where it requested clarification.
380
+
Returns a streaming SSE response with continued research after clarification. The agent resumes execution from the point where it requested clarification.
369
381
370
382
**Error Responses:**
371
383
@@ -375,15 +387,19 @@ Returns streaming response (SSE format) with continued research after clarificat
375
387
"detail": "Agent not found"
376
388
}
377
389
```
390
+
-`400 Bad Request`: Agent is not in `waiting_for_clarification` state
391
+
```json
392
+
{
393
+
"detail": "Agent is not waiting for clarification"
394
+
}
395
+
```
378
396
-`500 Internal Server Error`: Error during clarification processing
379
397
```json
380
398
{
381
399
"detail": "Error message"
382
400
}
383
401
```
384
402
385
-
**Note:** This endpoint can also be accessed via POST `/v1/chat/completions` by using the agent ID as the `model` parameter when the agent is in `waiting_for_clarification` state.
386
-
387
403
## DELETE `/agents/{agent_id}`
388
404
389
405
Cancel a running agent's execution and remove it from storage. If the agent is currently running, it will be cancelled first before removal.
-`max_tokens` (integer, опциональный, по умолчанию: 1500): Максимальное количество токенов для генерации
118
118
-`temperature` (float, опциональный, по умолчанию: 0): Температура генерации (0.0-1.0). Меньшие значения делают вывод более детерминированным
119
119
120
-
**Особое поведение - Запросы на уточнение:**
120
+
**Особое поведение — Возобновление агента в состоянии ожидания уточнения:**
121
121
122
-
Если `model` содержит ID агента (формат: `{agent_name}_{uuid}`) и агент находится в состоянии `waiting_for_clarification`, этот endpoint автоматически перенаправит запрос на обработчик уточнений вместо создания нового агента.
122
+
Endpoint поддерживает два способа возобновить агент, находящийся в состоянии `waiting_for_clarification`:
123
+
124
+
| Режим | Триггер | Обработка разговора |
125
+
|---|---|---|
126
+
|**Stateless (полный контекст)**| ID агента обнаружен где-либо в тексте `messages`| Разговор агента **полностью заменяется** входящими `messages`|
127
+
|**Stateful (дельта)**| ID агента передан в поле `model`| Входящие `messages`**дописываются** к существующему разговору |
128
+
129
+
Используйте **режим stateless**, когда интегрируетесь через стандартный OpenAI-совместимый клиент, который каждый раз пересылает полную историю сообщений. Агент автоматически обнаружит свой ID в тексте (сообщение вида `agent {agent_id} started` добавляется агентом в самом начале работы), заменит снимок разговора и возобновит выполнение.
130
+
131
+
Используйте **режим stateful**, когда клиент сам управляет контекстом и отправляет только новые сообщения-дополнения. Передайте ID агента (формат: `{agent_name}_{uuid}`) в поле `model`.
## POST `/agents/{agent_id}/provide_clarification`
323
332
324
-
Предоставить уточнение агенту, который ожидает ввода. Возобновляет выполнение агента после получения сообщений уточнения.
333
+
Предоставить уточнение агенту, который ожидает ввода. Возобновляет выполнение агента после получения сообщений уточнения. Endpoint работает в **stateful (дельта) режиме**: переданные сообщения *дописываются* к существующей истории разговора агента.
334
+
335
+
!!! tip "Альтернатива через `/v1/chat/completions`"
336
+
Если вы используете стандартный OpenAI-совместимый клиент, который пересылает полную историю сообщений при каждом запросе, предпочтите **режим stateless** endpoint `POST /v1/chat/completions`: вставьте ID агента в любое место текста сообщений (агент сам добавляет `agent {agent_id} started` в начале работы) и передайте полный контекст в `messages`. Сервер обнаружит ID, заменит разговор агента новым снимком и возобновит выполнение.
-`messages` (array, обязательный): Сообщения уточнения в формате OpenAI (ChatCompletionMessageParam). Может содержать несколько сообщений для сложных уточнений.
357
+
-`messages` (array, обязательный): Новые сообщения уточнения в формате OpenAI (ChatCompletionMessageParam). Дописываются к существующему разговору — передавайте только новые реплики пользователя, а не полную историю.
346
358
347
359
**Запрос:**
348
360
@@ -365,7 +377,7 @@ curl -X POST "http://localhost:8010/agents/sgr_agent_12345-67890-abcdef/provide_
365
377
366
378
**Потоковый ответ:**
367
379
368
-
Возвращает потоковый ответ (формат SSE) с продолжением исследования после уточнения. Агент возобновляет выполнение с точки, где он запросил уточнение.
380
+
Возвращает потоковый SSE-ответ с продолжением исследования после уточнения. Агент возобновляет выполнение с точки, где он запросил уточнение.
369
381
370
382
**Ошибки:**
371
383
@@ -375,15 +387,19 @@ curl -X POST "http://localhost:8010/agents/sgr_agent_12345-67890-abcdef/provide_
375
387
"detail": "Agent not found"
376
388
}
377
389
```
390
+
-`400 Bad Request`: Агент не находится в состоянии `waiting_for_clarification`
391
+
```json
392
+
{
393
+
"detail": "Agent is not waiting for clarification"
394
+
}
395
+
```
378
396
-`500 Internal Server Error`: Ошибка при обработке уточнения
379
397
```json
380
398
{
381
399
"detail": "Сообщение об ошибке"
382
400
}
383
401
```
384
402
385
-
**Примечание:** Этот endpoint также доступен через POST `/v1/chat/completions`, используя ID агента в качестве параметра `model`, когда агент находится в состоянии `waiting_for_clarification`.
386
-
387
403
## DELETE `/agents/{agent_id}`
388
404
389
405
Отменить выполнение запущенного агента и удалить его из хранилища. Если агент в данный момент выполняется, он будет сначала отменен, а затем удален.
0 commit comments