词元之母TOK.MOM - 平台充值汇率 1:1 即 1 人民币充值到账 1 美元,支持一个 Key 调用近 600+ 海内外模型,限时特价模型低至 1 折,欢迎上岸!
系统性地诊断和解决问题

| 平台 | 路径 |
|---|---|
| macOS/Linux | ~/.local/share/opencode/log/ |
| Windows | %USERPROFILE%\.local\share\opencode\log\ |
2025-01-09T123456.log),保留最近 10 个。| 数据类型 | 路径 |
|---|---|
| 配置文件 | ~/.config/opencode/opencode.json |
| 认证信息 | ~/.local/share/opencode/auth.json |
| 日志 | ~/.local/share/opencode/log/ |
| 项目数据 | ~/.local/share/opencode/storage/ |
| 缓存 | ~/.cache/opencode/ |
zsh: command not found: opencodeProviderInitError: Failed to initialize provider/connect 配置AuthenticationError: Invalid API keyError: 403 Forbidden
Please reauthenticate with the copilot provider to ensure
your credentials work properly with OpenCode.RateLimitError: quota exceededAI_APICallError: API call failedProviderModelNotFoundError: Model not found<providerId>/<modelId>anthropic/claude-sonnet-4-20250514openai/gpt-4odeepseek/deepseek-chat# 压缩上下文
/compact
# 新建会话
/new
# 切换模型
/modelsToo Many Requests、Provider is overloaded 这类临时错误时,OpenCode 会自动重试,你不需要手动操作。| 参数 | 值 | 说明 |
|---|---|---|
| 初始延迟 | 2 秒 | 首次重试的等待时间 |
| 退避因子 | 2x | 每次重试延迟翻倍 |
| 最大延迟(无响应头) | 30 秒 | 提供商没返回 Retry-After 头时 的上限 |
| 最大延迟(有响应头) | 按响应头 | 提供商返回了 Retry-After 头时,按其指定的等待时间 |
首次重试: 2 秒
第二次: 4 秒
第三次: 8 秒
第四次: 16 秒
第五次: 30 秒(触及上限,不再增长)Retry-After 或 Retry-After-Ms 响应头,OpenCode 会优先使用提供商指定的等待时间,不受 30 秒上限限制。| 错误 | 是否重试 | 说明 |
|---|---|---|
Too Many Requests (429) | ✅ 自动重试 | 速率限制 |
Provider is overloaded (503) | ✅ 自动重试 | 服务过载 |
Rate Limited | ✅ 自动重试 | 频率限制 |
| 上下文溢出 | ❌ 不重试 | 需要压缩或新建会话 |
| 认证失败 (401) | ❌ 不重试 | 需要修复 API Key |
| 免费额度用完 | ❌ 不重试 | 提示充值链接 |
| 限制 | 默认值 | 说明 |
|---|---|---|
| 最大行数 | 2,000 行 | 超过会被截断 |
| 最大字节数 | 50 KB | 超过会被截断 |
| 完整输出保留 | 7 天 | 截断后的完整文件会自动清理 |
...2000+ lines truncated...
The tool call succeeded but the output was truncated.
Full output saved to: /path/to/tool-output/tool_xxx
Use Grep to search the full content or Read with offset/limit
to view specific sections.offset 和 limit 参数分段查看The user rejected permission to use this specific tool call.| 操作 | 默认权限 | 说明 |
|---|---|---|
| 读取普通文件 | ✅ 允许 | 大多数文件直接读取 |
读取 .env 文件 | ⚠️ 需确认 | 保护敏感配置(API Key 等) |
读取 .env.* 文件 | ⚠️ 需确认 | 如 .env.local、.env.production |
读取 .env.example | ✅ 允许 | 示例文件没有敏感信息 |
| 访问项目外目录 | ⚠️ 需确认 | 防止越权访问 |
| 编辑文件(Build 模式) | ✅ 允许 | Build 模式默认可写 |
| 编辑文件(Plan 模式) | ❌ 拒绝 | Plan 模式禁止编辑普通文件(计划文件除外) |
| 执行 Bash 命令 | ✅ 允许 | 默认允许 |
y 确认a 键,该会话内不再询问同类操作opencode.json 中设置权限策略{
"permission": {
"read": "allow",
"edit": "allow",
"bash": "ask"
}
}{
"permission": {
"read": {
"*": "allow",
"*.env": "allow"
}
}
}ETIMEDOUT / ECONNREFUSED / ECONNRESETUNABLE_TO_VERIFY_LEAF_SIGNATURE
CERT_HAS_EXPIREDallow 或 asky 确认/undo 没有效果EACCES: permission deniedopencode --version,确认是最新版opencode.json 语法是否正确?(用 jq . 验证 JSON 格式)opencode auth list,API Key 是否有效?OAuth 是否过期?curl 测试)| 错误码 | 含义 | 可能原因 | 是否自动重试 |
|---|---|---|---|
| 400 | 请求格式错误 | 无效参数、缺少必填字段 | ❌ |
| 401 | 认证失败 | API Key 无效或过期 | ❌ |
| 403 | 权限不足 | 没有访问该模型的权限 | ❌ |
| 404 | 资源不存在 | 模型名称错误或已下线 | ⚠️ OpenAI 有时误报 |
| 413 | 请求体过大 | 上下文溢出(Cerebras/Mistral) | ❌ |
| 429 | 请求过多 | 触发速率限制或配额限制 | ✅ |
| 2000+ | 服务器错误 | 提供商内部错误 | ✅ |
| 503 | 服务不可用 | 提供商维护或过载 | ✅ |
| 错误类型 | 含义 | 解决方案 |
|---|---|---|
ContextOverflowError | 上下文溢出 | /compact 压缩或 /new 新建会话 |
AI_APICallError | API 调用失败 | 检查网络和认证 |
ProviderInitError | 提供商初始化失败 | 检查配置和认证 |
ProviderModelNotFoundError | 模型不存在 | 检查模型名称格式 provider/model |
RejectedError | 用户拒绝了权限 | 在权限提示时按 y 允许 |
DeniedError | 配置规则拒绝了操作 | 检查 opencode.json 的 permission 配置 |
| 提供商 | 错误信息模式 |
|---|---|
| Anthropic | prompt is too long |
| OpenAI | exceeds the context window |
| Google Gemini | input token count exceeds the maximum |
| DeepSeek | maximum context length is X tokens |
| OpenRouter | maximum context length is X tokens |
| Groq | reduce the length of the messages |
| Amazon Bedrock | input is too long for requested model |
| xAI (Grok) | maximum prompt length is X |
| GitHub Copilot | exceeds the limit of X |
| llama.cpp | exceeds the available context size |
| LM Studio | greater than the context length |
| Cerebras/Mistral | 400 (no body) / 413 (no body) |
| MiniMax | context window exceeds limit |
| Moonshot/Kimi | exceeded model token limit |
| 通用 fallback | context length exceeded |
/compact 压缩上下文或 /new 新建会话。