Catalog PyPI
PACKAGE EXPLORERView in registry

agentura

PyPI

Production-grade multi-agent harness with LLM routing, memory, safety, and observability

agentanthropicautogencrewailangchainlanggraphllmmulti-agentopenai
Versions collected1
Direct dependencies38From release 0.1.0
Last observed20 Oct, 23:36 UTC

README

Version 0.1.0 documentation

🧠 HarnessAgent

Run SQL agents, code assistants, or research bots on any LLM. Bring your own framework. Memory, safety, and failure recovery come included.

Python FastAPI Tests License Models


What is this?

Think about what actually happens when you run an AI agent in production. The LLM call needs to work. It needs to not cost $500 a day. It needs to not loop forever when the API is slow. It needs to remember context from three messages ago. It needs to not crash your app when one provider goes down.

HarnessAgent handles all of that. You write the task. It handles the rest.

What you seeWhat happens under the hood
AI answers your questionPicks the healthiest LLM, checks the budget, falls back if the provider fails
AI runs a SQL queryValidates the input schema, checks safety rules, executes, logs the result
AI remembers past contextShort-term in Redis, long-term in a vector DB
AI finds relevant info fastGraph RAG: entity extraction plus BFS traversal, 83% fewer tokens than naive vector search
AI gets better after failuresHermes loop: samples errors, proposes a prompt fix, evaluates it, applies if the score clears 70%
One provider goes downCircuit breaker opens after 5 failures, auto-recovers after 60 seconds

Architecture

graph TB
    subgraph CLIENT["🌐 Client Layer"]
        UI[Web / CLI / SDK]
        API[REST API POST /runs]
    end

    subgraph HARNESS["⚙️ HarnessAgent Core"]
        RUNNER[AgentRunner lifecycle manager]

        subgraph AGENTS["🤖 Agent Layer"]
            BASE[BaseAgent run loop]
            SQL[SQLAgent]
            CODE[CodeAgent]
            LG[LangGraph Adapter]
            AG[AutoGen Adapter]
            CR[CrewAI Adapter]
        end

        subgraph MEMORY["🧠 Memory System"]
            STM[Short-Term Redis]
            LTM[Long-Term Qdrant / Chroma / Weaviate]
            GRAPH[Knowledge Graph NetworkX / Neo4j]
            RAG[Graph RAG Engine]
        end

        subgraph LLM["🔮 LLM Router"]
            ROUTER[Health-aware Circuit-broken Router]
            ANT[Claude]
            OAI[GPT-4o / GPT-5]
            LOCAL[vLLM / SGLang / llama.cpp]
        end

        subgraph TOOLS["🔧 Tool System"]
            REG[Tool Registry]
            MCP[MCP Servers]
            SQL2[SQL Tools]
            CODE2[Code Sandbox]
            FILE[File Tools]
        end

        subgraph SAFETY["🛡️ Safety"]
            GUARD[Guardrail Pipeline]
            HITL[Human-in-the-Loop]
            RATE[Rate Limiter]
            CB[Circuit Breaker]
        end
    end

    subgraph OBS["📊 Observability"]
        MLFLOW[MLflow Traces]
        OTEL[OpenTelemetry]
        PROM[Prometheus]
        GRAFANA[Grafana Dashboard]
    end

    subgraph IMPROVE["🔄 Self-Improvement"]
        HERMES[Hermes Loop]
        ERR[Error Collector]
        PATCH[Patch Generator]
        EVAL[Evaluator]
    end

    UI --> API --> RUNNER --> BASE
    BASE --> LLM & MEMORY & TOOLS & SAFETY
    BASE --> OBS
    BASE -.->|failures| IMPROVE
    IMPROVE -.->|better prompts| AGENTS
    ROUTER --> ANT & OAI & LOCAL
    STM & LTM & GRAPH --> RAG
    REG --> MCP & SQL2 & CODE2 & FILE

Features

FeatureDescription
🔀 LLM RoutingClaude, GPT-5, o4-mini, vLLM, SGLang, llama.cpp with automatic health-aware fallback
🧠 3-Tier MemoryRedis (hot) then vector DB (warm) then knowledge graph (structured)
📉 Graph RAG83% token reduction via multi-hop graph traversal vs naive vector search
🔌 Framework AdaptersLangGraph, AutoGen, CrewAI plug in without rewriting your agents
🛡️ Safety PipelinePII redaction, injection detection, tool policy, loop detection, budget enforcement
🔁 Hermes LoopAnalyzes failures, proposes prompt patches, evaluates them, applies if the score is good
👤 Human-in-the-LoopAgent pauses on risky actions, waits for approval, then continues or stops
⚡ Circuit BreakerOpens after 5 failures, self-heals after 60 seconds
💰 Cost TrackingPer-run, per-tenant USD cost with hard monthly caps
🔒 Code SandboxDocker-isolated execution for code agents, 256MB limit, no network
📊 ObservabilityMLflow agent traces, OTel infra spans, Prometheus metrics, Grafana dashboards
🧩 MCPConnect any MCP server over stdio or SSE

LLM Support

ProviderModelsTool CallingPrompt CachingCost per 1M input tokens
🟣 AnthropicSonnet 4.6, Haiku 4.5, Opus 4.7NativeYes$0.25 to $15
🟢 OpenAIGPT-4o, GPT-4o-mini, GPT-5, GPT-5-mini, o1, o3, o4-miniNativeAuto$0.15 to $75
🔵 vLLMAny HuggingFace modelNativeNoFree (self-hosted)
🟡 SGLangAny HuggingFace modelNativeNoFree (self-hosted)
🔴 llama.cppAny GGUF quantized modelReAct text injectionNoFree (CPU / Metal)
🟠 OllamaAny Ollama modelNativeNoFree (local)

No GPU? llama.cpp runs on any Mac or CPU machine. Tool calling works through ReAct text injection when native function calling is not available.


Quick Start

# 1. Clone and install
git clone https://github.com/thepradip/HarnessAgent.git
cd HarnessAgent
poetry install

# 2. Configure (set at least one API key, or a local model URL)
cp .env.example .env

# 3. Start infrastructure (Redis, Qdrant, Neo4j, MLflow, Prometheus, Grafana)
docker compose up -d

# 4. Start the API and worker
make api      # terminal 1, FastAPI on port 8000
make worker   # terminal 2, async agent worker

# 5. Run your first agent
curl -X POST http://localhost:8000/runs \
  -H "Content-Type: application/json" \
  -d '{"agent_type": "sql", "task": "How many users signed up this week?"}'

# Watch steps in real time
curl http://localhost:8000/runs/{run_id}/steps

No API key? Use llama.cpp locally:

# Put a GGUF model in ./models/ then:
docker compose --profile local-cpu up -d llamacpp
# Add to .env: LLAMACPP_BASE_URL=http://localhost:8080

Use Cases

SQL Data Agent — Ask business questions in plain English. The agent reads your schema into a knowledge graph, writes safe SELECT queries, and returns formatted results with PII redacted.

Code Assistant — Give it a ticket or a spec. It reads your workspace, writes the code, lints it, runs it in a Docker sandbox, and fixes errors until it passes.

Research Agent — Feed it documents or URLs. It ingests them into the vector store and knowledge graph, then answers multi-hop questions with citations.

Multi-Agent Pipeline — Chain specialists through the planner: a researcher feeds a coder, which feeds a reviewer. All agents share the same memory pool.

Existing Framework — Already using LangGraph, AutoGen, or CrewAI? Drop your graph or crew into the adapter. You get traces, cost tracking, circuit breaking, and safety without changing a line of your agent logic.


Project Structure

HarnessAgent/
├── src/harness/
│   ├── agents/          # BaseAgent loop, SQLAgent, CodeAgent
│   ├── adapters/        # LangGraph, AutoGen, CrewAI wrappers
│   ├── api/             # FastAPI routes, JWT auth, SSE streaming
│   ├── core/            # Config, circuit breaker, cost tracker, rate limiter
│   ├── eval/            # Datasets, runners, scorers for Hermes evaluation
│   ├── filesystem/      # Isolated workspaces, Docker sandbox, checkpoints
│   ├── improvement/     # Hermes loop, error collector, patch generator
│   ├── ingestion/       # PDF/HTML/MD loaders, chunker, knowledge graph extraction
│   ├── llm/             # Anthropic, OpenAI, local providers, router, factory
│   ├── memory/          # Redis, vector backends, graph, Graph RAG engine
│   ├── messaging/       # Redis Streams inter-agent bus
│   ├── observability/   # MLflow tracer, OTel spans, Prometheus metrics, audit log
│   ├── orchestrator/    # AgentRunner, HITL manager, planner, scheduler
│   ├── prompts/         # Versioned prompt store, patch application
│   ├── safety/          # Guardrail pipeline factory and per-tenant policies
│   ├── tools/           # Tool registry, MCP client, SQL / code / file tools
│   └── workers/         # RQ agent worker, Hermes background scheduler
├── configs/             # Model capabilities, MCP server definitions
├── docs/                # Architecture diagrams and full reference docs
├── infra/               # Prometheus scrape config, OTel collector, Grafana
├── tests/               # 96 unit tests, 2 integration test suites
├── docker-compose.yml   # Full infrastructure: Redis, Qdrant, Neo4j, MLflow, Grafana
├── Dockerfile           # Multi-stage: api, worker, hermes targets
├── Makefile             # install, test, lint, api, worker, hermes, docker-up/down
└── pyproject.toml       # Poetry dependencies and tooling

Tech Stack

LayerTechnologyNotes
APIFastAPI + uvicornAsync by default, SSE for step streaming
LLManthropic + openai SDKsBoth support streaming and native tool calling
Short-term memoryRedisConversation history, pub/sub, task queue
Long-term memoryQdrant / ChromaDB / WeaviateChroma for dev (zero infra), Qdrant for prod
Knowledge graphNetworkX / Neo4jNetworkX in-process for dev, Neo4j for production
Agent tracingMLflowLLM-native spans, experiment tracking, eval metrics
Infra tracingOpenTelemetryVendor-neutral, exports to Jaeger or Tempo
MetricsPrometheus + Grafana15 pre-defined metrics, pre-built dashboard
SafetyGuardrail3-stage pipeline: input, intermediate, output
WorkersRQ + RedisSame Redis connection, no extra broker needed
DeploymentDocker ComposeScale workers independently with replicas

Dashboards

Once docker compose up -d is running:

DashboardURLCredentials
MLflow Traceshttp://localhost:5000none
Grafanahttp://localhost:3000admin / harness_admin
Prometheushttp://localhost:9090none
Qdrant UIhttp://localhost:6333/dashboardnone
Neo4j Browserhttp://localhost:7474neo4j / harnesspassword

Configuration

Everything goes in .env. Copy .env.example and set what you need.

# Cloud LLMs
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...
OPENAI_MODELS=gpt-4o-mini          # comma-separated, e.g. gpt-4o-mini,gpt-4o

# Local LLMs (no API key needed)
VLLM_BASE_URL=http://localhost:8000
LLAMACPP_BASE_URL=http://localhost:8080

# Memory backends (chroma is default, zero setup)
VECTOR_BACKEND=chroma              # chroma | qdrant | weaviate
GRAPH_BACKEND=networkx             # networkx | neo4j

# Hermes self-improvement
HERMES_AUTO_APPLY=false            # keep this off until you trust it
HERMES_PATCH_SCORE_THRESHOLD=0.7

# Cost and safety
COST_BUDGET_USD_PER_TENANT=100.0
RATE_LIMIT_RPM=60

Full reference: docs/guides/CONFIGURATION.md


Testing

# Run unit tests
PYTHONPATH=src python3 -m pytest tests/unit/

# Run integration tests (needs SQLite, no Docker required)
PYTHONPATH=src python3 -m pytest tests/integration/

# With coverage
PYTHONPATH=src python3 -m pytest tests/ --cov=src/harness --cov-report=term-missing

Current: 96 unit tests passing, 0 failures.


Documentation


Future Scope

Planned improvements focused on making HarnessAgent more efficient at scale.

AreaFeatureExpected Impact
Token EfficiencyAdaptive context compression — summarize stale history with a small model before appending to new prompts40–60% token reduction on long sessions
Cost OptimizationSemantic response caching — skip LLM calls when a sufficiently similar query was answered recentlyUp to 30% cost savings on repetitive workloads
Cost OptimizationBatch inference mode — route low-urgency tasks through Anthropic/OpenAI Batch APIs at 50% list price50% cost reduction for async pipelines
RoutingML-based predictive model selection — learn per-task-type patterns to auto-select the cheapest sufficient modelEliminates over-provisioned Opus/GPT-5 usage
MemoryDifferential re-indexing — re-embed only modified chunks on ingestion, not the full corpusFaster incremental ingestion at scale
ParallelismStreaming pipeline overlap — start tool execution while the LLM is still generating, cut latency per stepLower end-to-end agent step latency
Multi-AgentShared tool execution pool — deduplicate identical tool calls across concurrent agents in the same runFewer redundant DB and API round-trips
HermesCost-aware patch targeting — rank prompt candidates by token spend, optimize the most expensive patterns firstBetter ROI from self-improvement cycles
SchedulingFair-share multi-tenant scheduler — priority queues and resource caps to prevent noisy-neighbor budget spikesPredictable per-tenant cost and latency
ExtensibilityPlugin SDK — first-class API for registering custom LLM providers, memory backends, and tool namespacesFaster integration of new models and datastores
ObservabilityAutomated cost anomaly alerts — Prometheus rule + Grafana annotation when a run exceeds per-step cost thresholdCatch runaway agents before they exhaust budgets
SafetyStreaming guardrail evaluation — evaluate guardrail rules token-by-token instead of waiting for full outputInterrupt unsafe responses earlier, reduce wasted tokens

Contributing

Fork, branch off main, write tests for anything new, open a PR.

git checkout -b feat/your-feature
PYTHONPATH=src python3 -m pytest tests/unit/
ruff check src/ tests/

Things that would be useful: new LLM provider adapters, additional vector backends, more tool integrations, Kubernetes Helm chart, and examples for specific use cases.


License

MIT. See LICENSE.


Architecture  |  Quick Start  |  Components  |  Issues

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 1

Collected releases
VersionPublishedDirect dependenciesOpen version
0.1.06 May 202638

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
thepradip/harnessagent

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 23:36 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:22373964d3e31803e704cb9657dab19a8a57d71e5a48d77f9b28b5fcbc726c1e