Reflection Loop — Agent Self-Improvement
The reflection loop: a worker drafts, a critic reviews the draft against the brief and the orchestrator only approves once the revision closes every gap.
The memory loop: before planning, the planner queries the memory store for similar past lessons, then writes the new lesson back once the task is closed.
Copy and paste the following FlowZap code into a project in your FlowZap account to see this template diagram.
user { # User
n1: circle label:"Start task"
n2: rectangle label:"Submit complex task"
n4: rectangle label:"Receive acknowledgement"
n26: rectangle label:"Receive improved result"
n1.handle(right) -> n2.handle(left)
n2.handle(bottom) -> planner.n3.handle(top) [label="Task"]
}
planner { # Planner
n3: rectangle label:"Acknowledge task"
n5: rectangle label:"Ask for similar lessons"
n8: rectangle label:"Receive prior lessons"
n9: rectangle label:"Build plan"
n10: rectangle label:"Dispatch execution"
n13: rectangle label:"Receive execution output"
n14: rectangle label:"Request evaluation"
n17: rectangle label:"Receive evaluation"
n18: diamond label:"Good enough?"
n19: rectangle label:"Store new lesson"
n22: rectangle label:"Confirm lesson saved"
n23: rectangle label:"Send retry plan"
n25: rectangle label:"Send improved result"
n3.handle(top) -> user.n4.handle(bottom) [label="Ack"]
n3.handle(right) -> n5.handle(left)
n5.handle(bottom) -> memory.n6.handle(top) [label="Retrieve lessons"]
n8.handle(right) -> n9.handle(left)
n9.handle(right) -> n10.handle(left)
n10.handle(bottom) -> executor.n11.handle(top) [label="Execute plan"]
n13.handle(right) -> n14.handle(left)
n14.handle(bottom) -> evaluator.n15.handle(top) [label="Evaluate output"]
n17.handle(right) -> n18.handle(left)
n18.handle(right) -> n19.handle(left) [label="Yes"]
n18.handle(bottom) -> n23.handle(top) [label="No"]
n19.handle(bottom) -> memory.n20.handle(top) [label="Save lesson"]
n22.handle(right) -> n25.handle(left)
n23.handle(bottom) -> executor.n24.handle(top) [label="Retry with lessons"]
n25.handle(top) -> user.n26.handle(bottom) [label="Improved result"]
}
memory { # Memory Store
n6: rectangle label:"Search memory"
n7: rectangle label:"Return best lessons"
n20: rectangle label:"Persist new lesson"
n21: rectangle label:"Confirm persistence"
n6.handle(right) -> n7.handle(left)
n7.handle(top) -> planner.n8.handle(bottom) [label="Lessons"]
n20.handle(right) -> n21.handle(left)
n21.handle(top) -> planner.n22.handle(bottom) [label="Saved"]
}
executor { # Executor
n11: rectangle label:"Run first attempt"
n12: rectangle label:"Return output"
n24: rectangle label:"Run improved attempt"
n27: rectangle label:"Return improved output"
n11.handle(right) -> n12.handle(left)
n12.handle(top) -> planner.n13.handle(bottom) [label="Output"]
n24.handle(right) -> n27.handle(left)
n27.handle(top) -> evaluator.n28.handle(bottom) [label="Improved output"]
}
evaluator { # Evaluator
n15: rectangle label:"Judge first output"
n16: rectangle label:"Return verdict"
n28: rectangle label:"Judge improved output"
n29: rectangle label:"Return final verdict"
n15.handle(right) -> n16.handle(left)
n16.handle(top) -> planner.n17.handle(bottom) [label="Verdict"]
n28.handle(right) -> n29.handle(left)
n29.handle(top) -> planner.n19.handle(bottom) [label="Pass"]
}
Install the MCP packagenpm install -g flowzap-mcpMCP documentation
The reflection loop: a worker drafts, a critic reviews the draft against the brief and the orchestrator only approves once the revision closes every gap.
The evolution loop: an optimizer benchmarks candidate agents against the production baseline, keeps the best score and confirms persistence before promotion.
Legacy executor, LLM-as-judge evaluator and next-gen consumer: an evaluator scores the full trajectory, rejects structural sloppiness and forwards only validated payloads.
Shared host, per-client profiles and tool boundaries: how external clients reach their own Hermes workspaces without seeing another tenant's tools or data.
Option 1 of the Hermes multi-tenant setup: one external actor, one gateway, one isolated workspace inside an execution sandbox, and a single client profile.
Option 2: one client with several entry points, a prefix router that maps /eng or /support to a mode, and a single unified Hermes profile behind the gateway.