diff --git a/agent/turn.go b/agent/turn.go index 8ecdd15..b51268d 100644 --- a/agent/turn.go +++ b/agent/turn.go @@ -132,6 +132,18 @@ func (ag *Agent) executeTurn(ctx context.Context, input string) string { return "" } tools := toolInfosToBackend(ti) + + // Build output format lookup from the fresh tool list. This ensures + // dynamically loaded tools (via tool_load) have their outputFormat + // available immediately, not just after a full runtime rebuild. + outputFormats := make(map[string]string, len(ti)) + for _, info := range ti { + outputFormats[info.Name] = info.OutputFormat + } + outputFormatFn := func(name string) string { + return outputFormats[name] + } + ag.cfg = agentConfig{ Backend: ag.runtime.Backend, preamble: ag.runtime.Preamble, @@ -139,7 +151,7 @@ func (ag *Agent) executeTurn(ctx context.Context, input string) string { Tools: tools, Exec: ag.runtime.Exec, ClassifyTool: ag.runtime.ClassifyTool, - OutputFormat: ag.runtime.OutputFormat, + OutputFormat: outputFormatFn, ClassifyTier: ag.runtime.ClassifyTier, GenerationParams: ag.runtime.GenParams, MaxSteps: ag.runtime.MaxSteps,