GX4011: tool has no description or an input with no JSON form
An action or a form with .Tool() has no doc comment for the description of the tool, or its input has a gx.File field.
Cause
An action or a form with .Tool() is a tool for an agent. The agent reads the description of the tool to know when to call it. The description is the doc comment of the variable of the action. A tool with no doc comment has no description.
A tool call has JSON arguments. A gx.File field has no JSON value, so the input of a tool cannot have one.
Example
package route
import "github.com/alternayte/gx"
type Add struct {
gx.Route `POST /cart/add`
SKU string
}package cart
import (
"github.com/alternayte/gx"
"app/cart/route"
)
var add = gx.Action(func(c *gx.Ctx, in route.Add) error {
return nil
}).Tool()
var Routes = gx.Collect(add)gx check reports:
cart/cart.go:8:11: GX4011: the tool of "Add" has no description; a tool takes it from the doc comment of the variable of its actionFix
- Write a doc comment above the variable of the action. Say what the tool does:
// Adds a product to the cart of the user. - For an input with a
gx.Filefield, remove.Tool(), or make a second action with no file for the tool.