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

YAML
name: Summarize Document
description: Create a concise summary of any document
input_schema:
  type: object
  properties:
    document_text:
      type: string
      description: The text to summarize

Tools

Tools are functions that can be used by an agent to perform tasks. Julep supports:

Learn more about tools here.

YAML
tools:
  - name: internet_search
    description: Performs an internet search using Brave
    type: integration
    integration:
      provider: brave
      method: search
      setup:
        api_key: <BRAVE_API_KEY>

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.

YAML
name: Summarize Document
description: Create a concise summary of any document

sample_sub_workflow:
  - prompt: |-
      Tell me a joke about {{inputs[0].topic}}:

main:
- workflow: sample_sub_workflow
  arguments:
    topic: "'AI'"

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.

NameDescription
Tool CallExecute tools defined in the task
PromptSend messages to the AI model
EvaluatePerform calculations or data manipulation
Wait for InputPause workflow for user input
SetStore values for later use
GetRetrieve values from storage
ForeachIterate over a collection
Map-reduceProcess collections in parallel
ParallelExecute steps concurrently
SwitchMultiple condition handling
If-elseConditional execution
SleepPause execution
ReturnReturn values from workflow
YieldExecute subworkflows
LogLog messages or specific values
ErrorHandle 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:

YAML
- prompt: "Hello {{inputs[0].user_name}}"

Step Results

Use outputs from previous steps:

YAML
- evaluate: len(_.search_results)
- if: _.count > 0

Environment Context

Access agent and session data:

YAML
- prompt: "Agent {{agent.name}} is helping you"

Input schemas help catch errors early by validating all inputs before execution starts.

Here’s how these components work together:

YAML
name: Process Customer Feedback
description: Analyze and categorize customer feedback
input_schema:
  type: object
  required: ["feedback_text"]
  properties:
    feedback_text:
      type: string
    sentiment_analysis:
      type: boolean
      default: true

tools:
  - name: categorize
    integration:
      provider: classification
      method: categorize

main:
  - prompt: Analyze customer sentiment
  - tool: categorize
    arguments:
      text: inputs[0].feedback_text

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.

Check out the API reference here or SDK reference (Python here or JavaScript here for more details on different operations you can perform on tasks.

Executing a Task

Here’s how to execute a task:

Check out the API reference here or SDK reference (Python here or JavaScript here for more details on different operations you can perform on tasks.

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:

Python
# Create an agent with specific tools
agent = client.agents.create(
    name="Customer Support Agent",
    tools=["email", "ticket_system"]
)

# Create a task that inherits these tools
task = client.tasks.create(
    agent_id=agent.id,
    name="Handle Support Request",
    main=[
        {"tool": "email", "arguments": {"to": "{{inputs.customer}}"}}
    ]
)

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