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.

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

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 a wide range of tools from Integrations to external API calls to custom deinfed functions. More information on tools can be found here.

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.

name: Summarize Document
description: Create a concise summary of any document
sub_workflows:
  - prompt: |-
      Tell me a joke on a {{inputs.topic}}:
main:
- workflow: sub_workflows
  arguments:
    topic: "AI"

Steps

We use tasks and workflows interchangeably. They are the same except Julep’s branding reflects tasks.

Basic Steps

  1. Tool Call: Runs a specified tool with given arguments
  2. Prompt: Runs a prompt using a model
  3. Evaluate: Runs Python expressions and uses the result as output
  4. Wait for Input: Suspends execution and waits for user input
  5. Log: Logs information during workflow execution

Data Operations

  1. Embed: Embeds text for semantic operations
  2. Search: Searches for documents in the agent’s doc store
  3. Set: Sets a value in the workflow’s key-value store
  4. Get: Retrieves a value from the workflow’s key-value store

Control Flow

  1. Foreach: Runs a step for every value from a list in serial order
  2. Map-reduce: Runs a step for every value of the input list in parallel
  3. Parallel: Executes multiple steps in parallel
  4. Switch: Executes different steps based on a condition
  5. If-else: Conditional step with then and else branches
  6. Sleep: Pauses the workflow execution for a specified time
  7. Return: Ends the current workflow and optionally returns a value
  8. Yield: Switches to another named workflow
  9. 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:

- prompt: "Hello {{inputs.user_name}}"

Step Results

Use outputs from previous steps:

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

Environment Context

Access agent and session data:

- 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:

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.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:

# Execute a task
execution = client.executions.create(
    task_id=task.id,
    input={
        "document_text": "This is a sample document"
    }
)

# Monitor progress
while True:
    result = client.executions.get(execution.id)
    if result.status in ["succeeded", "failed"]:
        break
    time.sleep(1)

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:

# 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

  • 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