Keep a machine's discovery answer under the bus's message limit
Every tool's schema in one $SRV.INFO reply outgrew max_payload on machines serving 137-206 tools, and the refused reply was dropped silently, so search and a machine's view went empty. Module tools now announce without schema; describe and tools/list ask the module for it. An answer still too large has its descriptions cut to a line, and a failed reply is logged.
This commit is contained in:
@@ -691,6 +691,10 @@ func (s *Surface) discover(name string, args map[string]any) map[string]any {
|
||||
if err != nil {
|
||||
return failure(err.Error())
|
||||
}
|
||||
if !t.Seat && len(t.Tool.Input) == 0 {
|
||||
// Discovery carries a seat's schema, not a module tool's: asked of the runtime serving it.
|
||||
t.Tool.Input = inputOf(s.conn, t.Tool.Module, t.Tool.Name)
|
||||
}
|
||||
description := t.Tool.Description
|
||||
if description == "" {
|
||||
description = t.Name
|
||||
@@ -728,3 +732,29 @@ func (s *Surface) discover(name string, args map[string]any) map[string]any {
|
||||
}
|
||||
return failure("no discovery verb " + name)
|
||||
}
|
||||
|
||||
// inputOf is a module tool's input schema, asked of a runtime that serves the module — its `tools` verb,
|
||||
// answered on the module's plain subject by any instance — because discovery no longer carries it: every
|
||||
// tool's schema made a machine's one discovery answer outgrow the bus (2026-10-04). Nil when nothing
|
||||
// answers, which describes the tool as taking nothing rather than failing the description.
|
||||
func inputOf(conn *bus.Conn, module, tool string) json.RawMessage {
|
||||
got, err := conn.Ask(module+".tools", map[string]any{}, "")
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
var answer struct {
|
||||
Tools []struct {
|
||||
Name string `json:"name"`
|
||||
Input json.RawMessage `json:"input"`
|
||||
} `json:"tools"`
|
||||
}
|
||||
if json.Unmarshal(got.Result, &answer) != nil {
|
||||
return nil
|
||||
}
|
||||
for _, t := range answer.Tools {
|
||||
if t.Name == tool {
|
||||
return t.Input
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user