Merge branch 'crew/cluster1' into crew-integration

This commit is contained in:
sam committed 2026-09-15 10:33:15 +10:00
commit 49da68fb25
13 files changed
+63 -1747

No files matched your search

@@ -11,6 +11,7 @@ import (
"strconv"
"github.com/samcharles93/archie-core/internal/agentexec"
"github.com/samcharles93/archie-core/internal/config"
"github.com/samcharles93/archie-core/internal/domain/workflow"
"github.com/samcharles93/archie-core/internal/domain/workflow/skillbuild"
"github.com/samcharles93/archie-core/internal/domain/workflow/wfeval"
@@ -138,6 +139,22 @@ func newTaskRunner(providers map[string]agentexec.Provider, log *slog.Logger) ag
return agentexec.NewLoopRunner(agentexec.NewRuntime(providers), log)
}
// applyToolLimits wires the task's carried tool policy into a *LoopRunner's
// result cap/spill, so a worker-executed stage enforces the same limits the
// daemon's own chat path applies (config.Config.Tools.Policy, carried
// non-secret via TaskConfig.ToolPolicy). A runner that isn't a *LoopRunner
// (e.g. a test fake) is left untouched.
func applyToolLimits(agent agentexec.Runner, policy config.ToolPolicy) {
runner, ok := agent.(*agentexec.LoopRunner)
if !ok {
return
}
runner.Limits = agentexec.ToolLimits{
MaxResultChars: policy.MaxResultChars,
SpillDir: policy.SpillDir,
}
}
// routeTask applies the request-carried routing bindings and selects the
// workflow for a task. The daemon's package-level SetKindWorkflows state
// never crosses the process boundary, so runTask installs the resolved
@@ -191,6 +208,7 @@ func runTask(ctx context.Context, req taskrun.Request, dependencies taskDependen
if agent == nil {
return nil, fmt.Errorf("no agent runner configured for task %d", req.Task.ID)
}
applyToolLimits(agent, req.Cfg.ToolPolicy)
agent = persistentRunner{Runner: agent, enabled: req.Repo.PersistentStorage}
// A workflow run in this process publishes to an in-process *events.Bus
@@ -195,6 +195,29 @@ func TestHybridTreesPushSurfacesOwnershipReconciliationFailure(t *testing.T) {
}
}
// TestApplyToolLimitsWiresConfiguredPolicyIntoLoopRunner guards against
// regressing archie-core's tool-result cap and spill dir back to inert
// zero values on the worker path (agentexec-1 / tools-core-11): a
// *LoopRunner built for a task must carry the daemon's configured
// ToolPolicy, not the zero value NewLoopRunner leaves it at.
func TestApplyToolLimitsWiresConfiguredPolicyIntoLoopRunner(t *testing.T) {
runner := agentexec.NewLoopRunner(agentexec.NewRuntime(nil), slog.New(slog.DiscardHandler))
policy := config.ToolPolicy{MaxResultChars: 12345, SpillDir: "/var/tmp/archie-spill"}
applyToolLimits(runner, policy)
want := agentexec.ToolLimits{MaxResultChars: 12345, SpillDir: "/var/tmp/archie-spill"}
if runner.Limits != want {
t.Fatalf("runner.Limits = %+v, want %+v", runner.Limits, want)
}
}
// TestApplyToolLimitsIgnoresNonLoopRunner confirms a test-fake runner (which
// is not a *agentexec.LoopRunner) is left untouched rather than panicking.
func TestApplyToolLimitsIgnoresNonLoopRunner(t *testing.T) {
applyToolLimits(panicRunner{t}, config.ToolPolicy{MaxResultChars: 1})
}
type panicRunner struct{ t *testing.T }
func (r panicRunner) Run(context.Context, string, agentexec.Request, agentexec.ToolCallReporter) (agentexec.Result, error) {
+7
View File
@@ -173,6 +173,10 @@ var reloadableFields = map[string]bool{
// [agent] is a decode-only compatibility shim; changes have no runtime
// consumer and therefore require neither reload nor restart.
"LegacyAgent": true,
// Tools.Policy (MaxResultChars/SpillDir) is carried into TaskConfig by
// ForTask (config.go) and applied fresh per dispatch via
// agentworker.applyToolLimits. See reloadableSubFields["Tools"].
"ToolPolicy": true,
}
// reloadableSubFields are sub-fields of structs that are otherwise
@@ -188,6 +192,9 @@ var reloadableFields = map[string]bool{
var reloadableSubFields = map[string]map[string]bool{
"Containers": {"LegacyEnabled": true, "VolumeTTL": true},
"Forge": {"Host": true},
// Policy is carried into TaskConfig by ForTask (config.go); MCPServers,
// WebFetch and Minimax are not and stay requires-restart.
"Tools": {"Policy": true},
}
// changedNonReloadableFields compares old and new and returns the