The Action Agent (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/geremyjampiersalasgarcia-eng/Caso_Practico_Semillero_IA/llms.txt
Use this file to discover all available pages before exploring further.
agente_accion) is the only write-capable agent in the system. While all other agents are read-only RAG responders, agente_accion uses LangChain’s @tool decorator and bind_tools() to give Gemini the ability to call a Python function — registrar_oportunidad_crm — that writes the opportunity record to both backend/data/registro_oportunidades.txt and the PostgreSQL oportunidades table. A server-side sandboxing layer ensures the tool is never executed without an explicit confirmation=True signal from the user, preventing the LLM from writing data autonomously.
When it triggers
The orchestrator routes toagente_accion under any of these conditions:
- The intent classifier returns
accion_registro. - The user sends a short confirmation text such as “sí”, “confirmar”, “sí, registrar”, or similar.
- The last assistant message in the conversation history contains the phrase
'registrar la oportunidad'or'para continuar', indicating a pending confirmation flow.
Required fields
Before calling theregistrar_oportunidad_crm tool, the agent validates that all eight required fields are present. If any are missing, the agent asks the user for them instead of proceeding:
| # | Field (tool parameter) | Notes |
|---|---|---|
| 1 | cliente | Company or person name |
| 2 | contacto | Name of the contact person |
| 3 | producto | Patito S.A. product name |
| 4 | cantidad | Number of units (int) |
| 5 | precio_con_descuento | Unit price after discount applied (float) |
| 6 | porcentaje_descuento | Applied discount percentage, e.g. 8.0 (0 if none) |
| 7 | condicion_pago | contado or crédito (if credit: 30, 60, or 90 days) |
| 8 | monto_total | cantidad × precio_con_descuento (float) |
precio_con_descuento and monto_total from the data provided by the user before presenting the confirmation summary and before invoking the tool.
Multi-step conversation flow
User submits initial registration request
The user sends a natural-language message describing the opportunity, for example:The orchestrator classifies this as
accion_registro and routes to agente_accion.Agent validates fields and asks for missing data
The agent checks the message against the eight required fields. If any are absent, it responds with a targeted question — for example:The LLM is not allowed to call the tool at this stage, even if it believes all data is present.
Agent presents summary with calculated totals
Once all fields are collected, the agent calculates the derived values and presents a Markdown summary for review:
| Campo | Valor |
|---|---|
| Cliente | Comercial ABC |
| Contacto | Geremy |
| Producto | Patito Pro 2026 |
| Cantidad | 10 |
| Descuento | 8% |
| Precio con descuento | USD 1,195.08 |
| Monto total | USD 11,950.80 |
| Condición de pago | Contado |
User confirms
The user responds with an explicit confirmation: “Sí, registrar”, “Confirmar”, or equivalent. The frontend sets
confirmation: true in the next POST /api/v1/chat payload.Agent executes registrar_oportunidad_crm tool
With The tool writes a delimited record to
confirmation=True verified server-side, the agent invokes the LangChain tool:registro_oportunidades.txt and inserts a row into the PostgreSQL oportunidades table simultaneously.Discount authorization
Example requests
The following conversation starters all triggeragente_accion:
1. Full data in one message
The registrar_oportunidad_crm LangChain tool
The tool is defined with the @tool decorator from langchain_core.tools and bound to the LLM via bind_tools():
_es_duplicado) that scans registro_oportunidades.txt for an existing entry with the same client and product combination before writing.
Output files
Confirmed opportunities are persisted in two places simultaneously:| Destination | Path / Table | Format |
|---|---|---|
| Text file | backend/data/registro_oportunidades.txt | Delimited plain-text blocks separated by = lines, one block per opportunity |
| PostgreSQL | oportunidades table | Structured relational row with all fields including id, fecha, estado |