2026-06-30 21:43:00 +00:00
|
|
|
# rony-llm-agent
|
2026-06-28 23:03:57 +00:00
|
|
|
|
2026-06-30 20:40:37 +00:00
|
|
|
> 🌐 **Language:** [English](./README.md) | [Español](./README.es.md)
|
|
|
|
|
>
|
|
|
|
|
> 🔑 **Reusable core library** for building LLM agents in Go.
|
2026-06-28 23:03:57 +00:00
|
|
|
|
2026-06-30 20:40:37 +00:00
|
|
|
This library is the heart of several Victor Vargas projects:
|
2026-06-28 23:03:57 +00:00
|
|
|
|
2026-06-30 20:40:37 +00:00
|
|
|
- [`harness`](https://github.com/VictorVargas/rony-harness) — AI agent harness for software development (TUI)
|
|
|
|
|
- [`chat-bot`](https://github.com/VictorVargas/rony-chat-bot) — HTTP chatbot for portfolios and websites
|
2026-06-28 23:03:57 +00:00
|
|
|
|
2026-06-30 20:40:37 +00:00
|
|
|
It provides all the **generic** logic of an LLM agent:
|
|
|
|
|
|
|
|
|
|
| Component | Location | Responsibility |
|
2026-06-28 23:03:57 +00:00
|
|
|
|---|---|---|
|
2026-06-30 20:40:37 +00:00
|
|
|
| **Agent loop** | `pkg/agent/` | Iterative loop with guardrails |
|
|
|
|
|
| **LLM clients** | `pkg/llm/` | Multi-provider abstraction (OpenAI, Anthropic, Ollama) |
|
|
|
|
|
| **RAG / memory** | `pkg/rag/` | Short and long-term memory with semantic search |
|
|
|
|
|
| **Persona system** | `pkg/persona/` | Configurable system prompts + AGENTS.md discovery |
|
2026-06-28 23:03:57 +00:00
|
|
|
| **Tool registry** | `pkg/tools/` | JSON Schema + execution sandbox |
|
2026-06-30 20:40:37 +00:00
|
|
|
| **Config loading** | `pkg/config/` | YAML loading with hierarchical precedence |
|
2026-06-28 23:03:57 +00:00
|
|
|
|
2026-06-30 20:40:37 +00:00
|
|
|
## 🎯 Philosophy
|
2026-06-28 23:03:57 +00:00
|
|
|
|
2026-06-30 20:40:37 +00:00
|
|
|
- **Reusable, not opinionated.** Does not force a UI type, deployment, or use case.
|
|
|
|
|
- **Pure Hexagonal.** Ports & adapters — every external dependency is behind an interface.
|
|
|
|
|
- **Streaming-first.** Uses `iter.Seq2` from Go 1.23+ for natural streaming without callbacks.
|
|
|
|
|
- **Secure by default.** Filesystem path sandbox with `os.Root` (Go 1.24+).
|
|
|
|
|
- **Zero magic.** No reflection, no codegen, no DSLs. Idiomatic and explicit Go.
|
|
|
|
|
- **YAML configurable.** Everything that affects behavior is declarative.
|
2026-06-28 23:03:57 +00:00
|
|
|
|
2026-06-30 20:40:37 +00:00
|
|
|
## 📦 Installation
|
2026-06-28 23:03:57 +00:00
|
|
|
|
|
|
|
|
```bash
|
2026-06-29 06:22:15 +00:00
|
|
|
go get github.com/VictorVargas/rony-llm-agent
|
2026-06-28 23:03:57 +00:00
|
|
|
```
|
|
|
|
|
|
2026-06-30 20:40:37 +00:00
|
|
|
## 🚀 Basic usage
|
2026-06-28 23:03:57 +00:00
|
|
|
|
|
|
|
|
```go
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"fmt"
|
2026-06-29 06:22:15 +00:00
|
|
|
"github.com/VictorVargas/rony-llm-agent/pkg/agent"
|
|
|
|
|
"github.com/VictorVargas/rony-llm-agent/pkg/llm"
|
|
|
|
|
"github.com/VictorVargas/rony-llm-agent/pkg/persona"
|
2026-06-28 23:03:57 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func main() {
|
2026-06-30 20:40:37 +00:00
|
|
|
// 1. Create LLM client
|
2026-06-28 23:03:57 +00:00
|
|
|
llmClient, _ := llm.NewAnthropicClient(llm.AnthropicConfig{
|
|
|
|
|
APIKey: os.Getenv("ANTHROPIC_API_KEY"),
|
|
|
|
|
Model: "claude-sonnet-4.5",
|
|
|
|
|
})
|
|
|
|
|
|
2026-06-30 20:40:37 +00:00
|
|
|
// 2. Load persona
|
2026-06-28 23:03:57 +00:00
|
|
|
p := persona.Load("./persona.yaml")
|
|
|
|
|
|
2026-06-30 20:40:37 +00:00
|
|
|
// 3. Create agent loop
|
2026-06-28 23:03:57 +00:00
|
|
|
loop := agent.New(agent.Config{
|
|
|
|
|
LLM: llmClient,
|
|
|
|
|
Persona: p,
|
|
|
|
|
MaxIters: 50,
|
|
|
|
|
Sandbox: agent.NewSandbox("./workspace"),
|
|
|
|
|
})
|
|
|
|
|
|
2026-06-30 20:40:37 +00:00
|
|
|
// 4. Run
|
|
|
|
|
resp, err := loop.Run(context.Background(), "Refactor auth.go")
|
2026-06-28 23:03:57 +00:00
|
|
|
if err != nil { panic(err) }
|
|
|
|
|
|
|
|
|
|
fmt.Println(resp.Content)
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2026-06-30 20:40:37 +00:00
|
|
|
## 🔌 Included adapters
|
2026-06-28 23:03:57 +00:00
|
|
|
|
|
|
|
|
### LLM Providers (`pkg/llm/providers/`)
|
|
|
|
|
|
2026-06-30 20:40:37 +00:00
|
|
|
| Provider | Import | Models |
|
2026-06-28 23:03:57 +00:00
|
|
|
|---|---|---|
|
2026-06-30 20:40:37 +00:00
|
|
|
| OpenAI | `providers/openai` | gpt-4o, gpt-4o-mini, gpt-4-turbo |
|
|
|
|
|
| Anthropic | `providers/anthropic` | claude-sonnet-4.5, claude-haiku-4 |
|
|
|
|
|
| Ollama | `providers/ollama` | llama3.1, qwen2.5, mistral, etc. |
|
|
|
|
|
| llama.cpp | `providers/llamacpp` | Custom GGUF models |
|
2026-06-28 23:03:57 +00:00
|
|
|
|
|
|
|
|
### Vector DBs (`pkg/rag/backends/`)
|
|
|
|
|
|
2026-06-30 20:40:37 +00:00
|
|
|
| Backend | Status |
|
2026-06-28 23:03:57 +00:00
|
|
|
|---|---|
|
2026-06-30 20:40:37 +00:00
|
|
|
| ChromaDB embedded | ✅ Stable |
|
|
|
|
|
| Qdrant embedded | 🚧 In development |
|
|
|
|
|
| SQLite + sqlite-vec | 📋 Planned |
|
2026-06-28 23:03:57 +00:00
|
|
|
|
|
|
|
|
### Embeddings (`pkg/rag/embeddings/`)
|
|
|
|
|
|
|
|
|
|
- Ollama embeddings (nomic-embed-text, bge-m3, etc.)
|
|
|
|
|
- Local sentence-transformers via ONNX
|
|
|
|
|
|
|
|
|
|
## 🧪 Testing
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
go test ./...
|
|
|
|
|
go test -race ./...
|
|
|
|
|
go test -bench=. ./pkg/agent/
|
|
|
|
|
```
|
|
|
|
|
|
2026-06-30 20:40:37 +00:00
|
|
|
Includes `MockLLMClient` for deterministic tests without burning API calls.
|
2026-06-28 23:03:57 +00:00
|
|
|
|
2026-06-30 20:40:37 +00:00
|
|
|
## 📐 Versions
|
2026-06-28 23:03:57 +00:00
|
|
|
|
2026-06-30 20:40:37 +00:00
|
|
|
- **Go minimum:** 1.26 (uses `os.Root`, `iter.Seq`, `unique.Handle`, container-aware GOMAXPROCS)
|
|
|
|
|
- **Versioning policy:** Strict semver. API breaking changes only on MAJOR.
|
2026-06-28 23:03:57 +00:00
|
|
|
|
2026-06-30 20:40:37 +00:00
|
|
|
## 📄 License
|
2026-06-28 23:03:57 +00:00
|
|
|
|
2026-06-30 20:40:37 +00:00
|
|
|
MIT — see [`LICENSE`](./LICENSE).
|
2026-06-28 23:03:57 +00:00
|
|
|
|
2026-06-30 20:40:37 +00:00
|
|
|
## 🔗 Projects that use this library
|
2026-06-28 23:03:57 +00:00
|
|
|
|
2026-06-30 20:40:37 +00:00
|
|
|
- [`VictorVargas/rony-harness`](https://github.com/VictorVargas/rony-harness) — TUI agent for software dev
|
2026-06-29 06:22:15 +00:00
|
|
|
- [`VictorVargas/rony-chat-bot`](https://github.com/VictorVargas/rony-chat-bot) — HTTP chatbot
|
2026-06-28 23:03:57 +00:00
|
|
|
|
2026-06-30 20:40:37 +00:00
|
|
|
## 📚 Additional documentation
|
2026-06-28 23:03:57 +00:00
|
|
|
|
|
|
|
|
- [Architecture overview](./docs/README.md)
|
2026-06-29 00:25:45 +00:00
|
|
|
- [Architecture (core)](./docs/architecture.md)
|
|
|
|
|
- [Components reference](./docs/components.md)
|
|
|
|
|
- [Phase 2 features](./docs/phase2.md)
|