Configuration
Custom tools (UDTs)
FoxAgent supports user-defined tools (UDTs) that your AI agent can invoke. UDTs are VFP classes that inherit from FoxAgentTool and expose parameters and execution logic.
UDT example
* GetSaldoTool.prg - Coloca este archivo en tu carpeta Tools\
DEFINE CLASS GetSaldoTool AS FoxAgentTool
ToolName = "get_saldo"
ToolDescription = "Obtiene el saldo de un cliente por su codigo"
FUNCTION DefineParameters()
THIS.AddParam("clienteCode", "number", "Codigo del cliente", .T.)
ENDFUNC
FUNCTION Execute(toContext)
LOCAL lnCode, lcResult
lnCode = THIS.GetParam("clienteCode")
* Tu logica de negocio aqui
lcResult = "Cliente " + TRANSFORM(lnCode) + ": $1500.00"
RETURN THIS.Ok(lcResult)
ENDFUNC
ENDDEFINE Supported parameter types
When defining parameters with AddParam(), you can use the following types:
| Type | Description | Example |
|---|---|---|
"string" | Text of any length | THIS.AddParam("nombre", "string", "Nombre del cliente", .T.) |
"number" | Integer or decimal number | THIS.AddParam("cantidad", "number", "Cantidad", .T.) |
"boolean" | Logical value (.T. or .F.) | THIS.AddParam("activo", "boolean", "Esta activo?", .F.) |
"date" | Date (YYYY-MM-DD format) | THIS.AddParam("fecha", "date", "Fecha de inicio", .F.) |
"object" | Complex JSON object | THIS.AddParam("filtro", "object", "Filtros avanzados", .F.) |
The fourth parameter of AddParam() indicates whether the parameter is required (.T.) or optional (.F.).
Example with multiple parameters
* SearchClientsTool.prg
DEFINE CLASS SearchClientsTool AS FoxAgentTool
ToolName = "search_clients"
ToolDescription = "Busca clientes por nombre, codigo postal o saldo minimo"
FUNCTION DefineParameters()
THIS.AddParam("searchText", "string", "Texto a buscar en nombre o codigo", .T.)
THIS.AddParam("postalCode", "string", "Filtrar por codigo postal", .F.)
THIS.AddParam("minBalance", "number", "Saldo minimo requerido", .F.)
THIS.AddParam("activeOnly", "boolean", "Solo clientes activos", .F.)
ENDFUNC
FUNCTION Execute(toContext)
LOCAL lcSearch, lcPostal, lnMinBal, llActive
LOCAL lcQuery, lcResult
lcSearch = THIS.GetParam("searchText")
lcPostal = THIS.GetParam("postalCode")
lnMinBal = THIS.GetParam("minBalance")
llActive = THIS.GetParam("activeOnly")
* Construir consulta dinamica
lcQuery = "SELECT * FROM CLIENTES WHERE "
lcQuery = lcQuery + "(cNombre LIKE '%" + lcSearch + "%' OR cCodigo = '" + lcSearch + "')"
IF !EMPTY(lcPostal)
lcQuery = lcQuery + " AND cCodPost = '" + lcPostal + "'"
ENDIF
IF lnMinBal > 0
lcQuery = lcQuery + " AND nSaldo >= " + TRANSFORM(lnMinBal)
ENDIF
IF llActive
lcQuery = lcQuery + " AND lActivo = .T."
ENDIF
* Ejecutar y retornar resultados
&lcQuery INTO CURSOR curResult
SELECT * FROM curResult INTO ARRAY laResult
lcResult = TRANSFORM(ALEN(laResult,1)) + " clientes encontrados"
RETURN THIS.Ok(lcResult)
ENDFUNC
ENDDEFINE Automatic discovery
UDTs are automatically loaded from the folder configured with SetToolsFolder(). Just place your .prg files in that folder and FoxAgent will discover them when connecting.
LOCAL loBridge
loBridge = CREATEOBJECT("FoxAgent.Bridge")
loBridge.SetInstance(_VFP)
loBridge.SetToolsFolder("C:\MiProyecto\Tools") && Scan automatico
loBridge.Connect("mi-app-001", "Mi App", 3) Role system
FoxAgent has 4 permission levels that control which tools your AI agent can use:
| Level | Name | Access |
|---|---|---|
| 0 | Observer | Read-only: list instances, view variables, cursors, forms |
| 1 | Operator | Read + write: set_variable, exec_command, UDTs |
| 2 | Developer | Operator + get_call_stack, get_object_members, reload_procedure |
| 3 | Admin | Developer + close_cursors, execute_tool, build_project |
The role is set when connecting with Connect(instanceId, displayName, role) and can be changed on-the-fly with set_role.
License
FoxAgent uses validated licenses. Place the foxagent.lic file next to the Broker executable:
# License path
C:\Program Files\FoxAgent\foxagent.lic
# Without license, Broker starts in evaluation mode Built-in tools
FoxAgent includes 33 built-in tools organized by level:
Inspection (Level 0)
list_instances— View connected VFP instancesget_variables— Read public variablesget_cursors— View open cursorsget_cursor_data— Read cursor rowsget_active_form— Active formget_form_controls— Form controlstake_screenshot— Screenshoteval_expression— Evaluate VFP expression
Execution (Level 1)
set_variable— Assign variableexec_command— Execute VFP commandset_control_value— Change control valuerefresh_form— Refresh form
Development (Level 2)
get_call_stack— Call stackget_object_members— Object membersreload_procedure— Reload PRGrun_report— Run reportget_project_structure— Project structureget_source_file— Source codebuild_project— Build project
Admin (Level 3)
close_cursors— Close cursorsexecute_tool— Execute UDTget_tools— Tool list