How salesforceairesearch/agentlite works
Project type and purpose
• AgentLite is a Python research-oriented library for building LLM-based task-oriented agents and multi-agent systems. It provides core abstractions (Actions, Prompts, Agents, Memory, Logging) and an orchestrator (ManagerAgent) plus optional UI, example scripts, benchmarks and tutorials.
File structure
• Top-level directories:
• agentlite/ ← core library
– actions/ ← BaseAction, custom tool wrappers
– agent_prompts/ ← BasePrompt, prompt utilities
– agents/ ← BaseAgent, ManagerAgent, agent utilities
– commons/ ← TaskPackage, AgentAct, shared data types
– llm/ ← LLMConfig, agent_llms (factory for LLM backends)
– memory/ ← AgentSTMemory, memory utilities
– logging/ ← base logger, terminal and streamlit loggers
– utils.py ← core helper functions
• app/ ← Streamlit UI demo (Homepage.py + pages)
• benchmark/ ← evaluation scripts (hotpotqa, tool-operation, tool, webshop)
• example/ ← standalone agent scripts and notebooks
• docs/, tutorials/ ← Sphinx docs, Jupyter tutorials
• tests/ ← unit tests
• setup.py, requirements.txt
Architecture overview from README
• Core library exposes a clear plugin API: define Actions → wrap in BaseAgent → orchestrate with ManagerAgent.
• LLM backends are pluggable via LLMConfig and get_llm_backend.
• State can be persisted via AgentSTMemory.
• Logging sinks to console or Streamlit.
• UI and benchmarks sit on top of the core.
Main components
a. Core Library (agentlite)
• Actions module
• Agent Prompts module
• Agents module (BaseAgent, ManagerAgent)
• Commons (TaskPackage, AgentAct)
• LLM layer (LLMConfig, get_llm_backend)
• Memory layer (AgentSTMemory)
• Logging layer (base, terminal, streamlit)
• Utils
b. External Services
• LLM APIs (OpenAI, custom backends)
• Third-party tools invoked by Actions (e.g., Wikipedia API)
c. Orchestrator
• ManagerAgent coordinates TeamAgents
d. UI Layer (Streamlit app)
e. Benchmarks & Examples
• Benchmark runners call ManagerAgent or Agents
• Example scripts demonstrate usage
Relationships and data flow
• TaskPackage (instruction + metadata) flows from UI / CLI / benchmark → ManagerAgent or BaseAgent.
• Agent uses:
1. LLM layer to generate next action or response using AgentPrompts.
2. Actions to call external tools.
3. Memory to read/write context.
4. Commons to package AgentAct results into TaskPackage.
5. Logging module to emit logs (to console or UI).
• ManagerAgent routes TaskPackage to multiple BaseAgents, merges their outputs.
• UI layer invokes ManagerAgent / BaseAgent, displays results, and logs via streamlit_logger.
Architectural patterns & design principles
• Plugin/Strategy pattern: Actions and Prompts are interchangeable plugins.
• Orchestrator pattern: ManagerAgent coordinates multiple agents in sequence or parallel.
• Separation of concerns: distinct layers for LLM, Actions, Memory, Logging.
• Lightweight core: minimal coupling, easy extension.
• Data flow is explicit via TaskPackage and AgentAct structures.
Technologies & frameworks
• Python 3.9+
• LangChain (for tool wrappers in examples)
• OpenAI (or any LLM via pluggable backends)
• Streamlit (UI demo)
• Sphinx (docs)
• pytest (tests)
Elements
• Clear, human-readable labels for each module.
– Rectangles for modules/packages
– Clouds for external services (LLM API, Wikipedia).