Skip to main content

lexigram-ai-agents

Agent system for Lexigram Framework - AI agents with tools, strategies, and execution


Overview

Agent orchestration package for the Lexigram Framework. Provides agent base classes, tool registration, execution strategies (ReAct, Plan-and-Execute, Reflexion, Supervisor), observability, and multi-agent coordination — all wired through DI via AgentsModule. Zero-config usage starts with sensible defaults.

Full documentation: docs.lexigram.dev

Install

uv add lexigram-ai-agents

Quick Start

from lexigram import Application
from lexigram.di.module import Module, module

from lexigram.ai.agents import AgentsModule
from lexigram.ai.agents.config import AgentConfig
from lexigram.ai.llm import LLMModule


@module(
    imports=[
        LLMModule.stub(),  # provides LLMClientProtocol
        AgentsModule.configure(AgentConfig(max_iterations=10)),
    ]
)
class AppModule(Module):
    pass


async with Application.boot(modules=[AppModule]) as app:
    # use app.container to resolve services
    ...

Note: AgentsModule requires an LLM client (LLMClientProtocol) in the container — provided by LLMModule (from lexigram-ai-llm). When using a real LLM provider, set OPENAI_API_KEY (or configure your provider in ClientConfig).

Configuration

Zero-config usage: Call AgentsModule.configure() with no arguments to use defaults.

Option 1 — YAML file

# application.yaml
ai_agents:
  max_iterations: 10
  default_temperature: 0.7
  default_max_tokens: 2048
  enable_tracing: true

Option 2 — Profiles + Environment Variables (recommended)

export LEX_AI_AGENTS__MAX_ITERATIONS=15
# Environment variables for each field

Option 3 — Python

from lexigram.ai.agents.config import AgentConfig
from lexigram.ai.agents import AgentsModule

config = AgentConfig(max_iterations=10)
AgentsModule.configure(config)

Config reference

Field Default Env var Description
enabled True LEX_AI_AGENTS__ENABLED Enable the agent subsystem
max_iterations 10 LEX_AI_AGENTS__MAX_ITERATIONS Maximum reasoning iterations per execution
default_temperature 0.7 LEX_AI_AGENTS__DEFAULT_TEMPERATURE Default LLM temperature
default_max_tokens 2048 LEX_AI_AGENTS__DEFAULT_MAX_TOKENS Default max tokens for LLM responses
tool_max_retries 3 LEX_AI_AGENTS__TOOL_MAX_RETRIES Retry attempts for transient tool errors
enable_tracing True LEX_AI_AGENTS__ENABLE_TRACING Enable OpenTelemetry tracing
enable_metrics True LEX_AI_AGENTS__ENABLE_METRICS Enable Prometheus metrics

Module Factory Methods

Method Description
AgentsModule.configure(config, enable_multi_agent) Configure with explicit config
AgentsModule.stub() Minimal config for testing

Key Features

  • Agent base classes: AgentBase for defining agents with tools and system prompts
  • Execution strategies: ReAct, Plan-and-Execute, Reflexion, Supervisor
  • Tool system: @tool decorator for registering standalone tool functions
  • Multi-agent coordination: AgentAsToolAdapter for agent-to-agent delegation
  • Observability: Built-in tracing and metrics via AgentTracer and AgentMetrics

Testing

from lexigram.ai.llm import LLMModule

async with Application.boot(modules=[LLMModule.stub(), AgentsModule.stub()]) as app:
    # your test code
    ...

AgentsModule.stub() alone fails container validation without an LLMClientProtocol in the container — pair it with LLMModule.stub() as shown.

Key Source Files

File What it contains
src/lexigram/ai/agents/module.py AgentsModule.configure() and stub()
src/lexigram/ai/agents/config.py AgentConfig and environment variable bindings
src/lexigram/ai/agents/agent/base.py AgentBase class with tools and prompts
src/lexigram/ai/agents/executor/executor.py AgentExecutorImpl — strategy execution loop
src/lexigram/ai/agents/tools/registry.py ToolRegistryImpl and @tool decorator
src/lexigram/ai/agents/strategies/react.py ReAct reasoning loop
src/lexigram/ai/agents/di/provider.py AgentsProvider — registers agents into DI

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lexigram_ai_agents-0.1.4.tar.gz (110.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lexigram_ai_agents-0.1.4-py3-none-any.whl (90.5 kB view details)

Uploaded Python 3

File details

Details for the file lexigram_ai_agents-0.1.4.tar.gz.

File metadata

  • Download URL: lexigram_ai_agents-0.1.4.tar.gz
  • Upload date:
  • Size: 110.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.14

File hashes

Hashes for lexigram_ai_agents-0.1.4.tar.gz
Algorithm Hash digest
SHA256 6e13061af209b5828673f4932c5a7b22ef9796f0806b2cfd54c6e4e5c6abdb10
MD5 306829209c07add89cc79f1be7e4d6f9
BLAKE2b-256 4015a1e56178d805e969713deecb5579fbd4f2167150bfdfcb9a21dda36d7872

See more details on using hashes here.

File details

Details for the file lexigram_ai_agents-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for lexigram_ai_agents-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e7473373ba49ee84f549444e5e70341fa0844f82b22e286a7cfd1cfc7b3facfa
MD5 bff31cdd5b3c3c9378e74529cb823430
BLAKE2b-256 d8699848cba34dc2e2c27731891fccce0bdcdd5d4050789255dcc0625b9aa1a8

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.5003

1 file

0.1.5001

2 files

0.1.3007

1 file

0.1.3006

1 file

0.1.3005

1 file

This release

0.1.4 This release

2 files

0.1.2

1 file

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page