Tasks
Understanding Julep Tasks and workflows
Overview
Tasks are GitHub Actions-style workflows that define multi-step actions in Julep. Think of them as recipes that tell an agent exactly how to accomplish a goal. For example, a task might outline the steps to “Summarize a Research Paper” or “Debug a Code Issue”.
Here are some of the key features of tasks:
- Connect multiple AI operations seamlessly
- Make decisions based on intermediate results
- Run operations in parallel for efficiency
- Integrate with external tools and APIs
- Maintain state throughout execution
Components
A task consists of several key components which can be broadly classified into:
Input Schema
Tools
Tools are functions that can be used by an agent to perform tasks. Julep supports:
Learn more about tools here.
Sub-Workflows
A task can be made up of multiple sub-workflows. These sub-workflows can be named and can be used to break down complex tasks into smaller, more manageable pieces.
Steps
We use tasks and workflows interchangeably. They are the same except Julep’s branding reflects tasks.
Below is a table of all the steps that can be used in a task.
Name | Description |
---|---|
Tool Call | Execute tools defined in the task |
Prompt | Send messages to the AI model |
Evaluate | Perform calculations or data manipulation |
Wait for Input | Pause workflow for user input |
Set | Store values for later use |
Get | Retrieve values from storage |
Foreach | Iterate over a collection |
Map-reduce | Process collections in parallel |
Parallel | Execute steps concurrently |
Switch | Multiple condition handling |
If-else | Conditional execution |
Sleep | Pause execution |
Return | Return values from workflow |
Yield | Execute subworkflows |
Log | Log messages or specific values |
Error | Handle errors by specifying an error message |
You can learn more about workflow steps as to how they work in the Workflow Steps section.
Context Variables
Tasks have access to three types of context:
Input Variables
Access input parameters:
Step Results
Use outputs from previous steps:
Environment Context
Access agent and session data:
Input schemas help catch errors early by validating all inputs before execution starts.
Here’s how these components work together:
Learn more about tools here.
Metadata
Metadata is a key-value pair that can be used to categorize and filter tasks.
How to Use Tasks ?
Creating a Task
Here’s a simple task that summarizes a document and checks if the summary is too long. We first define the task in a YAML file and then create it using the Julep SDK.
Executing a Task
Here’s how to execute a task:
Relationship to Other Concepts
This section will help you understand how tasks relate to other concepts in Julep.
Agents
Julep agents can power tasks by providing memory, context, or tools. Tasks are multi-step workflows designed for complex, automated execution. Whenever you create a task, you can associate it with an agent if you want to leverage that agent’s capabilities. Unlike sessions, tasks are not meant for real-time interaction; they run through a defined workflow to achieve a goal.
For example:
Tools
Task can leverage tools to perform complex operations. Tools can be defined in the task definition or can be associated with an agent. When you define a tool in the task definition, it is available to all steps in that task only. On the other hand, when you associate a tool with an agent, it is available to all the Tasks associated with that agent.
Best Practices
Keep Tasks Focused
- 1. Purpose: Each task should have a single, clear purpose
- 2. Subtasks: Break complex workflows into smaller subtasks
Handle Errors Gracefully
- 1. Error Handling: Use try/catch blocks for error-prone operations
- 2. Error Messages: Provide helpful error messages
- 3. Fallback Options: Include fallback options where appropriate
Optimize Performance
- 1. Parallel Execution: Use parallel execution when steps are independent
- 2. Map-Reduce: Use map-reduce to run steps in parallel
Next Steps
- Workflow Steps - Learn about all available step types
- Tools - Learn about tools and how to use them in tasks
- Sessions - Learn about sessions and how to use them in tasks