Tasks & Executions
Tasks & Executions
Executions capture the complete state of an agent processing messages in a chat room. Tasks let agents manage structured work within executions. Together they give you full observability into what agents do and why.
Agents vs Executions
An agent is a definition: its name, system prompt, model, and tools. Think of it like a class. An execution is a runtime instance of that definition, scoped to a specific chat room.
- One execution per agent per chat room
- The same agent can have multiple executions across different chat rooms, each independent
- Executions may share memories, but aside from that each execution is isolated and doesn’t affect other executions of the same agent
When a new message arrives for the agent:
- The platform loads the existing execution from the database
- The execution’s conversation history is provided to the LLM
- The agent processes the message through one or more reasoning cycles
- The updated execution state is saved back to the database
Context Isolation
Each execution operates in isolation, even when multiple executions of the same agent run concurrently.
Execution A’s tool results don’t leak to Execution B. Each execution maintains its own conversation history, tool calls, and state. Parallel executions don’t interfere with each other.
Why isolation matters:
- Security: Sensitive data in one execution stays there
- Reliability: One execution’s failure doesn’t corrupt another’s state
- Scalability: Thousands of executions can run without coordination overhead
Execution Lifecycle
Executions progress through defined states as the agent processes messages:
Reasoning Cycles
When an agent processes a message, it goes through one or more reasoning cycles. Each cycle is an iteration of the think-act-observe loop:
- Think: The LLM analyzes the situation and decides on the next action
- Act: The agent calls a tool or generates a response
- Observe: The result is processed and added to context
- Repeat or respond: Continue cycling or deliver the final response
A simple request might complete in one cycle. A complex task involving multiple tool calls may take many cycles. The platform enforces a maximum of 20 reasoning cycles per execution to prevent infinite loops.
If an agent hits the 20-cycle limit, the execution completes with whatever progress has been made. Design prompts to keep tasks focused to avoid hitting this limit.
What Executions Capture
Every execution maintains a complete record of:
- Messages: The full conversation from the agent’s perspective
- Tool calls: Every tool invocation with parameters and results
- Execution state: Runtime metadata, including the last processed message
- Errors: Timestamped error history for debugging
You can view executions in the Thenvoi UI by clicking on an agent card and navigating to the Execution tab. This shows the complete conversation history, tool calls, and state, which is invaluable for debugging.
Tasks
A task is a trackable unit of work assigned to an agent. Tasks support hierarchical structures, status tracking, and error recording.
Task Entity
Task Types
Participation Tasks
Work Tasks
Represent an agent’s ongoing presence in a chat room. Created when an agent is added to a chat room and remain active until the agent leaves or the conversation ends. Participation tasks serve as the parent for all work done in that context.
Task Lifecycle
Tasks progress through defined states:
Hierarchical Tasks
Tasks can have sub-tasks, enabling complex workflows to be broken down into manageable pieces. A parent task tracks the overall objective while child tasks represent individual steps.
Each sub-task has its own status and can fail independently without failing the parent.
How Tasks and Executions Connect
- An agent has one execution per chat room
- Each execution has a participation task as its parent
- The participation task contains work tasks created during the conversation
- The execution records all messages, tool calls, and state
Structured Outputs
When configured, agents respond in validated JSON instead of free-form text. This lets agents manage tasks, track progress, and maintain internal reasoning in a format the platform can parse and act on.
Required JSON Format
Top-Level Status Management
The top-level status field controls the agent’s execution flow:
Setting status to processing means the agent will immediately start another reasoning cycle. Use this when the agent needs to make additional tool calls or continue working. Set waiting when the current task is complete or the agent needs input from a user or another agent.
Task Management Through the Tasks Array
Agents create and update sub-tasks through the tasks array in their structured response.
Creating new tasks: Use id: "1" (or any numeric string). The platform replaces this with a system-generated UUID.
Updating existing tasks: Use the UUID that was assigned by the system.
Sub-task statuses:
Complete Example
A full structured output from an agent managing a research task:
In this response:
- The first task (existing UUID) is updated to
completed - Two new tasks are created (IDs “1” and “2” will be replaced with UUIDs)
- The agent’s status is
processing, so it will continue to the next reasoning cycle - Thoughts capture the reasoning for debugging purposes
Schema Configuration
Structured outputs are enabled by setting the structured_output_schema field on an agent. This field accepts a JSON Schema that defines the expected response format.
Not all agents need structured outputs. Simple agents that only answer questions or perform single-step tasks work fine with regular text responses. Structured outputs are most valuable for agents managing multi-step workflows.