Open source · by Trysti Labs

The self-optimizing AI runtime
for durable autonomous agents.

A transparent layer between your AI coding tools and your models: smart routing, token savings, durable execution, and continuous learning. All local, fully open source.

Your tool SelfOpt Local + cloud models

How it works

A six-step pipeline: adaptive routing, retries, and per-task learning.

01

Classify

Keyword scan identifies task type without an extra model call.

02

Route

Rank models by skill, learned task weights, availability, and cooldowns.

03

Optimize

Strip stale context, dedupe file contents, keep the most relevant history.

04

Execute

A self-healing loop with format enforcement and automatic escalation.

05

Persist

Save project state and history to the OS-native data folder.

06

Learn

Record outcomes so routing improves over time for each task type and model.

SelfOpt in action
Tool

Key capabilities

One layer for multi-model agentic work, with Ollama-native and OpenAI-compatible tools.

Adaptive routing

Ranks models by task type, skill, and difficulty. Easy requests go to free local models; hard ones to the strongest available.

Self-healing execution

A 3-attempt retry loop with model escalation and a quality gate, for fewer broken responses.

Circuit breaker

Detects provider failures and defers cooldown, quota, and rate-limit errors automatically.

Per-task learning

Tracks outcomes per model and task type, so routing keeps improving every session.

Prompt optimization

Strips stale metadata, dedupes files, and trims history, with token savings shown inline.

Prompt caching

The stable Anthropic prefix is served from cache at ~0.1× input price on repeat steps. Automatic.

Guaranteed JSON

Local models constrain decoding to a schema at generation time. Valid JSON by construction.

Secret redaction

API keys and tokens are scrubbed before prompts reach a cloud provider. Local models stay untouched.

Local-first

All state stays in your OS-native data folder. Runs fully offline on local models.

Reliable by design

Durability and privacy built into the execution layer, not bolted on.

Durable, resumable plans

Step results are checkpointed as they complete, then replayed from the journal on resume, continuing where it stopped.

No orphaned GPUs

Remote provisioning auto-destroys an instance on any failure or Ctrl-C, with a --reconcile backstop. A crash never leaves a billing instance behind.

Offline regression checks

A local eval harness scores prompt and routing changes against a baseline, so regressions are caught before they ship.

Integrations

Drop-in for both Ollama-native and OpenAI-compatible clients.

Ollama-native Protocol

POST /api/chat for Cline, Continue, crewAI, and LangChain.

OpenAI-compatible Protocol

POST /v1/chat/completions for Aider, AutoGen, and smolagents.

Quick start

Running locally in under two minutes.

Clone & install
git clone https://github.com/selfopt/selfopt.git
cd selfopt
pip install -e ".[dev]"
Pull models (Ollama)
ollama pull qwen3-coder:30b   # primary code model
ollama pull gemma4            # fast analysis model
Start the server
selfopt start --port 8001
Connect your tool or agent framework
# Ollama-native endpoint (Cline, Continue, crewAI, LangChain)
http://localhost:8001   model: selfopt

# OpenAI-compatible endpoint (Aider, AutoGen, smolagents)
http://localhost:8001/v1   model: openai/selfopt

Supported backends

Local and remote providers, with optional cloud failover.

Local
Ollamalocal
Claude Code CLIlocal CLI
Cloud
Anthropic Claudecloud
Google Geminicloud
OpenAI Codexcloud