feat: support custom headers in LLM runner (EVOLVER_LLM_HEADERS)
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 76/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, nodejs
Hướng nghiên cứu
Start by locating llmRunner.js and readLlmRunnerConfig(), then follow how its returned configuration reaches complete(). Support the documented single-header and JSON formats, merge the parsed values with the existing request headers, and verify that requests include custom headers without losing the defaults.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
问题
内置的 llm runner(llmRunner.js)在 complete() 函数中硬编码了 HTTP 请求头:
- "" + + "" + + "javascript
headers: { 'content-type': 'application/json', authorization: Bearer \ }, - "" + + "" + + "" +
某些 OpenAI 兼容的 API 提供商需要额外的请求头来进行路由/认证。例如,OpenCode Go 需要 + "" + x-opencode-session + "" + 头来进行请求路由:
- "" + + "" + + "json
{
"error": {
"type": "MissingSessionID",
"message": "Request is missing x-opencode-session and cannot be routed efficiently."
}
} - "" + + "" + + "" +
没有这个头,API 会返回 400 Bad Request。
建议方案
通过环境变量 + "" + EVOLVER_LLM_HEADERS + "" + 支持自定义请求头:
简单格式(单个头):
- "" + + "" + + "ash
export EVOLVER_LLM_HEADERS='x-opencode-session:evolver-autoexec-12345' - "" + + "" + + "" +
JSON 格式(多个头):
- "" + + "" + + "ash
export EVOLVER_LLM_HEADERS='{"x-opencode-session":"evolver-12345","user-agent":"my-agent/1.0"}' - "" + + "" + + "" +
实现建议
在 + "" +
eadLlmRunnerConfig() + "" + 中解析 + "" + EVOLVER_LLM_HEADERS + "" + 并合并到请求头:
- "" + + "" + + "javascript
// readLlmRunnerConfig
const rawHeaders = env['EVOLVER_LLM_HEADERS'] ?? '';
const extraHeaders = rawHeaders.startsWith('{')
? JSON.parse(rawHeaders)
: Object.fromEntries(rawHeaders.split(',').map(h => h.split(':').map(s => s.trim())));
return { apiKey, baseUrl, model, maxTurns, maxFileBytes, extraHeaders };
// complete()
const response = await fetchFn(\/chat/completions, {
method: 'POST',
headers: {
'content-type': 'application/json',
authorization: \Bearer \,
...config.extraHeaders,
},
body: JSON.stringify({ model: config.model, messages, tools: TOOLS, tool_choice: 'auto' }),
signal,
});
- "" + + "" + + "" +
临时解决方案
目前使用本地代理来添加所需的请求头,然后转发到上游 API。这虽然可行,但增加了一个额外的进程和网络跳转。
环境信息
- Evolver: 2.0.37
- OS: Windows 11
- Node: v24.18.1
- API 提供商: OpenCode Go ( + "" + https://opencode.ai/zen/go/v1 + "" + )
Problem
The built-in llm runner (llmRunner.js) hardcodes HTTP headers in the complete() function:
- "" + + "" + + "javascript
headers: { 'content-type': 'application/json', authorization: \Bearer \ }, - "" + + "" + + "" +
Some OpenAI-compatible API providers require additional headers for routing/authentication. For example, OpenCode Go requires + "" + x-opencode-session + "" + for request routing:
- "" + + "" + + "json
{
"error": {
"type": "MissingSessionID",
"message": "Request is missing x-opencode-session and cannot be routed efficiently."
}
} - "" + + "" + + "" +
Without this header, the API returns 400 Bad Request.
Proposed Solution
Add support for custom headers via environment variable + "" + EVOLVER_LLM_HEADERS + "" + :
Simple format (single header):
- "" + + "" + + "ash
export EVOLVER_LLM_HEADERS='x-opencode-session:evolver-autoexec-12345' - "" + + "" + + "" +
JSON format (multiple headers):
- "" + + "" + + "ash
export EVOLVER_LLM_HEADERS='{"x-opencode-session":"evolver-12345","user-agent":"my-agent/1.0"}' - "" + + "" + + "" +
Implementation
In + "" +
eadLlmRunnerConfig() + "" + , parse + "" + EVOLVER_LLM_HEADERS + "" + and merge into request headers:
- "" + + "" + + "javascript
// readLlmRunnerConfig
const rawHeaders = env['EVOLVER_LLM_HEADERS'] ?? '';
const extraHeaders = rawHeaders.startsWith('{')
? JSON.parse(rawHeaders)
: Object.fromEntries(rawHeaders.split(',').map(h => h.split(':').map(s => s.trim())));
return { apiKey, baseUrl, model, maxTurns, maxFileBytes, extraHeaders };
// complete()
const response = await fetchFn(\/chat/completions, {
method: 'POST',
headers: {
'content-type': 'application/json',
authorization: \Bearer \,
...config.extraHeaders,
},
body: JSON.stringify({ model: config.model, messages, tools: TOOLS, tool_choice: 'auto' }),
signal,
});
- "" + + "" + + "" +
Workaround
Currently using a local proxy that adds the required header before forwarding to the upstream API. This works but adds an extra process and network hop.
Environment
- Evolver: 2.0.37
- OS: Windows 11
- Node: v24.18.1
- API Provider: OpenCode Go ( + "" + https://opencode.ai/zen/go/v1 + "" + )
- Ngôn ngữ chính
- JavaScript
- Star
- 9.1k
- Fork
- 848
- Merge trung bình
- 14 giờ 39 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của EvoMap/evolver
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
[Windows] fdatasyncSync on read-only fd throws EPERM, blocks node credential snapshot (canonicalIdentityLock.js)Có thể đã có người làm @scui73414-bot đã nhận 64 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Tất cả issue của EvoMap/evolver
Issue tương tự
-
generate_image reference URL guard lets through IPv4-mapped IPv6 hosts and 100.64.0.0/10Có thể đã có người làm @goranai đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
NL-BioImaging/OMERO.biomero#92 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug: juros do parcelamento travados em 1x no gateway Rede Débito e Crédito 3DS (woo-rede 5.6.0)Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
LinkNacional/woo-rede#367 ·
-
Docs: 1 broken linkĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug Next.js
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
getsentry/sentry-wizard#1397 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày