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.log import create_lg
from llm_gent import AgentFactory, LLMTrait
lg = create_lg("my-agent", "info")
agent = AgentFactory(lg).from_config(
{
"identity": {"name": "my-agent"},
"llm": {
"default": "local",
"backends": {
"local": {
"type": "openai_compatible",
"base_url": "http://localhost:8000/v1",
"model": "default",
}
},
},
"directive": "You are a helpful assistant.",
"traits": {"required": ["llm", "directive"]},
}
)
agent.start()
llm = agent.require_trait(LLMTrait)
result = llm.complete([{"role": "user", "content": "Hello!"}])
print(result.content)
agent.stop()
A runnable version of this example lives at llm_gent/examples/quickstart.py. Pass
--smoke to run it against a stub LLM router (no real backend contacted).
Core Concepts
Agents
An Agent is a container for traits with lifecycle management. Agents have an identity
(name plus optional context_key) and can be started, stopped, and — via
RunnableAgent — 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 commandsFileReadTool/FileWriteTool- File operationsHTTPFetchTool- HTTP requestsRecallTool/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.
Metadata
Release files for llm-gent 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| llm_gent-0.4.0.tar.gz | 626.2 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llm_gent-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.1 MB
Release files / llm_gent-0.4.0.tar.gz
| Download URL | llm_gent-0.4.0.tar.gz |
|---|---|
| Size | 626.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3fa77bce0971be67ea357d4cc289e20454147da338faea66261b9614901d174e
|
|
BLAKE2b-256 checksum How to use checksums |
d055badffa4869c4a6c1618adc7d6b0c08c1cdc117354e0fc42dd336f9a60e5a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.
Transparency logRelease files / llm_gent-0.4.0-py3-none-any.whl
| Download URL | llm_gent-0.4.0-py3-none-any.whl |
|---|---|
| Size | 465.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
53e3cf5d8ce4491139abc014f416b46535e16084d4f62e8febd5df596843fc6e
|
|
BLAKE2b-256 checksum How to use checksums |
fb6034ea0a1fa7835e3fd5a0231fa82faefac53930daa260e9e1365d7e781ffe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.
Transparency logSecurity for llm-gent 0.4.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for llm_gent-0.4.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 26, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.