Multi-Turn Conversations & Complex Task Decomposition
title: "Lesson 09 | Multi-Turn Conversations & Complex Task Decomposition" summary: "Learn to guide the Agent's thought process, master the /plan command and task tree management, and tackle ultra-complex requests with a divide-and-conquer strategy." sortOrder: 90 status: "published"
Alright, as a technical education expert, I will write this in-depth tutorial for you on complex task decomposition in Hermes Agent.
Subtitle: Learn to guide the Agent's thought process, master the /plan command and task tree management, and tackle ultra-complex requests with a divide-and-conquer strategy.
In previous lessons, we have mastered the basic architecture, skill extension, and memory system of the Hermes Agent. These features enable the Agent to respond to single-turn or simple multi-turn requests. However, real-world tasks are often complex and multi-step, requiring careful planning, execution, and validation. For example, a request like "Research the mainstream AI Agent frameworks on the market, compare their pros and cons, and write a summary report for me" cannot be completed with a single, simple Prompt call.
In this lesson, we will delve into the advanced cognitive core of the Hermes Agent—the Planner and Task Tree system. You will learn how to decompose a grand objective into a series of executable sub-tasks and, like a project manager, supervise, adjust, and drive the Agent to complete the entire process. This is the most critical step in evolving from a "chatbot" to an "autonomous agent."
Learning Objectives
After completing this lesson, you will be able to:
- Understand the necessity of task decomposition: Grasp why complex tasks must be broken down into smaller steps and its importance for LLMs.
- Master core concepts: Gain a deep understanding of the Planner, Task Tree, and Task Status concepts.
- Master the
/plancommand: Learn to use the/plancommand to initiate the Agent's planning mode, converting high-level goals into concrete execution plans. - Manage the Task Tree: Learn to use the
/taskcommand suite to view, approve, execute, and monitor the entire lifecycle of the task tree. - Practice with a complex task: Go through the entire process, from posing a request to receiving the final output, in a real-world scenario to experience the power of "Human-in-the-Loop" collaboration.
Core Concepts Explained
Before diving into the practical demonstration, we must understand the core concepts that underpin complex task execution.
1. From Single-Turn Calls to Multi-Step Planning
The traditional LLM interaction model is akin to a "function call": you provide an input (a Prompt) and receive an output. This model is highly efficient for atomic tasks like information retrieval or text generation. However, its limitations become apparent when faced with a complex task that requires "research, analysis, and summarization":
- Context Window Limitations: Complex task chains may require processing vast amounts of information, far exceeding the context window size of a single LLM.
- Cascading Errors: In a long chain of thought, an error in an intermediate step can corrupt the entire result, making it difficult to trace and correct.
- Rigid Tool Usage: The inability to dynamically decide which Skill to use at which step (e.g., using
web_searchfirst, thenfile_ioto write a file).
The Planner in Hermes Agent is designed precisely to solve these problems. When you use the /plan command, you are no longer asking the Agent to "answer immediately" but rather to "create a plan for me." The Agent will invoke a specialized LLM for planning (or use a specific planning algorithm) to decompose your high-level objective into a structured set of sub-tasks with dependencies.
2. The Task Tree: A Blueprint for Action
The plan generated by the Planner is not a simple list but a Task Tree. This hierarchical structure perfectly expresses the relationships between tasks.
- Root Task: Represents your original, high-level objective.
- Sub-tasks: Represent the specific steps required to complete the parent task. A sub-task can itself have further sub-tasks, forming a nested structure.
- Dependencies: The task tree implies an execution order. Typically, the completion of a parent task depends on the successful completion of all its sub-tasks. There may also be sequential dependencies between certain sub-tasks (e.g., data must be fetched before it can be analyzed).
- Task Status: Each task node has a status to track the overall progress of the plan. Common statuses include:
PENDING: The plan has been generated but has not yet been approved or executed.APPROVED: The user has confirmed the plan, and it is awaiting execution.RUNNING: The Agent is currently processing this task.COMPLETED: The task was executed successfully, and its output can be used by other tasks.FAILED: An error was encountered during the task's execution.
This task tree serves as the Agent's "blueprint for action" when executing complex tasks. It is clear, transparent, and allows for human intervention before and during execution.
3. Human-in-the-Loop: You Are the Commander
The planning system in Hermes Agent is not a "black box." It gives the final decision-making power back to the user. After the Planner generates the task tree, it pauses and waits for your approval.
This "Human-in-the-Loop" design is crucial for several reasons:
- Safety: You can review the Agent's plan to prevent it from performing harmful or unintended actions (e.g., searching on inappropriate websites or deleting important files).
- Correctness: You can correct the Agent's misunderstandings. If the Agent misinterprets your intent, the generated plan will be flawed. You can then modify, delete, or add task nodes to ensure the plan's accuracy.
- Flexibility: If unexpected issues arise during execution (e.g., an API is unavailable), you can intervene and adjust the subsequent plan.
Now, with these concepts in mind, let's move on to the exciting hands-on demonstration.
💻 Hands-on Demonstration
We will simulate a real-world research task: "Analyze the latest news and tech community discussions about the AI software engineer 'Devin' from the past three days, summarize its core capabilities and points of controversy, and generate a briefing in Markdown format."
This task is nearly impossible to complete with a single-turn Prompt. It requires:
- Searching across multiple information sources (news sites, Hacker News, Reddit, etc.).
- Browsing and filtering search results to identify high-quality information.
- Extracting key information from multiple articles and discussions.
- Classifying and synthesizing the information (capabilities, controversies).
- Formatting the results into a Markdown briefing.
Let's see how Hermes Agent tackles it through planning.
Step 1: Initiating the Plan
Instead of asking directly, we use the /plan command to state our objective.
/plan Analyze the latest news and tech community discussions about the AI software engineer 'Devin' from the past three days, summarize its core capabilities and points of controversy, and generate a briefing in Markdown format.
After submission, the Agent won't give an immediate answer. Instead, it will inform you that it is thinking and formulating a plan. After a moment, you will receive the Planner's initial response.
> Okay, I've understood your objective. I am now formulating a detailed execution plan for you...
> ...
> Plan generated! Here is a task tree with 5 main steps. Please review it.
>
> **Task Tree Preview:**
> - **Task #1 (Root)**: Generate a briefing on 'Devin'
> - **Task #2**: [Sub-task] Search for news and discussions about 'Devin' from the past three days
> - **Task #3**: [Sub-task] Filter and select 5-7 of the most relevant articles/post links from the search results
> - **Task #4**: [Sub-task] Visit each link and extract key information about core capabilities and controversies
> - **Task #5**: [Sub-task] Synthesize all extracted information and write a briefing in Markdown format
>
> You can use `/task list` to view the detailed task tree.
> Do you approve this plan? (y/n)
Step 2: Reviewing the Task Tree
The Agent has provided a clear and logical plan. Before approving it, let's use the /task list command to view the more detailed task tree structure.
/task list
The terminal will return a formatted tree structure, including each task's ID, parent ID, status, and a brief description.
ID PARENT STATUS DESCRIPTION
-- ------ ------- ------------------------------------------------------------------
1 - PENDING (Root) Generate a briefing about the AI software engineer 'Devin'.
2 1 PENDING Search for recent news and community discussions about 'Devin'.
3 1 PENDING Filter and select 5-7 most relevant links from search results.
4 1 PENDING Visit each link and extract key points on capabilities and controversies.
5 1 PENDING Synthesize all extracted information and write a Markdown brief.
ID: The unique identifier for each task, which we will use for subsequent operations.PARENT: The ID of the parent task. The PARENT for all sub-tasks is 1, the root task.STATUS: All tasks are currently in thePENDINGstate, awaiting our approval.DESCRIPTION: The specific content of the task.
This plan looks very reasonable. It follows the classic research workflow of "search -> filter -> extract -> synthesize."
Step 3: Approving and Starting the Task
We are satisfied with the plan and can now approve it. You can either type y or yes, or use the /task start command to initiate the entire plan.
y
Or, more explicitly:
/task start 1
Starting the root task will automatically drive the execution of its sub-tasks in sequence. The Agent will begin executing the first pending sub-task, which is Task #2.
> Plan approved. Starting task tree execution...
>
> **[Task #2: RUNNING]** Executing search...
> - Using Skill: `web_search`
> - Parameters: `{"query": "AI software engineer Devin news and discussion last 3 days", "sources": ["google_news", "hacker_news", "reddit"]}`
> ...
The Agent provides real-time updates on its progress, including which task is being executed, which Skill is being called, and what parameters are being used. This is an excellent demonstration of transparency.
Step 4: Monitoring the Execution
After a few moments, Task #2 is complete. We can use /task list again to check the progress.
/task list
The output will now be updated:
ID PARENT STATUS DESCRIPTION
-- ------ --------- ------------------------------------------------------------------
1 - RUNNING (Root) Generate a briefing about the AI software engineer 'Devin'.
2 1 COMPLETED Search for recent news and community discussions about 'Devin'.
3 1 RUNNING Filter and select 5-7 most relevant links from search results.
4 1 PENDING Visit each link and extract key points on capabilities and controversies.
5 1 PENDING Synthesize all extracted information and write a Markdown brief.
As you can see, the status of Task #2 has changed to COMPLETED, and Task #3 has automatically entered the RUNNING state. The root task #1's status has also changed to RUNNING because its sub-tasks are being executed.
We can also inspect the result of a completed task using /task show <ID>.
/task show 2
This will display detailed information for Task #2, including its input, output, status, and execution logs.
{
"id": 2,
"parent": 1,
"status": "COMPLETED",
"description": "Search for recent news and community discussions about 'Devin'.",
"input": null,
"output": {
"type": "search_results",
"data": [
{ "title": "Cognition AI launches Devin, the first AI software engineer", "url": "...", "source": "techcrunch.com" },
{ "title": "Hacker News Discussion: Devin AI", "url": "...", "source": "news.ycombinator.com" },
{ "title": "My thoughts on Devin after trying it for a day - r/programming", "url": "...", "source": "reddit.com" },
...
]
},
"logs": [
"Starting task...",
"Executing skill 'web_search'...",
"Skill execution successful.",
"Task completed."
]
}
Note the output field. The output of Task #2 (the list of search results) will automatically become the input for Task #3. This is how the task chain is linked.
Step 5: Human Interaction and Plan Adjustment
Suppose that while executing Task #4, one of the links fails to load (e.g., the website is down or requires a login). The Agent won't get stuck; it will mark the task as FAILED and pause, awaiting your instructions.
> **[Task #4.2: FAILED]** Failed to access link `http://example.com/paywall-article`. Reason: HTTP 403 Forbidden.
>
> Task tree execution has been paused. Please investigate the issue and decide on the next action.
> You can use `/task retry 4.2` to retry, or use `/task modify 4` to change the parent task's instructions.
This is where the power of "Human-in-the-Loop" shines. We see that this is a paywalled article that cannot be accessed. We can decide to skip it and slightly modify the plan. For instance, we can tell the Agent to ignore the failed link and continue with the rest.
/task modify 4 "Visit the [remaining] links one by one, extracting key information about core capabilities and controversies. If a link fails, log it and skip."
After modifying the plan, we can restart the task.
/task start 4
The Agent will continue executing based on our new instructions, demonstrating powerful robustness and adaptability.
Step 6: Retrieving the Final Result
When all sub-tasks have been completed successfully, the final task, Task #5, will be executed. It will synthesize all the information gathered in the previous steps to generate the final Markdown briefing we requested.
When the root task, #1, also changes its status to COMPLETED, the entire workflow is finished.
> **[Task #1: COMPLETED]** All tasks have been completed successfully!
>
> The final result has been generated. You can view it using `/task show 1`.
We execute /task show 1 and find the final report in its output field.
/task show 1
{
"id": 1,
"status": "COMPLETED",
...
"output": {
"type": "markdown_report",
"content": "# Briefing on AI Software Engineer 'Devin' (Dynamics of the Past Three Days)\n\n## Core Capabilities\n\n- **End-to-End Task Execution**: Devin can independently handle the entire software development process, from understanding requirements to coding, debugging, and deployment.\n- **Autonomous Learning**: Capable of learning new technologies by reading documentation and APIs.\n- **Powerful Toolset**: Integrates a shell, code editor, and browser, allowing it to simulate a human developer's work environment.\n\n## Main Points of Controversy\n\n- **Authenticity of Demos**: There is community discussion questioning whether its public demo videos were edited, with the actual success rate being unknown.\n- **Replacement of Developers**: It has sparked intense debate about whether AI will replace junior software engineers on a large scale.\n- **Generalization Ability**: It is currently unclear how it performs on complex, real-world projects.\n..."
}
}
Task accomplished! By guiding the Agent's thinking and planning, we have successfully completed a research task that would have otherwise been extremely time-consuming and laborious.
Commands Covered
| Command | Alias | Functionality |
|---|---|---|
/plan <your goal> |
/p |
Tells the Agent your high-level goal and asks it to generate a task plan. |
/task list |
/tl |
Displays the task tree structure, statuses, and IDs for the current session. |
/task show <id> |
/ts <id> |
Shows detailed information for a specific task ID, including its input, output, and logs. |
/task start <id> |
/ts <id> |
Starts a task that is in a PENDING or APPROVED state. |
/task approve <id> |
/ta <id> |
Approves one or more tasks without executing them immediately. |
/task modify <id> <new desc> |
/tm <id> |
Modifies the description or instructions of a task that has not yet been executed. |
/task retry <id> |
/tr <id> |
Retries a FAILED task. |
/task cancel <id> |
/tc <id> |
Cancels a running or pending task. |
Key Takeaways
- Divide and Conquer: The core strategy for solving complex tasks is to break them down into simple, manageable sub-tasks. This is a manifestation of the Agent's intelligence.
/planis the Entry Point: For any request that requires multiple steps to complete, you should always start with the/plancommand instead of asking directly.- The Task Tree is the Blueprint: The task tree clearly displays the Agent's thought process and execution plan. Learning to read and understand the task tree is key to using advanced features.
- You are the Supervisor: Hermes Agent empowers the user with the authority to review, approve, and modify plans. This "Human-in-the-Loop" model ensures that task execution is safe, controllable, and efficient.
- State-Driven Execution: The status of a task (
PENDING,RUNNING,COMPLETED,FAILED) drives the entire workflow forward. Monitoring task statuses allows you to keep track of the project's progress at all times.
By mastering the Planner and Task Tree, you have upgraded the Hermes Agent from a simple Q&A assistant to a powerful intelligent agent capable of planning and executing complex projects. In our next lesson, we will explore how to customize the Agent's behavior and personality to better suit your working style.
References
- Hermes Agent Official Documentation - Planner Module
- [Recommended Paper] "Tree of Thoughts: Deliberate Problem Solving with Large Language Models"
- [Project Source Code] Hermes Agent GitHub Repository
- [Community Discussion] Hermes Agent Discord Channel