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”.
Watch our video walkthrough to see tasks in action.
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 a wide range of tools from Integrations to external API calls to custom deinfed functions. More information on tools can be found 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.
Basic Steps
- Tool Call: Runs a specified tool with given arguments
- Prompt: Runs a prompt using a model
- Evaluate: Runs Python expressions and uses the result as output
- Wait for Input: Suspends execution and waits for user input
- Log: Logs information during workflow execution
Data Operations
- Embed: Embeds text for semantic operations
- Search: Searches for documents in the agent’s doc store
- Set: Sets a value in the workflow’s key-value store
- Get: Retrieves a value from the workflow’s key-value store
Control Flow
- Foreach: Runs a step for every value from a list in serial order
- Map-reduce: Runs a step for every value of the input list in parallel
- Parallel: Executes multiple steps in parallel
- Switch: Executes different steps based on a condition
- If-else: Conditional step with then and else branches
- Sleep: Pauses the workflow execution for a specified time
- Return: Ends the current workflow and optionally returns a value
- Yield: Switches to another named workflow
- Error: Throws an error and exits the workflow
You can learn more about workflow steps 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
- Each task should have a single, clear purpose
- Break complex workflows into smaller subtasks
Handle Errors Gracefully
- Use try/catch blocks for error-prone operations
- Provide helpful error messages
- Include fallback options where appropriate
Optimize Performance
- Use parallel execution when steps are independent
- Cache frequently accessed data
- Minimize unnecessary API calls
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