-
Notifications
You must be signed in to change notification settings - Fork 16
Description
Refactor the Human-in-the-Loop (HITL) tool-approval logic currently embedded in BasicReActAgent into a dedicated shared module, without changing runtime behavior.
This is a cleanup/architecture issue to improve readability, reuse, and future evolution of tool-level approval policies across agents.
Goals
- Extract HITL tool-approval concerns from
BasicReActAgent - Keep behavior strictly unchanged (no functional regression)
- Make approval rules reusable by other ReAct/LangGraph agents
- Improve code separation (prompting, tool loading, HITL gating, graph wiring)
Scope
Move the following out of agentic_backend/core/agents/basic_react_agent.py into a dedicated module (e.g. agentic_backend/core/interrupts/tool_approval.py):
- tool approval tuning fields (
safety.enable_tool_approval,safety.approval_required_tools) - read-only vs mutating tool prefix classification
- exact tool-name approval matching logic
- HITL approval policy text (FR/EN)
- localized HITL confirmation payload builder (FR/EN)
- parsing helpers for approval configuration
Keep in BasicReActAgent:
interrupt()callbuild_tool_loop(...)wiring- graph construction / runtime control flow
- tool assembly (MCP + local tools)
Non-goals
- No UI changes
- No capability model refactor
- No change to HITL behavior or wording (except internal relocation if needed)
- No changes to Mermaid prompt policies / Mermaid UI rendering
Acceptance criteria
BasicReActAgentstill behaves exactly the same for:- read-only tools (no HITL)
- mutating tools (HITL confirmation required when enabled)
- exact tool-name forced approvals
- Existing localized HITL cards (FR/EN) still render the same
py_compilepasses on refactored filesBasicReActAgentcode is visibly slimmer and more focused- HITL tool-approval logic can be imported/reused from a shared module
Suggested files
- New:
agentic_backend/core/interrupts/tool_approval.py - Update:
agentic_backend/core/agents/basic_react_agent.py
Why this matters
We are progressively structuring the platform around reusable agent capabilities/policies (similar to the Mermaid rendering policies). Extracting HITL approval logic now makes future reuse and refactoring safer, especially before introducing a capability-first model for local + MCP tools.