Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/mkdocs/en/graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@ Common options:
- input_mapper / output_mapper: Parent-child state mapping (explicit configuration recommended)
- config / callbacks: Same as add_node

When a child Agent emits a `LongRunningEvent`, `add_agent_node` promotes it to a parent GraphAgent `interrupt`: the parent graph does not execute downstream nodes, and the Runner event preserves the original tool name and arguments. After the client submits the matching `FunctionResponse`, the parent graph resumes the current Agent node and the SDK maps the response back to the child's original function call. The graph continues only after the child Agent reaches a final result. This supports multiple HITL rounds in one node and persists child state in the SessionService-backed checkpoint for process-restart recovery.

When the Agent node is a TeamAgent, the Leader can use the same HITL flow. Regular Team Members still must not be configured with or invoke `LongRunningFunctionTool`.

GraphAgent does not require (nor support) registering Agent nodes via sub_agents; composition relationships are handled uniformly through add_agent_node.

## Advanced Usage
Expand Down
26 changes: 26 additions & 0 deletions docs/mkdocs/en/model.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,32 @@ model = OpenAIModel(
)
```

#### Responses API

`OpenAIModel` uses Chat Completions by default. Enable the Responses API explicitly for OpenAI or compatible
providers that expose `/v1/responses`:

```python
model = OpenAIModel(
model_name="your-responses-model",
api_key="your-api-key",
base_url="https://api.openai.com/v1",
use_responses_api=True,
responses_api_params={
"store": False,
"reasoning": {"summary": "auto"},
},
)
```

The switch is opt-in so existing OpenAI-compatible providers continue to use Chat Completions. The adapter maps
conversation history, function calls and `function_call_output` items, structured output, semantic streaming events,
reasoning summaries, and token usage into the existing tRPC-Agent types. When `store=False`, the SDK automatically
requests `reasoning.encrypted_content` so reasoning items can be replayed with tool outputs in the next turn.

`responses_api_params` accepts Responses-only fields such as `store`, `reasoning`, `include`, and `truncation`.
`model`, `input`, and `stream` are managed by `OpenAIModel` and cannot be overridden there.

#### Advanced Usage

Since version `1.1.10`, `OpenAIModel` supports passing a shared HTTP client provider to enable connection reuse. By default, `OpenAIModel` creates a temporary HTTP client for each model-service request. If you want to reuse connections, use the following configuration:
Expand Down
4 changes: 4 additions & 0 deletions docs/mkdocs/zh/graph.md
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,10 @@ graph.add_agent_node(
- input_mapper / output_mapper:父子状态映射(推荐显式配置)
- config / callbacks:同 add_node

当子 Agent 发出 `LongRunningEvent` 时,`add_agent_node` 会将其提升为父 GraphAgent 的 `interrupt`:父图不会执行后继节点,Runner 返回的事件保留原工具名和参数。客户端提交对应 `FunctionResponse` 后,父图恢复当前 Agent 节点,SDK 将响应映射回子 Agent 的原始 function call;只有子 Agent 最终完成后父图才继续。该机制支持同一节点多轮 HITL,并将 child state 写入 SessionService-backed checkpoint,服务重启后仍可恢复。

TeamAgent 作为 Agent 节点时同样支持 Leader 发起 HITL;普通 Team Member 仍不允许配置或调用 `LongRunningFunctionTool`。

GraphAgent 不需要(也不支持)通过 sub_agents 注册 Agent 节点;组合关系统一用 add_agent_node 完成。

## 进阶用法
Expand Down
25 changes: 25 additions & 0 deletions docs/mkdocs/zh/model.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,31 @@ model = OpenAIModel(
)
```

#### Responses API

`OpenAIModel` 默认仍使用 Chat Completions。对于 OpenAI 或提供 `/v1/responses` 的兼容服务,需要显式开启:

```python
model = OpenAIModel(
model_name="your-responses-model",
api_key="your-api-key",
base_url="https://api.openai.com/v1",
use_responses_api=True,
responses_api_params={
"store": False,
"reasoning": {"summary": "auto"},
},
)
```

该开关默认关闭,现有 OpenAI-compatible 服务不会改变调用路径。适配层会把多轮消息、函数调用及
`function_call_output`、结构化输出、语义化流式事件、reasoning summary 和 token usage 映射为现有
tRPC-Agent 类型。设置 `store=False` 时,SDK 会自动请求 `reasoning.encrypted_content`,以便下一轮
连同工具结果一起回放 reasoning item。

`responses_api_params` 可传入 `store`、`reasoning`、`include`、`truncation` 等 Responses 专用字段;
`model`、`input`、`stream` 由 `OpenAIModel` 管理,不能在此覆盖。

#### 高级用法

从版本 `1.1.10`之后 OpenAIModel 支持传入共享的 http client 来解决连接复用的场景,当前的 OpenAIModel 默认每次都会创建临时的 http client 去访问模型服务;如果期望连接复用可以使用如下的方式
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ classifiers = [
]
dependencies = [
"pydantic>=2.11.3",
"openai>=1.3.0",
"openai>=1.66.0",
"mcp>=1.10.1",
"aiohttp",
"httpx>=0.27.0",
Expand Down
Loading
Loading