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 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 commandsFileReadTool/FileWriteTool- File operationsHTTPFetchTool- HTTP requestsRecallTool/RememberTool- Memory operations
Running as a Service
# Start agent server
llm-gent serve
# Or with specific config
llm-gent -c etc/llm-gent.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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_gent-0.3.1.tar.gz.
File metadata
- Download URL: llm_gent-0.3.1.tar.gz
- Upload date:
- Size: 246.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9942ab6af2adbd1a05b9b4a76699def21b12566a660d8e488db33db24227498e
|
|
| MD5 |
874dbea1c0bf722b2ae5225316007818
|
|
| BLAKE2b-256 |
a5ce2ab3a25f45d2b5da8e91970611185a60f6dba94fe0d7423e8c714155f521
|
Provenance
The following attestation bundles were made for llm_gent-0.3.1.tar.gz:
Publisher:
release.yml on llm-works/llm-gent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_gent-0.3.1.tar.gz -
Subject digest:
9942ab6af2adbd1a05b9b4a76699def21b12566a660d8e488db33db24227498e - Sigstore transparency entry: 2647687386
- Sigstore integration time:
-
Permalink:
llm-works/llm-gent@00ce1b818a50376bf953ee0a8b5c6cf09152725b -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/llm-works
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@00ce1b818a50376bf953ee0a8b5c6cf09152725b -
Trigger Event:
push
-
Statement type:
File details
Details for the file llm_gent-0.3.1-py3-none-any.whl.
File metadata
- Download URL: llm_gent-0.3.1-py3-none-any.whl
- Upload date:
- Size: 211.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12d934b20fb26b4c652590b89c92adb14df841f7bf395a0db10f077b76e7d566
|
|
| MD5 |
67f8b52dae19dc027b22260ad4aa4139
|
|
| BLAKE2b-256 |
754ba6eac8e579e334e417c500cf7d612656d5d484025e3e6a120314d5e940b7
|
Provenance
The following attestation bundles were made for llm_gent-0.3.1-py3-none-any.whl:
Publisher:
release.yml on llm-works/llm-gent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_gent-0.3.1-py3-none-any.whl -
Subject digest:
12d934b20fb26b4c652590b89c92adb14df841f7bf395a0db10f077b76e7d566 - Sigstore transparency entry: 2647687390
- Sigstore integration time:
-
Permalink:
llm-works/llm-gent@00ce1b818a50376bf953ee0a8b5c6cf09152725b -
Branch / Tag:
refs/tags/v0.3.1 - Owner: https://github.com/llm-works
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@00ce1b818a50376bf953ee0a8b5c6cf09152725b -
Trigger Event:
push
-
Statement type: