Files
yhh d4dd348b14 fix(agent): let read-only agents search the capability catalog
The read-only execution guard admitted only list and inspect, so
use_capability action=search fell through to the unknown-action block even
though the tool declares it and resolves it exactly like list. The tool's
own description tells every model to search before calling a tool
unavailable, so a read-only subagent was steered into the block.

usecap now exports the declared actions and the catalog-read subset; the
guard reads that set instead of keeping its own copy. The refusal for an
action outside the declared set names the action and the allowed ones.
2026-10-10 04:06:14 -07:00

31 lines
1.0 KiB
Go

package usecap
import "slices"
// The actions use_capability declares in its schema.
const (
ActionSearch = "search"
ActionList = "list"
ActionInspect = "inspect"
ActionCall = "call"
ActionDecline = "decline"
)
// CatalogReadActions resolve host-side without a target and execute nothing.
// inspect of a connected server may refresh the in-memory tool snapshot.
var CatalogReadActions = []string{ActionSearch, ActionList, ActionInspect}
// IsCatalogReadAction reports whether action is one of CatalogReadActions.
func IsCatalogReadAction(action string) bool {
return slices.Contains(CatalogReadActions, action)
}
// IDlessCatalogActions are the catalog reads that need no capability_id. inspect
// is excluded on purpose: it names an id, so a restricted proxy must gate it.
var IDlessCatalogActions = []string{ActionSearch, ActionList}
// IsIDlessCatalogAction reports whether action is one of IDlessCatalogActions.
func IsIDlessCatalogAction(action string) bool {
return slices.Contains(IDlessCatalogActions, action)
}