CP

cuga-project/cuga-agent

开发工具
861 stars 质量 74 趋势 74

Building a domain-specific enterprise agent from scratch is complex and requires significant effort: agent and tool orchestration, planning logic, safety and alignment policies, evaluation for...

概览

Building a domain-specific enterprise agent from scratch is complex and requires significant effort: agent and tool orchestration, planning logic, safety and alignment policies, evaluation for...

README


Why CUGA? — A generalist agent harness for the enterprise: wire your APIs and MCP servers, tune reasoning and task modes, and govern behavior with policies—without rebuilding orchestration from scratch.

Feature How
MCP, OpenAPI & LangChain tools mcp_servers.yaml · CugaAgent(tools=[...])
Reasoning modes (fast / balanced / accurate) [features] cuga_mode in settings.toml · configurations/modes/
Hybrid API + browser tasks [advanced_features] mode = 'hybrid' · Playwright + browser extension
Multi-agent (CugaSupervisor) cuga start demo_supervisor · [supervisor] in settings.toml
A2A & remote agents External agent entries in supervisor config · CugaSupervisor
Policies & HITL Policies SDK — Intent Guard, Playbook, Tool Approval, Tool Guide, Output Formatter
Manage & publish cuga start manager · draft tools, MCP, LLM, and policies in the web UI, then publish a versioned config for production chat (details)
Reflection [advanced_features] reflection_enabled in settings.toml
Langflow Low-code visual workflows — integrates with CUGA (langflow.org)
Knowledge (RAG) enable_knowledge=True (default) · ingest PDFs/Office/HTML/Markdown via Docling · agent-level + session-level scopes · cuga start demo_knowledge · details
Agent skills SKILL.md under .cuga/skills (default) · cuga start demo_skills (sandbox_mode = "native" by default, or opensandbox) · or demo --sandbox with [skills] on · Agent skills
Self-host on a cluster Helm chart and deploy scripts in deployment/ · Kubernetes guide (local kind/minikube, or registry push for cloud clusters)
Save & reuse (experimental) cuga_mode = "save_reuse_fast" in settings.toml

SDK · Policies · Quick Start →

Why CUGA?

Benchmark Performance

CUGA achieves state-of-the-art performance on leading benchmarks:

  • #1 on AppWorld (#1 from 07/25 - 02/26) — a benchmark with 750 real-world tasks across 457 APIs
  • #1 on WebArena (#1 from 02/25 - 09/25) — a complex benchmark for autonomous web agents across application domains

Key Features & Capabilities

  • High-performing generalist agent — Benchmarked on complex web and API tasks. Combines best-of-breed agentic patterns (e.g. planner-executor, code-act) with structured planning and smart variable management to prevent hallucination and handle complexity

  • Flexible agent and tool integration — Seamlessly integrate tools via OpenAPI specs, MCP servers, and Langchain, enabling rapid connection to REST APIs, custom protocols, and Python functions

  • Integrates with Langflow — Low-code visual build experience for designing and deploying agent workflows without extensive coding

  • Open-source and composable — Built with modularity in mind, CUGA itself can be exposed as a tool to other agents, enabling nested reasoning and multi-agent collaboration. Evolving toward enterprise-grade reliability

  • Policy System — Configure agent behavior with 5 policy types (Intent Guard, Playbook, Tool Approval, Tool Guide, Output Formatter) via the Python SDK or standalone UI in demo mode. Includes human-in-the-loop approval gates for safe agent behavior in enterprise contexts. See SDK Docs and Policies Guide

  • Save-and-reuse capabilities (Experimental) — Capture and reuse successful execution paths (plans, code, and trajectories) for faster and consistent behavior across repeated tasks

  • Agent skills — Package domain workflows as SKILL.md files with frontmatter; the agent discovers them and loads full instructions on demand via the load_skill tool (see Agent skills)

  • Knowledge engine — Built-in RAG over your documents: ingest PDFs, Office files, HTML, Markdown, and images through Docling, then search and reason over them via auto-injected knowledge tools. Documents can be scoped to agent-level (permanent, shared across conversations) or session-level (per-thread, isolated to a single conversation) — so long-lived reference material and ephemeral per-user uploads can coexist (see Knowledge Base)

Manage, publish, and self-hosting

Manage and publish — Run cuga start manager to start the manage-mode stack. You edit agent configuration (tools, MCP servers, LLM selection, policies) as a draft, try it in the draft chat, then publish to create a new version that production chat uses. Published versions are tracked so you can roll forward and audit what shipped.

Self-host on Kubernetes — The repo includes a Helm chart under deployment/helm/, helper scripts such as deployment/deploy-local.sh, and documentation for building images, pushing to a registry, and wiring API keys via Kubernetes secrets for clusters such as kind, minikube, Docker Desktop Kubernetes, GKE, EKS, or AKS. See deployment/README.md.

Explore the Roadmap to see what’s ahead, or join the Call for the Community to get involved.

CUGA in Action

Hybrid Task Execution

Watch CUGA seamlessly combine web and API operations in a single workflow:

Example Task: get top account by revenue from digital sales, then add it to current page

https://github.com/user-attachments/assets/0cef8264-8d50-46d9-871a-ab3cefe1dde5

Human in the Loop Task Execution

Watch CUGA pause for human approval during critical decision points:

Example Task: get best accounts

https://github.com/user-attachments/assets/d103c299-3280-495a-ba66-373e72554e78

Quick Start

# In terminal, clone the repository and navigate into it
git clone https://github.com/cuga-project/cuga-agent.git
cd cuga-agent

# 1. Create and activate virtual environment
uv venv --python=3.12 && source .venv/bin/activate

# 2. Install dependencies
uv sync

# 3. Set up environment variables
# Create .env file with your API keys
echo "OPENAI_API_KEY=your-openai-api-key-here" > .env

# 4. Start the demo
cuga start demo_crm --read-only

# Chrome will open automatically at https://localhost:7860
# then try sending your task to CUGA: 'from contacts.txt show me which users belong to the crm system'

# 5. View agent trajectories (optional)
cuga viz

# This launches a web-based dashboard for visualizing and analyzing
# agent execution trajectories, decision-making, and tool usage

Agent skills

Agent skills are reusable instruction packs: each skill is a SKILL.md file with YAML frontmatter and markdown body. CUGA discovers them at startup, lists short descriptions in the agent prompt, and exposes a load_skill tool so the model pulls the full body only when a task matches that skill—similar to opening a playbook instead of stuffing every procedure into the system prompt.

Where skills live

Configure a single root in settings.toml ([skills] root, default cuga) or via DYNACONF_SKILLS__ROOT env var. CUGA scans one directory only — no merge across paths.

skills.root Project path Use when
cuga (default) /skills/**/SKILL.md (e.g. .cuga/skills/) CUGA-native layout; keeps skills with other CUGA config
agents .agents/skills/**/SKILL.md skills.sh / npx skills universal installs
global_agents ~/.config/agents/skills/ Global npx skills -g installs
global_cuga ~/.config/cuga/skills/ Legacy global CUGA path

Why default cuga? CUGA already uses .cuga/ for policy, workspace, and uploads. Keeping skills there avoids colliding with other agents that write .agents/skills/. If you install skills with npx skills, set root = "agents" or copy skills into .cuga/skills/.

SKILL.md shape

Frontmatter must include name and description (shown in the available-skills list). You can add optional requirements (string or list). The markdown below the frontmatter is the full instruction text returned by load_skill.

Try it

From the repository root:

npx skills add https://github.com/anthropics/skills --skill pptx -a universal
cuga start demo_skills

That preset turns on skills for the run and uses [advanced_features] sandbox_mode in settings.toml (default native). For opensandbox, run uv sync --extra opensandbox first so the client deps are installed and OpenSandbox can be reached.

For Docker/Podman isolation instead, use uv sync --group sandbox then cuga start demo --sandbox and enable [skills]—see Configurations.

For settings you keep beyond a one-off run, configure [skills] and [advanced_features] in settings.toml (Dynaconf env overrides apply as documented there).

Install a sample skill (Anthropic pptx)

The Anthropic skills repo publishes ready-made folders such as skills/pptx (SKILL.md, scripts, and helper markdown). Install the pptx skill into the project-local universal agent skills folder from the repository root:

npx skills add https://github.com/anthropics/skills --skill pptx -a universal

This creates .agents/skills/pptx/SKILL.md for the current project (or set [skills] root = "agents" in settings.toml). To use the CUGA default layout instead, copy or symlink skills into .cuga/skills/. Restart cuga start demo_skills (or your app) so skills are rescanned. Add -g if you want the skill installed globally under ~/.config/agents/skills/ instead.


Using CUGA as a Python SDK

CUGA can be easily integrated into your Python applications as a library. The SDK provides a clean, minimal API for creating and invoking agents with custom tools.

SDK Documentation: SDK Documentation

Quick Start

from cuga import CugaAgent
from langchain_core.tools import tool
import asyncio

@tool
def add_numbers(a: int, b: int) -> int:
    '''Add two numbers together'''
    return a + b

@tool
def multiply_numbers(a: int, b: int) -> int:
    '''Multiply two numbers together'''
    return a * b

# Create agent with tools
agent = CugaAgent(tools=[add_numbers, multiply_numbers])

async def main():
    # Add an Intent Guard to block specific operations
    await agent.policies.add_intent_guard(
        name="Block Delete Operations",
        description="Prevents deletion of critical data",
        keywords=["delete", "remove", "erase"],
        response="Deletion operations are not permitted for security reasons.",
        priority=100  # Higher priority = checked first
    )

    # Add a Playbook to provide step-by-step guidance for complex workflows
    await agent.policies.add_playbook(
        name="Budget Analysis Workflow",
        description="Multi-step process for analyzing financial budgets",
        natural_language_trigger=["When user asks to analyze their budget"],
        content="""# Budget Analysis Workflow

    ## Step 1: Calculate Total Expenses
    - Sum all expense categories using add_numbers
    - Document each category amount

    ## Step 2: Calculate Total Revenue
    - Sum all revenue streams using add_numbers
    - Include all income sources

    ## Step 3: Calculate Profit Margin
    - Use multiply_numbers to calculate profit (revenue - expenses)
    - Calculate margin percentage

    ## Step 4: Generate Recommendations
    - Compare against target budget
    - Identify areas for optimization
    - Provide actionable insights""",
        priority=50
    )

    result = await agent.invoke("Analyze my budget: expenses are 5000 and 3000, revenue is 12000")
    print(result.answer)  # The agent's response

if __name__ == "__main__":
    asyncio.run(main())

Key Features

  • Simple API: CugaAgent(tools=[...])await agent.invoke(message)
  • Streaming: Monitor execution in real-time with agent.stream()
  • State Isolation: Per-user sessions with thread_id
  • LangGraph Integration: Access underlying graph for advanced use cases
  • Flexible Tools: Direct tools or custom tool providers
  • Policy System: Comprehensive policy framework with 5 types:
    • Intent Guard: Block or modify specific user intents
    • Playbook: Step-by-step guidance for complex workflows
    • Tool Approval: Require human approval before executing tools
    • Tool Guide: Enhance tool descriptions with additional context
    • Output Formatter: Format agent responses based on triggers

Documentation: SDK Guide | Policies Guide

Knowledge Base

CUGA includes a built-in knowledge base powered by LangChain and local vector stores. Docling is integrated for document ingestion: it parses and normalizes PDFs, Office files, HTML, Markdown, images, and other supported types before chunking and embedding, so the pipeline stays self-contained with no external document services.

When enabled, the agent can search, ingest, and manage documents.

Try the knowledge demo: same as the main demo but with the knowledge engine on (upload documents and query them):

cuga start demo_knowledge

Walk through a full HR-Benefits demo with sample documents and example prompts: docs/examples/knowledge_demo/

Knowledge is enabled by default via settings.toml. The SDK auto-injects knowledge tools and awareness into the agent, so it knows what documents are available and how to search them.

Programmatic Access

from cuga import CugaAgent
import asyncio

agent = CugaAgent(enable_knowledge=True)

async def main():
    # Ingest a document
    await agent.knowledge.ingest("/path/to/quarterly_report.pdf")

    # The agent now automatically knows about this document
    result = await agent.invoke("What does the report say about Q4 revenue?")
    print(result.answer)  # Agent searches knowledge base and answers

    # Direct search
    results = await agent.knowledge.search("Q4 revenue figures")
    for r in results:
        print(f"{r['filename']} (page {r['page']}): {r['text'][:100]}")

    # List documents
    docs = await agent.knowledge.list_documents()

    # Clean up
    await agent.aclose()

asyncio.run(main())

Session-Scoped Knowledge

Documents can be scoped to a specific conversation thread:

thread_id = "user-session-123"

# Ingest into session scope (temporary, per-conversation)
await agent.knowledge.ingest("/path/to/file.pdf", scope="session", thread_id=thread_id)

# Search session documents
results = await agent.knowledge.search("query", scope="session", thread_id=thread_id)

# Agent scope (default) — permanent, shared across conversations
await agent.knowledge.ingest("/path/to/file.pdf", scope="agent")

Disabling Knowledge

agent = CugaAgent(tools=[my_tools], enable_knowledge=False)

Supported Document Types

PDF, DOCX, XLSX, PPTX, HTML, Markdown, images, and more (via Docling).

Embedding providers + tuning

The knowledge engine ships four built-in provider categories — fastembed (default, local), huggingface (local), openai (network, accepts any OpenAI-compatible endpoint via base_url), and ollama (network) — plus openrouter for one-key-many-models access to embedding models on openrouter.ai/models. Provider, model, batch size, and concurrency are all set under [knowledge.embeddings] in settings.toml or via CLI overrides (--embeddings-provider, --embeddings-base-url, --embeddings-api-key, --embeddings-model, --embeddings-batch-size, --embeddings-concurrency).

Full provider matrix + tuning guide — see the knowledge engine docs. Switching provider or model invalidates existing vectors (different dim), so the manage UI surfaces a “Re-index recommended” banner automatically.


CugaSupervisor (Multi-Agent)

Orchestrate multiple agents with a single supervisor: delegate tasks to specialized sub-agents, mix local agents with remote A2A agents, and pass data between them.

Documentation: CugaSupervisor

Try the supervisor demo: run the multi-agent demo (CRM + email sub-agents) with:

cuga start demo_supervisor

Quick Start

from cuga import CugaAgent, CugaSupervisor
from langchain_core.tools import tool
import asyncio

@tool
def get_customers(limit: int = 10) -> str:
    """Fetch top customers from CRM with name, email, and revenue. Returns a formatted string."""
    customers = [
        "Alice ([email protected], $250,000)",
        "Bob ([email protected], $180,000)",
        "Carol ([email protected], $120,000)",
        "Dave ([email protected], $95,000)",
        "Eve ([email protected], $88,000)",
    ]
    top = customers[: min(limit, len(customers))]
    return "Top customers by revenue: " + "; ".join(f"{i+1}. {c}" for i, c in enumerate(top))

@tool
def send_email(to: str, body: str) -> str:
    """Send an email. Returns confirmation."""
    return f"Email sent successfully to {to}"

async def main():
    crm_agent = CugaAgent(tools=[get_customers])
    crm_agent.description = "CRM and customer data"

    email_agent = CugaAgent(tools=[send_email])
    email_agent.description = "Sending emails and notifications"

    supervisor = CugaSupervisor(agents={
        "crm": crm_agent,
        "email": email_agent,
    })

    result = await supervisor.invoke("Get our top 5 customers by revenue, then send the top customer a thank-you email")
    print(result.answer)

asyncio.run(main())

To add a remote agent via A2A, pass an external config in agents: "analytics": {"type": "external", "description": "...", "config": {"a2a_protocol": {"endpoint": "http://localhost:9999", "transport": "http"}}}.

Supervisor features

  • Delegation: Supervisor hands work to sub-agents and can pass variables between them when needed.
  • Internal + external: Combine local CugaAgent instances with external agents via A2A, task-only or variables in metadata if enabled.
  • Variable passing: Use variables=["var_name"] to pass previous agent outputs or context to the next agent (for internal agents, or A2A when pass_variables_a2a is enabled in settings).
  • Agent cards: For A2A agents, capabilities and description are taken from the agent card and shown in the supervisor prompt.

You can also load agents from YAML with CugaSupervisor.from_yaml("path/to/config.yaml"). Enable the supervisor in settings.toml under [supervisor] when using the server.


Configurations

Advanced Usage

Test Scenarios - E2E

All tests run through pytest (configured in pyproject.toml):

Unit Tests

  • Registry: OpenAPI integration, MCP server functionality, service configurations
  • Variables Manager: Core functionality, metadata handling, singleton pattern
  • Code Executors: Local sandbox and E2B lite execution

Policy Integration Tests (src/cuga/backend/cuga_graph/policy/tests/)

  • Intent Guard: Blocking behavior, priority resolution, multiple guard scenarios
  • Playbook: Guidance injection, plan refinement, workflow execution
  • Tool Approval: Human-in-the-loop approval flows (approve/deny)
  • Tool Guide: Context enhancement and metadata injection
  • Output Formatter: Response formatting and routing
  • NL Trigger Conflict Resolution: Embedding-based similarity search with LLM conflict resolution
  • Embedding Similarity: Vector search, policy matching, threshold validation
  • Keyword Operators: AND/OR logic, case sensitivity, multi-keyword matching

SDK Integration Tests (src/cuga/sdk_core/tests/)

  • SDK functionality: Agent invocation, streaming, tool integration
  • Policy management: Policy loading, matching, and execution via SDK

Stability Tests (@pytest.mark.stability in src/system_tests/e2e/)

  • Fast Mode: Get top account by revenue, list accounts, find VP sales high-value accounts
  • CRM Workflows: Contacts management, email operations, tool discovery
  • HF Utterances: Account queries, revenue calculations, playbook execution
  • Execution: Sequential (-n0) so the 88% pass-rate gate aggregates on the controller; CI uses --stability-threshold 88

Running Tests

Lint:

uv run ruff check && uv run ruff format --check

Run the default suite (excludes manual and pgvector; pgvector needs a container):

uv run pytest

Run the CI-equivalent subset (matches the main tests.yml job):

uv run pytest -m "not stability and not pgvector and not manual and not e2e and not load"
uv run pytest src/system_tests/load/load_test_with_mocked_llm.py -m load --load-test-users 5

Run a faster local loop:

uv run pytest -m "not stability and not slow and not pgvector and not manual and not e2e and not load"

Run stability tests only (88% pass-rate gate; use -n0 so threshold aggregation works):

uv run pytest -m stability --stability-threshold 88 -n0

Run pgvector tests (requires a running pgvector container):

uv run pytest -m pgvector -o addopts="-ra --strict-markers --import-mode=importlib"

Evaluation

For information on how to evaluate, see the CUGA Evaluation Documentation

Resources

Call for the Community

CUGA is open source because we believe trustworthy enterprise agents must be built together.
Here’s how you can help:

  • Share use cases → Show us how you’d use CUGA in real workflows.
  • Request features → Suggest capabilities that would make it more useful.
  • Report bugs → Help improve stability by filing clear, reproducible reports.

All contributions are welcome through GitHub Issues - whether it’s sharing use cases, requesting features, or reporting bugs!

Roadmap

Amongst other, we’re exploring the following directions:

  • Policy support: procedural SOPs, domain knowledge, input/output guards, context- and tool-based constraints
  • Performance improvements: dynamic reasoning strategies that adapt to task complexity

Before Submitting a PR

Please follow the contribution guide in CONTRIBUTING.md.


Contributors

View this README on GitHub

推荐工具

换一个关键词,或者移除筛选条件。

安装

npx skillfish add cuga-project/cuga-agent