Repository navigation
Core Concepts
weego edited this page Jun 5, 2026
·
2 revisions
LightAgent is the main runtime object. It owns:
- model configuration
- tool registry
- optional memory backend
- optional Skills discovery
- optional Tree-of-Thought planning
- optional tracing and debug logging
- optional MCP tool registration
- optional LightFlow workflow composition
Typical constructor:
from LightAgent import LightAgent
agent = LightAgent(
name="SupportAgent",
instructions="You are a helpful support agent.",
role="Answer product support questions.",
model="gpt-4.1",
api_key="your_api_key",
base_url="https://api.openai.com/v1",
)At a high level, agent.run() performs these steps:
- Create a trace id for the run.
- Register runtime tools passed through
tools=[...]. - Optionally let
LightSwarmdecide whether to hand off the task. - Build the system prompt from agent name, instructions, role, date, and time.
- Add Skills metadata if Skills are discovered.
- Retrieve memory context if a memory backend is configured.
- Optionally run Tree-of-Thought planning.
- Send a chat completion request.
- Execute model-selected tools when tool calls are returned.
- Return a string,
RunResult, legacy stream generator, orStreamEventgenerator.
LightFlow sits above individual agents. It does not replace LightAgent.run(); it coordinates multiple agent runs as named deterministic steps.
Use LightFlow when the workflow shape is known in advance:
- research then write
- extract then validate then summarize
- classify then route to a fixed follow-up step
- run independent steps and combine their outputs
Each step has a unique name, an agent, optional dependencies, optional runtime tools, and an optional custom query builder. Dependency outputs are available to later steps through the flow context.
| Object | Purpose |
|---|---|
LightAgent |
Main agent runtime |
LightFlow |
Deterministic DAG-style workflow runner for named agent steps |
LightFlowStep |
Step configuration used by LightFlow.step()
|
LightFlowStepResult |
Structured result for one completed or failed flow step |
LightFlowResult |
Structured result for the whole flow |
LightSwarm |
Simple multi-agent registration and handoff helper |
ToolRegistry |
Stores tool metadata and callable mappings |
ToolLoader |
Loads named tools from a tools directory |
AsyncToolDispatcher |
Executes sync, async, and generator tools |
MemoryProtocol |
Minimal memory interface contract |
MemoryPolicy |
Optional namespace and retrieval safety policy |
RunResult |
Optional structured non-streaming result |
StreamEvent |
Optional structured streaming event |
TraceRecorder |
Records structured trace events |
SkillManager |
Discovers and activates SKILL.md based Skills |
| Call | Return |
|---|---|
agent.run("hello") |
str |
agent.run("hello", result_format="object") |
RunResult |
agent.run("hello", result_format="dict") |
dict |
agent.run("hello", stream=True) |
generator of legacy chunks |
agent.run("hello", stream=True, result_format="event") |
generator of StreamEvent
|
- Existing
agent.run("hello")code remains compatible. - Existing
agent.run(query, stream=True, user_id=user_id)code remains compatible. - Structured results and structured streaming events are opt-in.
-
result_format="event"requiresstream=True. -
result_format="object"andresult_format="dict"are non-streaming modes.
LightAgent Wiki - see the repository, releases, and issues.
- Installation and Your First Agent
- Tools and Integrations
- Memory, Sessions, and RAG
- Workflows and Multiple Agents
- Agent Backends and Codex
- Durable Execution, Jobs, and Subagents
- Safety, Observability, and Evaluation
- Usage, Cost Estimates, and Budgets
- Deployment, Migration, and Verification
- 安装与第一个 Agent
- 工具和集成
- 记忆、会话与 RAG
- 工作流与多 Agent
- 执行后端与 Codex
- 持久执行、Jobs 与 Subagents
- 安全、观测与评测
- 用量统计、费用估算与预算
- 部署、升级与验收
- Quick Start
- Core Concepts
- API Reference
- Examples Cookbook
- Migration Guide
- Tools
- Tool Generator
- Memory
- MCP
- Skills
- LightFlow
- Tree of Thought
- Self-Learning
- Multi-Agent
- Tracing and Debugging
- Langfuse Observability
- Model Providers
- browser-use Integration
- Testing and CI
- Deployment Guide
- Architecture
- Security
- Known Limitations
- FAQ
- FAQ 中文
- Roadmap
- Release Process
- Contributing