agent: nil-check ToolServer before ListTools in turn
Prevents nil pointer dereference when a newly created agent's tool server connection failed to establish (keeper.Dial returned nil, or session was restored with a dead toolsConn).
This commit is contained in:
parent
c9c76d51c0
commit
aa84cd1c9f
|
|
@ -125,8 +125,12 @@ func (ag *Agent) executeTurn(ctx context.Context, input string) string {
|
|||
// Refresh tool definitions from the tool server so dynamically loaded
|
||||
// tools (via tool_load) are available on the next turn without a rebuild.
|
||||
var tools []backend.Tool
|
||||
if ti, err := ag.runtime.ToolServer.ListTools(); err == nil {
|
||||
tools = toolInfosToBackend(ti)
|
||||
if ag.runtime.ToolServer != nil {
|
||||
if ti, err := ag.runtime.ToolServer.ListTools(); err == nil {
|
||||
tools = toolInfosToBackend(ti)
|
||||
} else {
|
||||
tools = ag.runtime.Tools
|
||||
}
|
||||
} else {
|
||||
tools = ag.runtime.Tools
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue