Skip to content
This repository was archived by the owner on Sep 4, 2026. It is now read-only.
This repository was archived by the owner on Sep 4, 2026. It is now read-only.

模型请求 timeout 应支持配置 #23

Description

@darkkid0

背景

长时间 agent turn、慢速 OpenAI-compatible provider、代理链路或本地模型服务都可能让模型请求耗时超过默认客户端 timeout。当前 timeout 不能从配置里调整,部署时只能改代码。

当前观察

core/agent/models.py 里构造 AsyncOpenAI 时没有从应用配置传入可调 timeout。本地 workaround 是直接硬编码:

timeout=httpx.Timeout(600.0, connect=60.0)

这可以缓解长请求超时,但硬编码不适合上游:不同 provider、网络环境、部署形态需要不同 timeout 策略。

建议

在 agent/provider 配置中增加 timeout 字段,例如:

  • request_timeout_seconds
  • connect_timeout_seconds

然后在构造 AsyncOpenAI 时使用配置值。默认值可以保持保守,但允许部署者按 provider 调整。

预期收益

  • 不需要修改源码即可适配慢速或代理后的 OpenAI-compatible endpoint。
  • 对长上下文、工具调用较多、推理耗时较长的 agent turn 更稳定。
  • 避免把某个环境的 timeout 偏好硬编码进通用实现。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions