Skip to main content

Lightweight LLM agent library — memory layers, skills, context engineering

Project description

uc-llm-agent-tools

Lightweight LLM agent library — memory layers, skills, context engineering.

Works with any LLM: Anthropic, OpenAI, Google, Ollama. Built on uc-llm-provider.

PyPI Python License


Why

Most agent frameworks are complex, opinionated, and hard to embed. uc-llm-agent-tools is a small, composable library:

  • No mandatory vector DB — SQLite by default
  • No framework lock-in — works with any provider via uc-llm-provider
  • Context Engineering first — token budget, anti-fail guards built in
  • Readable memory — Identity and memories are Markdown files

Install

pip install uc-llm-agent-tools

Quick Start

import asyncio
from uc_llm_agent_tools import Agent, Identity, MemoryStore, MemoryLayer, skill, SkillResult
from uc_llm_agent_tools.memory.backends.sqlite import SQLiteBackend
from uc_llm_provider import get_provider

# Define a skill
@skill(name="fetch_page", description="Fetch and analyze a web page", tags=["browser"])
async def fetch_page(url: str) -> SkillResult:
    # your implementation here
    return SkillResult(success=True, content=f"Page at {url} analyzed", data={})

# Create agent
agent = Agent(
    identity = Identity.from_file("my-identity.md"),
    memory   = MemoryStore(
        backend = SQLiteBackend("agent.sqlite3"),
        layers  = [
            MemoryLayer("project", level=2, persist=True),
            MemoryLayer("run",     level=3, persist=False),
        ]
    ),
    skills   = [fetch_page],
    provider = get_provider({"name": "anthropic", "provider_type": "anthropic"}),
)

async def main():
    result = await agent.run("Analyze https://example.com for accessibility issues")
    print(result.response)

asyncio.run(main())

Identity File

---
name: My Agent
version: 1.0
---

# Persönlichkeit

I am a QA specialist. I test systematically and precisely.

# Direktiven

- Never test production systems without explicit confirmation.
- Always report errors — never swallow them silently.

Directives are immutable at runtime. Personality grows via agent.identity.add_fact(...).

Memory Hierarchy

Level 0: Directives   — always loaded, never overridden
Level 1: Personality  — always loaded, grows over time
Level N: custom named — filtered by budget and relevance

High beats low. Low complements high.

Context Engineering

ContextBuilder prevents the four context failure modes automatically:

Guard Problem prevented
Poisoning Guard LLM-sourced memories are marked [LLM]
Distraction Guard Run-memory capped when context grows too large
Confusion Guard Max 8 skills loaded at once
Clash Guard Hierarchy enforces priority

ThinkingLight

Provider-independent Chain-of-Thought — works on Ollama, GPT, Claude alike. No expensive Extended Thinking required.

from uc_llm_agent_tools import wrap_prompt, extract_thinking

prompt   = wrap_prompt("Analyze this page")
thinking, answer = extract_thinking(llm_response)

Human-in-the-Loop

from uc_llm_agent_tools import HumanInTheLoop

hitl = HumanInTheLoop(on_pause=my_approval_handler)
decision = await hitl.pause(
    message  = "I found 47 test ideas. Generate all as Gherkin?",
    options  = ["All", "High priority only", "Cancel"],
    timeout  = 300,
    fallback = "High priority only",
)

Structured Output

from uc_llm_agent_tools import structured_ai
from pydantic import BaseModel

class TestReport(BaseModel):
    summary: str
    issues:  list[str]

report = await structured_ai(provider, "Analyze this page", TestReport)
# report is a validated TestReport instance

Interactive Session

session = agent.interactive_session()
response = await session.chat("Why did you choose that selector?")
response = await session.chat("Now test the login form specifically")

License

MIT — uc-it

Project details


Download files

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

Source Distribution

uc_llm_agent_tools-0.1.1.tar.gz (24.2 kB view details)

Uploaded Source

Built Distribution

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

uc_llm_agent_tools-0.1.1-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

Details for the file uc_llm_agent_tools-0.1.1.tar.gz.

File metadata

  • Download URL: uc_llm_agent_tools-0.1.1.tar.gz
  • Upload date:
  • Size: 24.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for uc_llm_agent_tools-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d21dd80942d30881915fca6f6d3b9e848bc1835733d73ad4b982107dfa70a6fd
MD5 40dad3db0afe778b679884fce5d511e3
BLAKE2b-256 0e7f08cb723a7d7fe7d6fbf19911da1e9340f412d2de271baa6b05e9f29f6ec9

See more details on using hashes here.

File details

Details for the file uc_llm_agent_tools-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for uc_llm_agent_tools-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 661354bec1d66e611d60a945bcec39b16d81bc241449dcd15a73ea037cfe75a5
MD5 b1efb03d3df00998de5035d942d7ee70
BLAKE2b-256 f9c7d740d36dcfe91b097dd7805d2e99d8b3bc07b5fbfafe266c386a09b68bb5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page