Skip to main content

llm-gent

Agent framework with trait-based architecture and learning capabilities.

Overview

llm-gent provides a composable framework for building LLM-powered agents. Agents are composed of traits that provide specific capabilities (LLM access, storage, learning, etc.) and can be run standalone or as services via the included HTTP runtime.

Key features:

  • Trait-based composition - Mix and match capabilities via traits (LLM, Storage, Rating, Learn)
  • Multi-backend LLM support - OpenAI-compatible, Anthropic, and custom backends via llm-infer
  • Built-in learning - Collect training data (SFT/DPO) and fine-tune via llm-kelt
  • Structured output - Pydantic schema validation with automatic JSON cleanup for small models
  • Production ready - HTTP server, PostgreSQL storage, schema migrations

Installation

pip install llm-gent

For HTTP server support:

pip install llm-gent[http]

Supported Python versions

CI tests against Python 3.11, 3.12, 3.13, and 3.14 on every push. requires-python = ">=3.11".

Quick Start

from appinfra import DotDict
from appinfra.log import create_lg

from llm_gent import Agent, LLMTrait
from llm_gent.core.agent.types import ExecutionResult


# The public Agent class is abstract — a real application defines a small
# concrete subclass. Trivial stubs suffice when the workflow only uses
# LLMTrait.complete() directly.
class HelloAgent(Agent):
    def start(self) -> None:
        self._start_traits()

    def stop(self) -> None:
        self._stop_traits()

    def run_once(self) -> ExecutionResult:
        return ExecutionResult(success=True, content="")

    def ask(self, question: str) -> str:
        return ""

    def record_feedback(self, message: str) -> None:
        pass

    def get_recent_results(self, limit: int = 10) -> list[ExecutionResult]:
        return []


lg = create_lg("hello-agent", "info")

# Agent reads config.identity.name internally.
config = {"identity": {"name": "hello-agent"}}

llm_config = DotDict(
    {
        "default": "local",
        "backends": {
            "local": {
                "type": "openai_compatible",
                "base_url": "http://localhost:8000/v1",
                "model": "default",
            }
        },
    }
)

agent = HelloAgent(lg, config)
agent.add_trait(LLMTrait(agent, llm_config))
agent.start()

# LLMTrait.complete() accepts OpenAI-style message dicts.
llm = agent.require_trait(LLMTrait)
result = llm.complete(
    [
        {"role": "system", "content": "You are a concise assistant."},
        {"role": "user", "content": "Say hello."},
    ]
)
print(result.content)

agent.stop()

A runnable version of this example lives at llm_gent/examples/quickstart.py. Set LLM_GENT_SMOKE=1 to run it against a stub LLM router (used by CI's wheel-smoke job).

Core Concepts

Agents

An Agent is a container for traits with lifecycle management. Agents have an identity (domain/workspace/name) and can be started, stopped, and run in cycles.

Traits

Traits provide specific capabilities to agents:

Trait Purpose
LLMTrait LLM completions with multi-backend routing
DirectiveTrait System prompts and agent instructions
StorageTrait PostgreSQL persistence with migrations
RatingTrait Automated LLM-based content evaluation
LearnTrait Training data collection (SFT/DPO)
ToolsTrait Tool/function calling support

Tools

Built-in tools for agentic workflows:

  • ShellTool - Execute shell commands
  • FileReadTool / FileWriteTool - File operations
  • HTTPFetchTool - HTTP requests
  • RecallTool / RememberTool - Memory operations

Running as a Service

# Start agent server (uses packaged default config)
llm-gent serve

# With custom config
llm-gent --config path/to/config.yaml serve

Related Projects

  • llm-infer - LLM inference server and client
  • llm-kelt - Training infrastructure (SFT/DPO)
  • appinfra - Application infrastructure utilities

License

Apache License 2.0 - see LICENSE for details.

Maintained by LLM Works LLC and contributors.

Download files

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

Source Distribution

llm_gent-0.3.3.tar.gz (247.8 kB view details)

Uploaded Source

Built Distribution

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

llm_gent-0.3.3-py3-none-any.whl (222.6 kB view details)

Uploaded Python 3

File details

Details for the file llm_gent-0.3.3.tar.gz.

File metadata

  • Download URL: llm_gent-0.3.3.tar.gz
  • Upload date:
  • Size: 247.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for llm_gent-0.3.3.tar.gz
Algorithm Hash digest
SHA256 3fd208c0282063c7582fda6cda2909563d3909cf7a48cd386a7db357d2c826ba
MD5 3ff9530459be7e18ad1f32f411725577
BLAKE2b-256 eb25bf11ad9938a1c27a517a90eb404211df6d9dbd0f9f6c409e61d9aeb531c1

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_gent-0.3.3.tar.gz:

Publisher: release.yml on llm-works/llm-gent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file llm_gent-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: llm_gent-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 222.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for llm_gent-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 eb6bfdf4d3a751cbddc429a827ad455ce8bae0e471a1bd4732443e5e6c740bde
MD5 e05c38c91fafafc93b3ddae60e680619
BLAKE2b-256 e0bebb73d41e0fdfdc28dec2e430cbab32ef0a39d1d7889e7d2ba25cfb564ff5

See more details on using hashes here.

Provenance

The following attestation bundles were made for llm_gent-0.3.3-py3-none-any.whl:

Publisher: release.yml on llm-works/llm-gent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.3.3 This release

2 files

0.3.2

2 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

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