Repository navigation
Deployment Guide
weego edited this page May 28, 2026
·
1 revision
LightAgent is a Python library. Most production deployments wrap it in an application service such as FastAPI, Flask, a worker process, or an internal automation job.
Use environment variables for provider credentials:
export OPENAI_API_KEY="your_api_key"
export OPENAI_BASE_URL="https://api.openai.com/v1"Avoid hardcoding keys in code, examples, or Wiki pages.
from fastapi import FastAPI
from pydantic import BaseModel
from LightAgent import LightAgent
app = FastAPI()
agent = LightAgent(
model="gpt-4.1",
api_key=None,
base_url=None,
)
class ChatRequest(BaseModel):
query: str
user_id: str = "default_user"
@app.post("/chat")
def chat(req: ChatRequest):
result = agent.run(req.query, user_id=req.user_id, result_format="object")
return {
"content": result.content,
"trace_id": result.trace_id,
"error": result.error,
}Use stream=True when building a streaming endpoint:
def generate(query: str, user_id: str):
for chunk in agent.run(query, stream=True, user_id=user_id):
yield chunkFor typed events, use result_format="event" and serialize each StreamEvent.
- Pin package versions.
- Use environment variables or secret managers.
- Add request timeouts at the application layer.
- Keep tool outputs compact.
- Add memory namespace policies for shared backends.
- Disable or isolate built-in code execution tools for untrusted users.
- Enable trace only where data handling is approved.
- Add rate limits and concurrency controls.
- Log
trace_id, user id, tool names, and status metadata.
LightAgent itself can be used in stateless request handlers, but memory backends, logs, trace exports, and application histories are stateful. Decide where each state type lives:
- conversation history: application database
- long-term memory: memory backend
- trace and logs: observability stack
- files and artifacts: object storage
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