Skip to main content

uv-agent

uv-agent tui screenshot

简体中文

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, images, and plugin-provided capabilities such as MCP clients and workflow graphs. 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 uv environment. uv_agent_runtime provides helpers for read/write/edit, FFF-backed search, subprocesses, dependency installation, images, and plugin-provided namespaces. Scripts serve as documentation — no opaque shell commands.
  • Plugin system — trusted Python packages discovered via uv_agent.plugins can add runtime namespaces (rt.mcp, rt.workflow, custom helpers), actions, slash commands, UI providers, model context, event subscriptions, durable storage, and programmatic turn submission while preserving the single run_python model boundary. Plugins can declare whether they run in any host, only in a persistent daemon host, or only in a short interactive session host.
  • Headless service modeuv-agent daemon starts the host and plugins without opening the TUI, so schedulers, chat bridges, webhooks, and other long-running integrations can keep working for a project state.
  • 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/goal creates a per-thread checklist/notes layer independent of the chat transcript. After compaction or resume, the model consults goal plugin state rather than relying solely on summarized history.
  • 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:

  1. The model estimates how many more conversation rounds are needed (remaining_calls_bucket) and how strongly the task depends on history (history_dependency).
  2. 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.
  3. 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:

# 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"

# Run the headless service host for plugins and schedulers
uvx uv-agent@latest daemon --replace

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",
    "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,
    "max_run_logs": 200,
    "scriptenv_index_url": null
  },
  "logging": {
    "level": "INFO",
    "file_enabled": true,
    "console_enabled": false,
    "max_bytes": 5000000,
    "backup_count": 3
  },
  "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": {
    "my-plugin": {
      "enabled": false
    },
    "another-plugin": {
      "enabled": true,
      "config": {
        "option": "value"
      }
    }
  }
}

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.

Logging

uv-agent writes operational logs to the project state log directory, usually ~/.uv-agent/projects/<project-id>/log/uv-agent.log. Per-plugin logs live under ~/.uv-agent/plugins/<plugin-id>/logs/plugin.log. Both use the top-level logging.max_bytes and logging.backup_count rotation settings; defaults keep about 5 MB per active log and 3 backups. --log-level overrides logging.level for the current process.

Everyday Workflow

  • Type and press Enter to send. Use Ctrl+Enter / Ctrl+J for 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; /status to inspect runtime state including cache compaction judge details.
  • /goal enable [objective] for durable task checklists across long sessions. See TUI and slash commands for the full list.

TUI Interfaces

  • tui (default, uv-agent or uv-agent tui) — lightweight ANSI TUI rendered directly in the terminal. Compact status rows, streaming events, Goal/Worktree mode, and image attachments.

Service Mode

uv-agent daemon runs the same host/plugin stack without launching the terminal UI. Use it when plugin capabilities need a long-lived process: scheduled actions, external chat or webhook bridges, programmatic turn submission, or background event relays.

The daemon acquires a project-state lease and heartbeat so one active host owns integrations for that workspace. Use --replace to stop a stale or older daemon for the same state.

The normal TUI still creates a local session host for interactive work. Plugins whose manifests declare activation="persistent_only" are skipped in that session host and show as skipped in /status; they start in daemon mode instead. Plugins that can safely degrade, such as by using an ephemeral port, can keep the default activation="always" and inspect context.host.is_persistent inside setup(context).

By default, daemon mode uses ~/.uv-agent/workspace as its persistent workspace and creates a structured English or Chinese AGENTS.md there when one does not already exist. Use --workspace <path> to choose a different daemon workspace.

uv-agent daemon --replace

Plugins

Plugins are trusted Python packages discovered via the uv_agent.plugins entry point and loaded into the uv-agent host process. They extend the host without changing the model boundary: the model still acts through run_python, while plugin capabilities appear as script helpers, commands, actions, UI additions, and structured model context.

Plugins can:

  • expose runtime helper namespaces such as rt.mcp, rt.workflow, or project-specific rt.<name> helpers;
  • register actions for schedulers and other automation;
  • add slash commands, picker/UI providers, and localized text;
  • subscribe to host events, keep private storage, and submit turns from external systems;
  • declare host activation policy and inspect read-only host lifecycle metadata through context.host.

Built-in Goal, Worktree, Skills, MCP, Workflow, and Scheduler capabilities use this same plugin surface. Install only plugins you trust.

uvx --with your-uv-agent-plugin uv-agent@latest

For plugin-heavy launches, uv-agentx is a small companion launcher that keeps the runtime ephemeral while shortening the command line:

uvx uv-agentx@latest --latest -p auth-code -p remote-control -- daemon --replace

-p auth-code first tries the official PyPI package uv-agent-auth-code, then falls back to auth-code if the prefixed package does not exist. Use --raw-plugin to pass a package requirement without this name expansion. See uv-agentx for the full launcher syntax.

See Plugin system for details.

Runtime & Context

Every model turn = stable system prompt + on-demand structured context.

  • run_python is the only external action surface. Scripts execute in a project-shared uv environment and import uv_agent_runtime helpers. The uv environment and working directory are separate; the cwd can change via enter_dir or Worktree mode.
  • Runtime context (helper lists, skills, MCP servers, etc.) is plugin-owned epoch context. Plugins publish full epoch context after refresh/compaction and may enqueue explicit XML updates when their own state changes.
  • 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
uv run --project packages/uv-agentx pytest packages/uv-agentx/tests

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.

Download files

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

Source Distribution

uv_agent-0.21.3.tar.gz (1.7 MB view details)

Uploaded Source

Built Distribution

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

uv_agent-0.21.3-py3-none-any.whl (439.4 kB view details)

Uploaded Python 3

File details

Details for the file uv_agent-0.21.3.tar.gz.

File metadata

  • Download URL: uv_agent-0.21.3.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

Hashes for uv_agent-0.21.3.tar.gz
Algorithm Hash digest
SHA256 d2cb6006dd23d007b940d1360141648cbaa9d6170d3bd4c40b61a64a4839aadd
MD5 83f73407f4223f248f40354a21657327
BLAKE2b-256 f9ee6e051ec613444c45f5c30ba54651899aba74e81fa545efcd3c511454833d

See more details on using hashes here.

Provenance

The following attestation bundles were made for uv_agent-0.21.3.tar.gz:

Publisher: release.yml on uv-agent/uv-agent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file uv_agent-0.21.3-py3-none-any.whl.

File metadata

  • Download URL: uv_agent-0.21.3-py3-none-any.whl
  • Upload date:
  • Size: 439.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for uv_agent-0.21.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d32fbc15e9af4998b40e45441e8efbe053c06a1b397b17f7850793bfb3c9f8f6
MD5 b7c422bca678c5326d86998e97730d5e
BLAKE2b-256 7420d83f852f22b08e1e3996045cad5601c026e66eeeb244276e8b8a37dd39b2

See more details on using hashes here.

Provenance

The following attestation bundles were made for uv_agent-0.21.3-py3-none-any.whl:

Publisher: release.yml on uv-agent/uv-agent

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

Supported by

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