Task Basics
Understanding task structure and components in Julep
Overview
Tasks in Julep are the building blocks for creating complex AI workflows. They define a sequence of steps that an agent can execute, including prompts, tool calls, and control flow logic.
Task Structure
A basic task consists of:
Creating Tasks
You can create tasks using either the Python or Node.js SDK:
Python
JavaScript
Task Components
1. Input Schema
Define expected input parameters:
2. Tools
Declare tools needed for the task:
3. Main Workflow
Define the sequence of steps:
Executing Tasks
Execute tasks with input parameters:
Python
Context Variables
Tasks have access to various context variables:
-
Input Variables
-
Step Results
-
Agent Context
-
Session Context
Best Practices
-
Task Design
- Keep tasks focused on a single purpose
- Use clear, descriptive names
- Document expected inputs and outputs
-
Error Handling
- Validate inputs using input_schema
- Handle tool failures gracefully
- Provide meaningful error messages
-
Performance
- Use parallel execution when possible
- Cache intermediate results
- Break large tasks into smaller subtasks
Example: Complex Task
Hereβs an example of a more complex task: