Conversation
|
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c7ae5076a1
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (httpProxyUrls !== undefined) { | ||
| dispatcher = new EnvHttpProxyAgent({ | ||
| httpProxy: httpProxyUrls.httpProxy ?? '', | ||
| httpsProxy: httpProxyUrls.httpsProxy ?? '', | ||
| noProxy: resolveNoProxy(env), | ||
| headersTimeout: timeoutMs, | ||
| }); |
There was a problem hiding this comment.
Preserve the invalid-proxy fallback
When a CLI user sets KIMI_CODE_LLM_HEADERS_TIMEOUT_MS while an HTTP(S) proxy URL is malformed, this construction is outside the existing proxy factory's error handling, so the LLM request now fails with llm.failed.remote. Previously createProxyDispatcher caught invalid proxy configurations, warned, and continued with a direct connection (packages/agent-core-v2/src/_base/utils/proxy.ts:201-204). Reuse that fallback or catch this construction error so enabling the new timeout does not break users whose invalid proxy setting was already being tolerated.
Useful? React with 👍 / 👎.
| const value = Number(raw); | ||
| if (!Number.isInteger(value) || value <= 0) { |
There was a problem hiding this comment.
Reject timeout values outside Node's timer range
Values such as 3000000000 satisfy this validation and are documented as valid positive integers, but Undici schedules its header deadline with a Node timer, whose maximum delay is 2^31 - 1; Node clamps larger delays to 1 ms. As a result, a user attempting to set a very large timeout instead gets immediate headers-timeout failures on every supported LLM request, rather than the documented ten-minute SDK cap. Reject or clamp values above the timer limit (preferably to the total-request timeout) before constructing the dispatcher.
Useful? React with 👍 / 👎.
| | `KIMI_MODEL_TOP_P` | Nucleus-sampling `top_p` for every request; `kimi` provider only (global) | Number, e.g. `0.95` | | ||
| | `KIMI_MODEL_THINKING_EFFORT` | Force a thinking effort (`thinking.effort`), bypassing the model's declared `support_efforts`; `kimi` provider only | An effort value, e.g. `max` | | ||
| | `KIMI_MODEL_THINKING_KEEP` | Preserved-thinking passthrough: `thinking.keep` on `kimi`, a `clear_thinking_20251015` edit on `anthropic`; overrides `[thinking] keep` | A value the API accepts, e.g. `all`; an off-value (`false`/`0`/`no`/`off`/`none`/`null`) disables it | | ||
| | `KIMI_CODE_LLM_HEADERS_TIMEOUT_MS` | Max time (ms) an LLM request on the `openai` / `openai-responses` / `anthropic` protocols may wait for the response headers (first byte), replacing the HTTP client's default 300 s headers timeout — raise it for long non-streaming thinking; unset keeps the default; the SDK's own total request timeout (default 10 minutes) still caps each attempt; not supported for `google-genai` (its SDK exposes no dispatcher option) or behind a SOCKS proxy (requests still go through the proxy) | Positive integer; invalid values fail the request | |
There was a problem hiding this comment.
Add the required CLI changeset
This adds a documented, user-perceivable CLI environment variable, but the commit does not add a .changeset file. The next release's curated CLI changelog will therefore omit how users can configure longer LLM header waits. Add an @moonshot-ai/kimi-code changeset with a short user-facing sentence for this setting.
AGENTS.md reference: AGENTS.md:L85-L86
Useful? React with 👍 / 👎.
Requirement or Bug
新增环境变量
KIMI_CODE_LLM_HEADERS_TIMEOUT_MS,可配置 LLM 请求等待响应头的最长时间(替代 HTTP 客户端默认的 300 秒),避免长时间不返回响应头的非流式 thinking 请求在 300s 被掐断后陷入退避重试循环。Bug Reproduction Steps
N/A
Root Cause
N/A
Code Changes
packages/agent-core-v2/src/human/llm/requester/ +├── timeout.ts # resolveLlmHeadersTimeoutMs + 代理感知的 memoized dispatcher 工厂 └── bases/ ├── openai/requester.ts # createClient:解析到值时传 fetchOptions.dispatcher ├── openai-responses/requester.ts # 同上 └── anthropic/requester.ts # 同上 docs/en|zh/configuration/env-vars.md # 各新增一行变量说明只放宽 undici 的
headersTimeout(headers-only 语义),SDK 总超时仍为默认 10 分钟:单次尝试实际上限为 min(变量值, 10 分钟)。不设bodyTimeout,不碰全局 dispatcher,不影响进程内其他 fetch 用户。google-genai 的 SDK 无 dispatcher/fetchOptions 接缝,无法支持,文档已如实标注。Behavior Changes and Affected Users
KIMI_CODE_LLM_HEADERS_TIMEOUT_MS(全部现有用户)fetchOptions,undici 默认 300s headers 超时fetchOptions,RequestInit 无dispatcher)llm.failed.remote,错误消息含变量名EnvHttpProxyAgent携带同样的 headersTimeout)受影响模块与测试覆盖:
llm/requester/timeout.ts(新增)与三个 base 的createClient接线:test/llm/headers-timeout.test.ts新增 1 个用例——stub 全局 fetch 走真实 SDK,逐协议(openai / openai-responses / anthropic)断言未设置时 RequestInit 无dispatcher、设置后有;HTTP 代理下有;SOCKS 下无;非法值时请求以llm.failed.remote失败且消息含变量名。test/llm/errors.test.ts:413 用例并入「maps remaining status errors」,测试总数净增 0(根规则:加 1 删 1)。Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.