DS DevShelfHub Projects · AI tools
Tutorials / CrewAI / Reference / Classes / LiteAgent
Class core

LiteAgent: Reference Guide

By DevShelfHub

A lightweight single-agent runtime — execute one agent with tools and guardrails, without setting up a Crew.

See the CrewAI API reference index, CrewAI introduction, and core concepts for surrounding context.

What is LiteAgent?

LiteAgent is CrewAI's answer to "I just need one model call with tools and maybe a validator" without standing up Task objects, a Crew graph, or hierarchical planning. You construct it with the same role / goal / backstory vocabulary as Agent, attach tools and guardrails, then call .run(prompt) for a single completion cycle. That makes it ideal for Flow methods that perform a quick summarization, classification, or API-backed lookup before handing off to a full multi-agent crew for heavier work.

Because LiteAgent bypasses crew scheduling, you lose built-in task context wiring and cross-agent delegation — anything that looks like a pipeline of distinct responsibilities should graduate to Crew + Task. What you keep is predictable latency, smaller stack traces, and straightforward unit testing: mock tools, freeze the llm parameter, and assert on the string or structured object returned from run().

Observability still applies: LiteAgent emits execution lifecycle events compatible with the rest of CrewAI, so traces nest correctly when invoked from a parent Flow. Treat it as a sharp utility knife, not a replacement for crews when collaboration boundaries matter.

When to Use

One-shot utilities, micro-flows, embedding agents inside larger apps.

Use Cases

  • Embedded utilities
  • Single-purpose APIs
  • Quick chatbots

Key Features

  • No Crew/Tasks overhead
  • Guardrail integration
  • Parent-flow identification

When NOT to Use

Multi-agent collaboration — use a Crew.

Notes

No delegation channel

LiteAgent has no peer agents to hand work to. If the model asks to delegate, nothing listens — tighten prompts or move to Crew with allow_delegation and explicit roles.

Tool budget vs latency

Every tool schema adds tokens. For micro flows, prefer one well-scoped tool over five occasional ones to keep run() fast and under context limits.

Guardrails and retries

Callable guardrails behave like Task guardrails: failures should return actionable strings so the model can self-correct within the same run() instead of looping blindly.

Testing

Swap llm for a stub in unit tests and assert on tool call arguments. LiteAgent's surface is small enough that pytest fixtures stay readable without full crew bootstrapping.

Import

python
from crewai import LiteAgent

Key Parameters

Parameter Type Default Purpose
role / goal / backstory str Same identity fields as Agent.
tools list[BaseTool] [] Optional tools.
guardrails list[Callable] [] Output validators.

Code Examples

Minimal summarizer

python
from crewai import LiteAgent

agent = LiteAgent(
    role='Summarizer',
    goal='Return a 5-bullet executive summary',
    backstory='You prefer active voice and concrete metrics.',
)
print(agent.run(open('notes.md').read()))

With tools for a lookup + answer

python
from crewai import LiteAgent
from crewai_tools import SerperDevTool

research = LiteAgent(
    role='Quick researcher',
    goal='Answer with cited sources',
    backstory='Call Serper once, then synthesize.',
    tools=[SerperDevTool()],
)
print(research.run('Latest CrewAI release highlights'))

Inside a Flow step

python
from crewai import LiteAgent
from crewai.flow.flow import Flow, listen, start

class Pipeline(Flow):
    @start()
    def classify(self):
        agent = LiteAgent(role='Classifier', goal='Label intent', backstory='JSON only.')
        return agent.run(self.state.user_message)

Common Mistakes

❌ Trying to delegate from a LiteAgent

✅ Use a Crew with allow_delegation=True if you need delegation.

LiteAgent FAQ

What is LiteAgent in CrewAI?

A lightweight single-agent runtime — execute one agent with tools and guardrails, without setting up a Crew. LiteAgent is CrewAI's answer to "I just need one model call with tools and maybe a validator" without standing up Task objects, a Crew graph, or hierarchical planning. You construct it with the same role / goal / backstory vocabulary as Agent, attach tools and guardrails, then call .run(prompt) for a single completion cycle. That makes it ideal for Flow methods that perform a quick summarization, classification, or API-backed lookup before handing off to a full multi-agent cr…

Which package defines the CrewAI class LiteAgent?

DevShelfHub maps LiteAgent to Python module crewai (package path crewai in this reference). Pin your installed crewai version and match imports to the snippet on this page.

When should I use LiteAgent?

One-shot utilities, micro-flows, embedding agents inside larger apps.

When should I avoid using LiteAgent?

Multi-agent collaboration — use a Crew.

How do I import LiteAgent in Python?

from crewai import LiteAgent

Where can I explore more CrewAI API reference pages?

Open the CrewAI API reference index on DevShelfHub to search 58 classes, 30 methods, and 16 decorators, each with runnable examples, parameters, common mistakes, and cross-links.