This document describes how agents interact within the Black Glove system, including the structured output format, execution loop, and tool delegation.
graph TD
User[User Input] --> CLI[CLI Chat Command]
CLI --> RE[Root Executor]
RE --> LLM[LLM Client]
LLM --> RE
RE -->|Tool Call| TR[Tool Registry]
TR -->|Adapter Tool| PM[Plugin Manager]
TR -->|Subagent Tool| SE[Subagent Executor]
SE --> LLM
PM -->|Execute| Tools[nmap, gobuster, etc.]
RE -->|Final Answer| CLI
CLI --> User
Each agent runs in a ReAct-style loop managed by AgentExecutor:
sequenceDiagram
participant U as User
participant E as AgentExecutor
participant L as LLM
participant T as Tool/Subagent
U->>E: run(inputs)
loop Until complete_task or max_turns
E->>L: Generate (system + history + query)
L-->>E: JSON Response
alt Tool Call
E->>T: execute(params)
T-->>E: Result
E->>E: Append to history
else complete_task
E-->>U: Return final_answer
end
end
Every LLM response MUST be valid JSON with these fields:
| Field | Type | Description |
|---|---|---|
tool |
string | Name of tool to call (or complete_task to finish) |
parameters |
object | Arguments passed to the tool |
rationale |
string | Explanation of why this action was chosen |
{
"tool": "public_ip",
"parameters": {},
"rationale": "Using public_ip tool to detect the user's IP address"
}{
"tool": "complete_task",
"parameters": {
"final_answer": {
"answer": "Your public IP is 1.2.3.4"
}
},
"rationale": "Providing the IP address from tool results"
}Declarative schema for an agent:
name: Unique identifierinput_config: Required inputs (e.g.,user_query)output_config: Expected output schema (final_answer)tool_config: List of allowed toolsprompt_config: System prompt + query template
Runs the agent loop:
- Build system prompt with tool descriptions
- Send conversation to LLM
- Parse JSON response
- Execute tool or return
final_answer - Append result to history and repeat
Central registry for all tools:
- AdapterToolWrapper: Wraps
PluginManageradapters (nmap, whois, etc.) - SubagentTool: Wraps another
AgentDefinitionas a callable tool
graph TB
ROOT[ROOT_AGENT] -->|delegates to| PLANNER[Planner Agent]
ROOT -->|delegates to| RESEARCHER[Researcher Agent]
ROOT -->|delegates to| ANALYST[Analyst Agent]
ROOT -->|direct call| Tools[public_ip, dns_lookup, nmap...]
RESEARCHER --> Tools
| Agent | Purpose |
|---|---|
root_agent |
Main coordinator, handles user queries |
planner_agent |
Creates multi-step scan plans |
researcher_agent |
Executes security tools |
analyst_agent |
Interprets raw findings |
This is a synthetic tool injected by AgentExecutor. When called:
- The loop terminates
- The
parametersare returned to the caller - For
root_agent, this becomes the final answer shown to the user
- Invalid JSON: Agent is prompted to retry with correct format
- Tool not found: Error message added to history
- Tool failure: Exception message added to history for agent reasoning