fix(agent): refresh outputFormat lookup on each turn
The OutputFormat function was set once at runtime build time and stored in ag.runtime.OutputFormat. When tools were dynamically loaded via tool_load, the tool definitions were refreshed but the OutputFormat lookup still used the stale runtime version that didn't know about newly loaded tools. Build the outputFormats map from the fresh tool list on each turn, just like we already do for the tool definitions. This ensures outputFormat (e.g., 'diff' for file_edit) is available immediately after loading a tool.
This commit is contained in:
parent
b57bc003b2
commit
f9becce7cc
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in New Issue