Skip to content
28 changes: 23 additions & 5 deletions docs/guides/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ shell: bash
tool_timeout_sec: 20
runtime:
max_no_progress_streak: 3
max_repeat_cycle_streak: 3
assets:
max_session_asset_bytes: 20971520
max_session_assets_total_bytes: 20971520

tools:
webfetch:
Expand Down Expand Up @@ -90,6 +94,9 @@ context:
| 字段 | 说明 |
|------|------|
| `runtime.max_no_progress_streak` | 连续”无进展”轮次熔断阈值,默认 `3`;streak 达到 `limit-1`(默认第 2 轮)时向模型注入一次系统级纠偏提示,达到 `limit`(默认第 3 轮)时终止运行 |
| `runtime.max_repeat_cycle_streak` | 连续“重复调用同一工具参数”轮次熔断阈值,默认 `3`;达到阈值后终止运行 |
| `runtime.assets.max_session_asset_bytes` | 单个 `session_asset` 最大原始字节数,默认 `20971520`(20 MiB);`0` 或未配置时回退默认值 |
| `runtime.assets.max_session_assets_total_bytes` | 单次请求可携带的 `session_asset` 原始总字节上限,默认 `20971520`(20 MiB);`0` 或未配置时回退默认值 |

### `tools` 字段

Expand Down Expand Up @@ -141,9 +148,9 @@ name: company-gateway
driver: openaicompat
api_key_env: COMPANY_GATEWAY_API_KEY
model_source: discover
openai_compatible:
base_url: https://llm.example.com/v1
api_style: chat_completions
base_url: https://llm.example.com/v1
chat_endpoint_path: /chat/completions
discovery_endpoint_path: /models
```

`model_source` 语义如下:
Expand All @@ -158,8 +165,8 @@ name: company-gateway-manual
driver: openaicompat
api_key_env: COMPANY_GATEWAY_API_KEY
model_source: manual
openai_compatible:
base_url: https://llm.example.com/v1
base_url: https://llm.example.com/v1
chat_endpoint_path: /chat/completions
models:
- id: gpt-4o-mini
name: GPT-4o Mini
Expand All @@ -171,6 +178,17 @@ models:
- 老配置未声明 `model_source` 时,默认按 `discover` 处理。
- `manual` 模式下必须提供 `models`,否则会在加载/创建阶段报错。
- `manual` 模式会忽略 discovery 相关字段(如 `discovery_endpoint_path`、`discovery_response_profile`)。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Low] This bullet still mentions discovery_response_profile, but that field was removed from the custom provider schema in this PR. Please update the sentence to only reference currently supported discovery fields to avoid operator confusion.

- 旧版嵌套字段(如 `openai_compatible/gemini/anthropic`)在严格校验下会被拒绝,升级前请先执行迁移脚本:

```bash
go run ./scripts/migrate_provider_yaml.go --base-dir ~/.neocode
```

仅预览不落盘:

```bash
go run ./scripts/migrate_provider_yaml.go --base-dir ~/.neocode --dry-run
```

## Auto Compact 失败与校验补充

Expand Down
6 changes: 5 additions & 1 deletion internal/app/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ func newMemoExtractorAdapter(
}

generator := textGenAdapter(func(ctx context.Context, prompt string, msgs []providertypes.Message) (string, error) {
p, err := factory.Build(ctx, resolved.ToRuntimeConfig())
runtimeConfig, err := resolved.ToRuntimeConfig()
if err != nil {
return "", err
}
p, err := factory.Build(ctx, runtimeConfig)
if err != nil {
return "", err
}
Expand Down
27 changes: 9 additions & 18 deletions internal/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ func testDefaultProviderConfig() ProviderConfig {
BaseURL: testBaseURL,
Model: testModel,
APIKeyEnv: testAPIKeyEnv,
APIStyle: providerpkg.OpenAICompatibleAPIStyleChatCompletions,
Source: ProviderSourceBuiltin,
}
}
Expand Down Expand Up @@ -910,15 +909,13 @@ func TestAssembleProvidersRejectsIdenticalDuplicateCustomProviderNames(t *testin
Driver: "openaicompat",
BaseURL: "https://example.com/v1",
APIKeyEnv: "COMPANY_GATEWAY_API_KEY",
APIStyle: "responses",
Source: ProviderSourceCustom,
},
{
Name: "company-gateway",
Driver: "openaicompat",
BaseURL: "https://example.com/v1",
APIKeyEnv: "COMPANY_GATEWAY_API_KEY",
APIStyle: "responses",
Source: ProviderSourceCustom,
},
}
Expand Down Expand Up @@ -1913,19 +1910,19 @@ func TestToRuntimeConfigMapsAllFields(t *testing.T) {

resolved := ResolvedProviderConfig{
ProviderConfig: ProviderConfig{
Name: "test-provider",
Driver: "gemini",
BaseURL: "https://generativelanguage.googleapis.com/v1beta/openai",
Model: "gemini-2.5-flash",
APIKeyEnv: "TEST_ENV_KEY",
APIStyle: "responses",
DeploymentMode: "vertex",
APIVersion: "v1beta",
Name: "test-provider",
Driver: "gemini",
BaseURL: "https://generativelanguage.googleapis.com/v1beta/openai",
Model: "gemini-2.5-flash",
APIKeyEnv: "TEST_ENV_KEY",
},
APIKey: "resolved-secret-key",
}

got := resolved.ToRuntimeConfig()
got, err := resolved.ToRuntimeConfig()
if err != nil {
t.Fatalf("ToRuntimeConfig() error = %v", err)
}
if got.Name != "test-provider" {
t.Fatalf("expected Name=test-provider, got %q", got.Name)
}
Expand All @@ -1938,12 +1935,6 @@ func TestToRuntimeConfigMapsAllFields(t *testing.T) {
if got.APIKey != "resolved-secret-key" {
t.Fatalf("expected APIKey=resolved-secret-key, got %q", got.APIKey)
}
if got.DeploymentMode != "vertex" {
t.Fatalf("expected DeploymentMode=vertex, got %q", got.DeploymentMode)
}
if got.APIVersion != "v1beta" {
t.Fatalf("expected APIVersion=v1beta, got %q", got.APIVersion)
}
}

func TestLoaderLoadWithCanceledContext(t *testing.T) {
Expand Down
Loading
Loading