Release v1.0.2

This commit is contained in:
lpf
2026-04-08 15:25:28 +08:00
parent ce2263ac8c
commit a9169c66ff
15 changed files with 1670 additions and 450 deletions

View File

@@ -226,6 +226,8 @@ type ProviderConfig struct {
APIKey string `json:"api_key" env:"CLAWGO_PROVIDERS_{{.Name}}_API_KEY"`
APIBase string `json:"api_base" env:"CLAWGO_PROVIDERS_{{.Name}}_API_BASE"`
Models []string `json:"models" env:"CLAWGO_PROVIDERS_{{.Name}}_MODELS"`
MaxTokens int `json:"max_tokens,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
SupportsResponsesCompact bool `json:"supports_responses_compact" env:"CLAWGO_PROVIDERS_{{.Name}}_SUPPORTS_RESPONSES_COMPACT"`
Auth string `json:"auth" env:"CLAWGO_PROVIDERS_{{.Name}}_AUTH"`
TimeoutSec int `json:"timeout_sec" env:"CLAWGO_PROVIDERS_PROXY_TIMEOUT_SEC"`

View File

@@ -53,6 +53,8 @@ type NormalizedRuntimeRouterConfig struct {
type NormalizedRuntimeProviderConfig struct {
Auth string `json:"auth,omitempty"`
APIBase string `json:"api_base,omitempty"`
MaxTokens int `json:"max_tokens,omitempty"`
Temperature float64 `json:"temperature,omitempty"`
TimeoutSec int `json:"timeout_sec,omitempty"`
OAuth ProviderOAuthConfig `json:"oauth,omitempty"`
RuntimePersist bool `json:"runtime_persist,omitempty"`
@@ -143,6 +145,8 @@ func (c *Config) NormalizedView() NormalizedConfig {
view.Runtime.Providers[name] = NormalizedRuntimeProviderConfig{
Auth: pc.Auth,
APIBase: pc.APIBase,
MaxTokens: pc.MaxTokens,
Temperature: pc.Temperature,
TimeoutSec: pc.TimeoutSec,
OAuth: pc.OAuth,
RuntimePersist: pc.RuntimePersist,
@@ -232,6 +236,12 @@ func (c *Config) ApplyNormalizedView(view NormalizedConfig) {
current := c.Models.Providers[name]
current.Auth = strings.TrimSpace(item.Auth)
current.APIBase = strings.TrimSpace(item.APIBase)
if item.MaxTokens > 0 {
current.MaxTokens = item.MaxTokens
} else if item.MaxTokens == 0 {
current.MaxTokens = 0
}
current.Temperature = item.Temperature
if item.TimeoutSec > 0 {
current.TimeoutSec = item.TimeoutSec
}

View File

@@ -5,6 +5,13 @@ import "testing"
func TestNormalizedViewProjectsCoreAndRuntime(t *testing.T) {
cfg := DefaultConfig()
cfg.Agents.Router.Enabled = true
cfg.Models.Providers["openai"] = ProviderConfig{
APIBase: "https://api.openai.com/v1",
Models: []string{"gpt-5.4"},
MaxTokens: 12288,
Temperature: 0.35,
TimeoutSec: 90,
}
cfg.Agents.Subagents["coder"] = SubagentConfig{
Enabled: true,
Role: "coding",
@@ -27,4 +34,10 @@ func TestNormalizedViewProjectsCoreAndRuntime(t *testing.T) {
if !view.Runtime.Router.Enabled || view.Runtime.Router.Strategy != "rules_first" {
t.Fatalf("unexpected runtime router: %+v", view.Runtime.Router)
}
if got := view.Runtime.Providers["openai"].MaxTokens; got != 12288 {
t.Fatalf("expected provider max_tokens in normalized runtime view, got %d", got)
}
if got := view.Runtime.Providers["openai"].Temperature; got != 0.35 {
t.Fatalf("expected provider temperature in normalized runtime view, got %v", got)
}
}

View File

@@ -478,6 +478,9 @@ func validateProviderConfig(path string, p ProviderConfig) []error {
if p.TimeoutSec <= 0 {
errs = append(errs, fmt.Errorf("%s.timeout_sec must be > 0", path))
}
if p.MaxTokens < 0 {
errs = append(errs, fmt.Errorf("%s.max_tokens must be >= 0", path))
}
switch authMode {
case "", "bearer", "oauth", "none", "hybrid":
default: