Quickstart
Agent system for Lexigram — AI agents with tools, strategies, and execution.
Install
Section titled “Install”uv add lexigram-ai-agentsMinimal Agent
Section titled “Minimal Agent”import asyncio
from lexigram import Applicationfrom lexigram.ai.agents import AgentBase, AgentConfig, toolfrom lexigram.ai.agents import AgentsModulefrom lexigram.contracts.ai import AgentExecutorProtocol
@toolasync def get_weather(city: str) -> str: """Get the current weather for a city.""" return f"Sunny, 22°C in {city}"
class WeatherAgent(AgentBase): name = "weather_agent" system_prompt = "You are a helpful weather assistant."
@property def tools(self): return [get_weather]
async def main(): config = AgentConfig(max_iterations=10, default_temperature=0.3) async with Application.boot( name="agent-demo", modules=[AgentsModule.configure(config)], ) as app: executor = await app.container.resolve(AgentExecutorProtocol) result = await executor.run( agent=WeatherAgent(), message="What is the weather in Tokyo?", ) if result.is_ok(): print(result.unwrap().message)
asyncio.run(main())What Just Happened
Section titled “What Just Happened”@tooldecorated a function — auto-generated its JSON schema for the LLM.AgentBasesubclass declared identity, persona, and tools.AgentsModule.configure(config)wiredAgentsProviderinto the container.AgentExecutorProtocolresolved the executor from DI.executor.run()returnedResult[AgentResponse, AgentError].
Next Steps
Section titled “Next Steps”- Guide — agents, strategies, execution in depth
- How-Tos — common agent patterns
- Configuration — all config keys