Skip to content

[Bug]: mcode 默认不走系统代理,导致 provider test 在仅有代理出口的机器上固定 10000ms 超时 #175

Description

@yxd0379

Product or interface

CLI - interactive TUI

Version

0.4.12

Platform

Linux

OS version and architecture

openEuler 24.03 (LTS-SP1) aarch64

Issue area

Startup / install / update

Desktop log upload ID (optional)

No response

Steps to reproduce

这是一个代理不支持的常见问题,如果用国外 API BYOK 的方式就会触发问题。

我们机器仅有代理出口,所以同样触发了这个问题。但是这个问题并不只是在这里触发。MiniMax 给 FrontierHarness Eval 的 PR 中也提到了这一问题。这是一个普适性问题。

$ echo $http_proxy;echo $https_proxy;echo $socks_proxy;
http://127.0.0.1:7890
http://127.0.0.1:7890


$ mcode provider add \
  --name "ds4.1flash" \
  --base-url "https://api.deepseek.com/anthropic" \
  --api-format anthropic-messages \
  --model "deepseek-flash[1m]" \
  --use

$ mcode provider test provider-7b0fdd --model deepseek-flash
Provider test failed: Request timed out after 10000ms. Check the URL, API key, and model ID, then retry.

使用 MiniMax 给 FrontierHarness Eval 的 PR 中类似的 proxy-adapter 可以解决

// file: /tmp/mcode-proxy.cjs
const { EnvHttpProxyAgent, setGlobalDispatcher } = require('/tmp/mcode-proxy/node_modules/undici');
if (!process.env.HTTPS_PROXY && !process.env.HTTP_PROXY) {
  throw new Error('HTTP(S)_PROXY is required');
}
setGlobalDispatcher(new EnvHttpProxyAgent());
$ NODE_OPTIONS='--require=/tmp/mcode-proxy.cjs' \
  mcode provider test provider-851e29 --model deepseek-flash --json
{
  "success": true,
  "status": {
    "state": "available",
    "lastTestedAt": 1789782605854
  }
}

$ NODE_OPTIONS='--require=/tmp/mcode-proxy.cjs' \
  mcode exec --cwd /tmp --permission off --max-steps 2 --timeout 45s \
  --output-format json \
  --model custom_provider:provider-851e29/deepseek-flash \
  'Reply with exactly OK and do not inspect or modify any files.'

{"status":"succeeded","output":"OK","model":{"providerId":"custom_provider:provider-851e29","modelId":"deepseek-flash","protocol":"openai-completions"},"durationMs":1247}

Expected and actual behavior

期望行为:mcode 支持代理,避免代理情况下超时报错发生。

Redacted error summary

Screenshots

Image

Before submitting

  • I have searched existing issues.
  • I have included my version and removed sensitive information.

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

    bugSomething isn't workingcliStandalone mcode: TUI, headless, ACP and source builds/tooling

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions