chapter eight

8 Human In The Loop

 

This chapter covers

  • When should humans be in the loop to assist or oversee the execution of tasks?
  • Three different patterns for human-in-the-loop task executions
  • Implementing the human input tool, result approval gate, and supervised task execution in our framework

We really have come a long way since the first LLM agent we implemented together back in Chapter 4. Our work in the previous three chapters, in which we added support for MCP tools, Skills, and (episodic) Memory, has greatly enhanced our LLM agent, enabling it to accomplish tasks more effectively and efficiently. That said, there are some tasks that an LLM agent cannot, or perhaps should not, perform autonomously. In this chapter, we’ll complete our stage 2 build by supporting three different approaches to enabling human-in-the-loop (HITL) task execution.

8.1 When—and How—should humans be in the loop?

8.2 Pattern 1: Tool-Based HITL

8.3 Pattern 2: Result-Approval HITL

8.3.1 Updating TaskHandler and LLMAgent

8.4 Pattern 3: Supervised-Execution HITL

8.4.1 Implementing SupervisedTaskHandler

8.4.2 Updating LLMAgent

8.4.3 Introducing the LLM Agent Inspector for supervised task executions

8.5 Extending to MAS: HITL

8.6 Summary