fix: harden task and chat execution
Task runs now preserve real model context limits, provider usage, baseline-repair spend, commit identity, durable agent-finish telemetry, and useful timeline details without imposing a token cap. Dashboard forge links are canonical per owning GitHub or Gitea identity. Chat turn claims acquire SQLite writer intent before reading, eliminating the concurrent SQLITE_BUSY snapshot race.
This commit is contained in:
1 parent
9e6f507c06
commit
a825db283c
36 files changed
+874
-286
No files matched your search
@@ -11,15 +11,19 @@ import (
|
||||
|
||||
func applyModelCatalog(cfg *config.Config, snapshot modelcatalog.Snapshot) []string {
|
||||
discovered := make(map[string]config.Provider, len(snapshot.Providers))
|
||||
limits := make(map[string]config.ModelLimits)
|
||||
var models []string
|
||||
for _, provider := range snapshot.Providers {
|
||||
discovered[provider.ID] = config.Provider{
|
||||
Class: provider.Class, APIKeyEnv: provider.APIKeyEnv, BaseURL: provider.BaseURL,
|
||||
}
|
||||
for _, model := range provider.Models {
|
||||
models = append(models, provider.ID+"/"+model.ID)
|
||||
ref := provider.ID + "/" + model.ID
|
||||
models = append(models, ref)
|
||||
limits[ref] = config.ModelLimits{ContextWindow: model.ContextWindow, MaxOutputTokens: model.MaxOutputTokens}
|
||||
}
|
||||
}
|
||||
cfg.ModelLimits = limits
|
||||
cfg.Providers = mergeProviders(discovered, cfg.Providers)
|
||||
for i := range cfg.Identities {
|
||||
cfg.Identities[i].Providers = mergeProviders(discovered, cfg.Identities[i].Providers)
|
||||
|
||||
@@ -23,7 +23,7 @@ func TestApplyModelCatalogNormalizesEveryExecutionScope(t *testing.T) {
|
||||
{
|
||||
ID: "openai", Class: "openai", APIKeyEnv: "OPENAI_API_KEY",
|
||||
BaseURL: "https://api.openai.test/v1",
|
||||
Models: []modelcatalog.Model{{ID: "gpt-tool"}},
|
||||
Models: []modelcatalog.Model{{ID: "gpt-tool", ContextWindow: 128_000, MaxOutputTokens: 16_000}},
|
||||
},
|
||||
{
|
||||
ID: "anthropic", Class: "anthropic", APIKeyEnv: "ANTHROPIC_API_KEY",
|
||||
@@ -49,4 +49,7 @@ func TestApplyModelCatalogNormalizesEveryExecutionScope(t *testing.T) {
|
||||
if !reflect.DeepEqual(models, wantModels) {
|
||||
t.Fatalf("models = %v, want %v", models, wantModels)
|
||||
}
|
||||
if got := cfg.ModelLimits["openai/gpt-tool"]; got.ContextWindow != 128_000 || got.MaxOutputTokens != 16_000 {
|
||||
t.Fatalf("model limits = %+v, want catalog capacity", got)
|
||||
}
|
||||
}
|
||||
+16
-4
@@ -145,11 +145,23 @@ var reloadableFields = map[string]bool{
|
||||
"Budgets": true,
|
||||
"Dispatch": true,
|
||||
"Models": true,
|
||||
"ModelLimits": true,
|
||||
"Notify": true,
|
||||
// Per-poll reads off the live config in pollIssuesWithConfig:
|
||||
// cfg.Label feeds IssuesWithLabel (daemon.go:359,390), cfg.BotUser
|
||||
// feeds AssignedIssues (:368,381). Not carried by ForTask, so
|
||||
// pinned by hand in TestReloadableFieldsCoverForTaskSnapshot.
|
||||
// BotUser/BotEmail used to be poll-path only; ForTask now carries both
|
||||
// into the task snapshot as well, because the sandboxed worker builds
|
||||
// its own worktree.Manager and signs its own commits (agentworker
|
||||
// task_execution.go, config.go ForTask). The commit identity is
|
||||
// therefore per-dispatch and does reload. The startup-built daemon
|
||||
// trees (bootstrap.go:654) still capture both, but only to record
|
||||
// user.name/user.email in the clone's own .git/config
|
||||
// (worktree.go setIdentity) -- cosmetic, not the signature go-git
|
||||
// commits with -- so a reload applies where it counts and this stays
|
||||
// reloadable rather than requires-restart.
|
||||
"BotEmail": true,
|
||||
// cfg.Label additionally feeds IssuesWithLabel per poll cycle
|
||||
// (daemon.go:359,390) and cfg.BotUser feeds AssignedIssues (:364,377).
|
||||
// Label is not carried by ForTask, so it is pinned by hand in
|
||||
// TestReloadableFieldsCoverForTaskSnapshot.
|
||||
"Label": true,
|
||||
"BotUser": true,
|
||||
// Worked example of the every-consumer criterion above: the sole
|
||||
|
||||
@@ -287,9 +287,11 @@ func TestReloadableFieldsCoverForTaskSnapshot(t *testing.T) {
|
||||
t.Errorf("ForTask field %s is not allowlisted as reloadable", name)
|
||||
}
|
||||
}
|
||||
// The poll-path fields (Label, BotUser) are not carried by ForTask;
|
||||
// pin them explicitly so a refactor that moves their read site does
|
||||
// not silently drop the allowlist entry.
|
||||
// Label is not carried by ForTask; BotUser now is, but it is also read
|
||||
// on the poll path independently of the task snapshot. Pin both by hand
|
||||
// so a refactor that moves either read site -- including one that drops
|
||||
// BotUser from ForTask again -- does not silently drop the allowlist
|
||||
// entry the poll path still depends on.
|
||||
for _, name := range []string{"Label", "BotUser"} {
|
||||
if !reloadableFields[name] {
|
||||
t.Errorf("poll-path field %s is not allowlisted as reloadable", name)
|
||||
|
||||
Reference in new issue
Block a user