Experimental Python-runner coding agent with a Textual TUI
Project description
uv-agent
Python-native coding agent — one run_python boundary. Every external action is
auditable, replayable, and interruptible.
uv-agent channels all model capabilities through a single, well-defined exit: the
model can only touch the outside world via run_python. Each call is a complete
Python script executed in a uv run-managed isolated environment, using
uv_agent_runtime helpers for file editing, command execution, code search, MCP,
sub-agents, images, and more. With only one exit, you can replay any run and see
exactly what happened and why.
The project is still experimental. Public APIs, config fields, and runtime behavior may change.
Features
- Single tool boundary — no shell, filesystem, browser, or MCP model tools. The model writes Python; the managed runtime executes it. Every external action is an auditable script.
- Cache-aware NetGain compaction — long conversations no longer trigger blind compression. A pre-turn lightweight judge round lets the model estimate remaining calls and history dependency, then computes the net gain of compaction via an economic formula. Compression fires only when cache savings outweigh information loss. Recent context is retained verbatim (K tokens) to avoid losing key details.
- Python managed runtime — scripts run in a project-shared
uvenvironment.uv_agent_runtimeprovides helpers for read/write/edit, ripgrep search, subprocesses, dependency installation, sub-agents, MCP clients, and more. Scripts serve as documentation — no opaque shell commands. - Plugin system — plain Python packages discovered via
uv_agent.pluginsentry point. Register runtime helpers, subscribe to events, submit turns from external systems.uvx --with your-plugin uv-agentand you're set. - Self-bootstrapping — uv-agent is developed using uv-agent. Reading, editing, testing, and iterating on the project are done with uv-agent itself.
- Progressive context disclosure — skills, MCP servers, and workspace rules are not dumped into the prompt all at once. The model receives an index first; full content is disclosed only when needed. Removed capabilities are explicitly marked to prevent stale-context errors.
- Goal mode durable memory —
/goalcreates a per-thread checklist/notes layer independent of the chat transcript. After compaction or resume, the model consults Goal files rather than relying solely on summarized history. - Agent View parallel workspaces — dispatch bug investigations, implementation experiments, and test fixes to isolated Git worktree background sessions. Track them all from a single dashboard.
- Prompt-cache-friendly design — the system prompt prefix is guaranteed byte-identical within an epoch. Compaction requests share the same prefix structure as normal calls, maximizing provider-side cache hits. Cache reads are nearly free.
Cache-Aware Compaction
The cache-aware compaction introduced in v0.16.0 is uv-agent's core optimization for long-running sessions. Unlike traditional "compress when context hits N%," uv-agent makes an economic decision before every turn:
- The model estimates how many more conversation rounds are needed
(
remaining_calls_bucket) and how strongly the task depends on history (history_dependency). - It enumerates K retention candidates and evaluates the NetGain for each: future cache savings minus compaction call cost, cache invalidation loss, information distortion penalty, plus context quality improvement gain.
- Compaction fires only when the best net gain exceeds a margin-scaled threshold; otherwise it skips, avoiding wasted compression for short tasks.
Compaction requests share the exact same prefix structure as normal calls (system prompt → tools → messages), ensuring provider-side prompt prefix caches stay warm. Over 90% of input tokens in a typical compaction call are billed at cached rates (typically 1%–10% of the normal input price).
This design draws on the DP compaction algorithm from bash-agent, with thanks.
Quick Start
Prerequisites:
- uv — https://docs.astral.sh/uv/getting-started/installation/
- ripgrep — https://github.com/BurntSushi/ripgrep#installation
- Git — needed for normal coding workflows and Worktree mode.
# Run the latest published release
uvx uv-agent@latest
# Run from a local checkout
uv run uv-agent
# Single-turn question (no TUI)
uvx uv-agent@latest ask "Summarize the project structure"
# Resume an existing thread
uvx uv-agent@latest ask --thread thr_xxx "Continue where we left off"
Model Configuration
uv-agent ships with no real provider configuration. Configure at least one provider,
model, and level in ~/.uv-agent/config.json (or project-level
.uv-agent/config.json). Keep API keys in environment variables or git-ignored
local config.
Supported API formats:
api value |
Format |
|---|---|
"responses" |
OpenAI Responses API |
"chat_completions" |
OpenAI Chat Completions API |
"anthropic_messages" |
Anthropic Messages API |
Full configuration example
{
"providers": {
"deepseek": {
"base_url": "https://api.deepseek.com",
"api_key": "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"timeout_s": 7200,
"chat_completions": {
"path": "/chat/completions"
},
"message_passthrough": {
"assistant": [
"reasoning_content"
]
},
"reasoning_display": {
"assistant_message_fields": [
"reasoning_content"
],
"stream_delta_fields": [
"reasoning_content"
]
}
},
"minimax": {
"base_url": "https://api.minimaxi.com",
"api_key": "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"timeout_s": 7200,
"chat_completions": {
"path": "/v1/chat/completions"
},
"anthropic_messages": {
"path": "/anthropic/v1/messages"
}
}
},
"models": {
"deepseek-v4-flash": {
"provider": "deepseek",
"model": "deepseek-v4-flash",
"api": "chat_completions",
"supports_images": false,
"context_window_tokens": 1000000,
"params": {
"reasoning_effort": "high"
}
},
"deepseek-v4-pro": {
"provider": "deepseek",
"model": "deepseek-v4-pro",
"api": "chat_completions",
"supports_images": false,
"context_window_tokens": 1000000,
"params": {
"reasoning_effort": "max"
}
},
"MiniMax-M2.7": {
"provider": "minimax",
"model": "MiniMax-M2.7-highspeed",
"api": "anthropic_messages",
"supports_images": false,
"context_window_tokens": 204800
}
},
"levels": {
"deepseek-flash": {
"model": "deepseek-v4-flash"
},
"deepseek-pro": {
"model": "deepseek-v4-pro"
},
"MiniMax-M2.7": {
"model": "MiniMax-M2.7"
}
},
"runtime": {
"default_level": "deepseek-flash",
"ask_default_level": "deepseek-flash",
"store_provider_response": false,
"max_agent_rounds": 1000,
"compression": {
"enabled": true,
"model_level": "deepseek-flash",
"trigger_ratio": 0.9
},
"title_generation": {
"enabled": true,
"model_level": "deepseek-flash"
},
"branch_name_generation": {
"enabled": true,
"model_level": "deepseek-flash",
"timeout_s": 15.0
}
},
"runner": {
"default_timeout_s": 7200,
"max_output_bytes": 1000000,
"scriptenv_index_url": null
},
"pricing": {
"currency": "RMB",
"unit": "1M_tokens",
"models": {
"deepseek-v4-flash": {
"input": 1,
"output": 2,
"cached_input": 0.02
},
"deepseek-v4-pro": {
"input": 3,
"output": 6,
"cached_input": 0.025
}
}
},
"ui": {
"completion_notification": {
"enabled": true
}
},
"plugins": {
"disabled": [],
"config": {}
}
}
Use /config in the TUI to switch default level, language, and compression
settings. See configuration for every option and
config.example.json for a standalone example.
Everyday Workflow
- Type and press
Enterto send. UseCtrl+Enter/Ctrl+Jfor newlines. - Type
/from an empty composer to open the command palette; type to filter.@for file mentions,@@for thread mentions. /level <name>to switch models;/statusto inspect runtime state including cache compaction judge details./goal enable [objective]for durable task checklists across long sessions.- Agent View dispatches background tasks to isolated Git worktrees.
- Use
uv-agent tuifor the legacy Textual panels (/config,/models, etc.).
See TUI and slash commands for the full list.
TUI Interfaces
- tui2 (default,
uv-agentoruv-agent tui2) — lightweight ANSI TUI rendered directly in the terminal. Compact status rows, streaming events, Goal/Worktree mode, and image attachments. - Textual TUI (
uv-agent tui) — deprecated, kept for compatibility. The older Textual widget-based interface. Screenshot: docs/t1.png.
Agent View
Agent View is a dashboard for managing multiple background agent sessions. Tasks run in isolated Git worktrees on auto-generated branches, keeping edits away from your current checkout. Track status, skim output, continue or discard tasks — all from one panel.
Plugins
Plugins are Python packages discovered via the uv_agent.plugins entry point. They
run in the uv-agent host process and can register runtime helpers, subscribe to
events, and submit turns from external systems.
uvx --with your-uv-agent-plugin uv-agent@latest
See Plugin system for details.
Runtime & Context
Every model turn = stable system prompt + on-demand structured context.
run_pythonis the only external action surface. Scripts execute in a project-shared uv environment and importuv_agent_runtimehelpers. The uv environment and working directory are separate; the cwd can change viaenter_diror Worktree mode.- Runtime context (helper lists, skills, MCP servers, etc.) uses fingerprinted incremental updates — only changed parts are injected, and removed capabilities are explicitly marked.
- Workspace rules are disclosed progressively: index first, full AGENTS.md only when entering the relevant directory.
- Goal mode provides a durable checklist/notes layer independent of the chat transcript, preserving task progress across compaction and resume.
- Checkpoint compaction summarizes the conversation while excluding reloadable runtime context. New epochs replay structured context before retained history.
Documentation
Development
uv-agent is self-bootstrapping — it is developed using uv-agent itself for reading, editing, testing, and iterating.
uv run pytest
Local debug state, screenshots, config, and run data belong in .uv-agent/ and
should stay out of git.
Acknowledgments
The cache-aware compaction design draws on the DP compaction algorithm and cache alignment approach from bash-agent, with thanks.
License
MIT. See LICENSE.
Project details
Release history Release notifications | RSS feed
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 uv_agent-0.17.5.tar.gz.
File metadata
- Download URL: uv_agent-0.17.5.tar.gz
- Upload date:
- Size: 1.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
119d6cc89388489244c8303f42d9bf6912cf0e012277546afe4d4d0dd477043d
|
|
| MD5 |
c6cd2e6337ac433178a70087cea535ce
|
|
| BLAKE2b-256 |
b5ebc4b26d675c082af4dec168278b4f466380dbec9c1ade892b74159b9521fa
|
Provenance
The following attestation bundles were made for uv_agent-0.17.5.tar.gz:
Publisher:
release.yml on 4fuu/uv-agent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
uv_agent-0.17.5.tar.gz -
Subject digest:
119d6cc89388489244c8303f42d9bf6912cf0e012277546afe4d4d0dd477043d - Sigstore transparency entry: 1824278272
- Sigstore integration time:
-
Permalink:
4fuu/uv-agent@2861bbb7bb7dcd435f75ef87e9a9f0dfbbf6f77a -
Branch / Tag:
refs/heads/master - Owner: https://github.com/4fuu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2861bbb7bb7dcd435f75ef87e9a9f0dfbbf6f77a -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file uv_agent-0.17.5-py3-none-any.whl.
File metadata
- Download URL: uv_agent-0.17.5-py3-none-any.whl
- Upload date:
- Size: 403.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b22bf51246234128dc2576f9a731a283b33b3f76aae71c4eea4715799921612a
|
|
| MD5 |
d5acff47e6333e15f2028854e55cef19
|
|
| BLAKE2b-256 |
98b0a060fdea471fd1d3e8c9a8a5607abcba3bc0b2926ff4cf7e36d784bccd31
|
Provenance
The following attestation bundles were made for uv_agent-0.17.5-py3-none-any.whl:
Publisher:
release.yml on 4fuu/uv-agent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
uv_agent-0.17.5-py3-none-any.whl -
Subject digest:
b22bf51246234128dc2576f9a731a283b33b3f76aae71c4eea4715799921612a - Sigstore transparency entry: 1824278406
- Sigstore integration time:
-
Permalink:
4fuu/uv-agent@2861bbb7bb7dcd435f75ef87e9a9f0dfbbf6f77a -
Branch / Tag:
refs/heads/master - Owner: https://github.com/4fuu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@2861bbb7bb7dcd435f75ef87e9a9f0dfbbf6f77a -
Trigger Event:
workflow_dispatch
-
Statement type: