Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

dongitran/UrAgent

Repository files navigation

πŸ€– UrAgent

Your AI-Powered Software Engineer β€” An asynchronous coding agent that autonomously understands codebases, plans solutions, and executes code changes across entire repositories.

Fork LangGraph TypeScript


✨ What's New in UrAgent?

UrAgent is a production-ready fork of Open SWE by LangChain, enhanced with enterprise features and improved reliability:

πŸ” Enterprise Authentication

  • Keycloak SSO β€” Seamless single sign-on integration for enterprise environments
  • Auto Token Refresh β€” Automatic token renewal with secure cookie handling
  • Public/Confidential Clients β€” Support for both Keycloak client types

🧠 Advanced AI Capabilities

  • Gemini 3 Support β€” Full integration with Google's latest Gemini 3 models including thought signatures
  • Multi-Provider Fallback β€” Automatic failover between OpenAI, Anthropic, and Google GenAI
  • LiteLLM Gateway β€” Route requests through LiteLLM for unified API access
  • Circuit Breaker Pattern β€” Intelligent model switching when providers fail

πŸ”„ Intelligent Loop Detection

  • Pattern Recognition β€” Detects verification loops, error retries, alternating patterns, and "chanting"
  • Edit Loop Prevention β€” Specifically handles str_replace failures (whitespace, line endings)
  • Adaptive Thresholds β€” Tuned based on research from Claude Code, Gemini CLI, and Aider issues
  • Graceful Recovery β€” Warns, escalates, or requests human help based on severity

πŸ—οΈ Multi-Sandbox Architecture

  • Provider Abstraction β€” Unified interface for E2B, Daytona, and local sandboxes
  • Round-Robin Key Rotation β€” Weighted distribution across multiple API keys
  • Multi-Provider Mode β€” Run sandboxes across different providers simultaneously
  • Automatic Retry β€” Exponential backoff for transient sandbox failures

πŸš€ Production Reliability

  • GitHub API Caching β€” Intelligent caching layer for API responses
  • Retry with Backoff β€” All external calls include retry logic
  • Run Cancellation β€” Graceful termination with automatic commit
  • LLM Comment Generation β€” Natural language PR/issue comments via AI

🎯 Core Features

Feature Description
πŸ“ Planning Deep understanding of complex codebases with dedicated planning step
🀝 Human in the Loop Send messages while running for real-time feedback
πŸƒ Parallel Execution Run multiple tasks in parallel sandbox environments
πŸ§‘β€πŸ’» End-to-End Management Automatic GitHub issue and PR creation
πŸ” Enterprise SSO Keycloak authentication for corporate environments

πŸ›οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Browser β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
 β”‚
 β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Next.js Web Application β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ Keycloak β”‚ β”‚ GitHub β”‚ β”‚ API Proxy + Cache β”‚ β”‚
β”‚ β”‚ Auth β”‚ β”‚ OAuth β”‚ β”‚ (with retry & backoff) β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
 β”‚
 β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ LangGraph API (Internal) β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ Planner β”‚ β”‚ Programmer β”‚ β”‚ Reviewer β”‚ β”‚
β”‚ β”‚ Graph β”‚ β”‚ Graph β”‚ β”‚ Graph β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚ β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚ β”‚ Model Manager β”‚β”‚
β”‚ β”‚ β€’ Multi-provider fallback (OpenAI β†’ Anthropic β†’ Google) β”‚β”‚
β”‚ β”‚ β€’ Circuit breaker pattern β”‚β”‚
β”‚ β”‚ β€’ Gemini 3 thought signatures β”‚β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚ β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚ β”‚ Loop Detection β”‚β”‚
β”‚ β”‚ β€’ Verification loops β€’ Error retries β€’ Alternating patterns β”‚β”‚
β”‚ β”‚ β€’ Edit loops (str_replace) β€’ Chanting detection β”‚β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
 β”‚
 β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Sandbox Provider Layer β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ E2B β”‚ β”‚ Daytona β”‚ β”‚ Local β”‚ β”‚
β”‚ β”‚ Sandbox β”‚ β”‚ Sandbox β”‚ β”‚ (Dev Mode) β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚ β”‚
β”‚ β€’ Round-robin API key rotation β”‚
β”‚ β€’ Multi-provider mode β”‚
β”‚ β€’ Automatic retry with exponential backoff β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸš€ Quick Start

Prerequisites

  • Node.js 20+
  • Yarn 3.5+
  • Docker & Docker Compose

Installation

# Clone the repository
git clone https://github.com/dongitran/UrAgent.git
cd UrAgent
# Install dependencies
yarn install
# Copy environment template
cp apps/open-swe/.env.example apps/open-swe/.env
cp apps/web/.env.example apps/web/.env

Running Locally

# Start the LangGraph API (Docker)
docker compose up --build
# In another terminal, start the web app
cd apps/web && yarn dev

Visit http://localhost:3000 to access the UI.


βš™οΈ Configuration

Environment Variables

LLM Provider Configuration

# Primary provider (openai, anthropic, google-genai)
LLM_PROVIDER=google-genai
# Enable multi-provider fallback
LLM_MULTI_PROVIDER_ENABLED=true
# Provider-specific models (optional)
GOOGLE_PROGRAMMER_MODEL=gemini-3-pro-preview
GOOGLE_PLANNER_MODEL=gemini-3-pro-preview
ANTHROPIC_PROGRAMMER_MODEL=claude-opus-4-5
OPENAI_PROGRAMMER_MODEL=gpt-4o
# LiteLLM Gateway (optional)
OPENAI_BASE_URL=https://your-litellm-gateway.com/v1

Sandbox Configuration

# Sandbox provider: e2b, daytona, multi, local
SANDBOX_PROVIDER=daytona
# For multi-provider mode with round-robin
SANDBOX_PROVIDER=multi
DAYTONA_API_KEYS=key1,key2,key3
DAYTONA_API_KEY_WEIGHTS=3,2,1

GitHub App Configuration

GITHUB_APP_ID=your-app-id
GITHUB_APP_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----..."
GITHUB_APP_NAME=your-app-name

Repository Defaults

DEFAULT_REPOSITORY_OWNER=your-org
DEFAULT_REPOSITORY_NAME=your-repo
DEFAULT_BRANCH=main
DEFAULT_GITHUB_INSTALLATION_ID=your-installation-id

Authentication

Keycloak SSO (Recommended for Enterprise)

When Keycloak is configured, it becomes the mandatory authentication method.

NEXT_PUBLIC_KEYCLOAK_URL=https://your-keycloak.example.com
NEXT_PUBLIC_KEYCLOAK_REALM=your-realm
NEXT_PUBLIC_KEYCLOAK_CLIENT_ID=your-client-id
KEYCLOAK_REDIRECT_URI=http://localhost:3000/api/auth/keycloak/callback
# Optional: Only for confidential clients
# KEYCLOAK_CLIENT_SECRET=your-client-secret

Keycloak Client Setup:

  1. Create a new client in your Keycloak realm
  2. Set "Client authentication" to OFF for public clients (recommended for SPAs)
  3. Add http://localhost:3000/api/auth/keycloak/callback to Valid Redirect URIs
  4. Add http://localhost:3000 to Web Origins

GitHub OAuth (Default)

When Keycloak is not configured, GitHub OAuth is used automatically.

Development Mode

For local development without authentication:

DEFAULT_GITHUB_INSTALLATION_ID=your-installation-id
DEFAULT_GITHUB_INSTALLATION_NAME=your-github-username

☸️ Kubernetes Deployment

Ingress NGINX Configuration

When deploying behind NGINX Ingress Controller, add these annotations for large authentication headers:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
 annotations:
 nginx.ingress.kubernetes.io/proxy-buffer-size: "128k"
 nginx.ingress.kubernetes.io/proxy-buffers-number: "4"

πŸ”§ Advanced Features

Loop Detection

UrAgent includes sophisticated loop detection based on research from:

  • Claude Code Issue #4277 (Tool Call Loops + Content Loops)
  • Gemini CLI Issue #11002 (Output comparison for false positive reduction)
  • Gemini CLI Issue #5761 (str_replace_based_edit_tool specific errors)
  • Cline Issue #2909 (Diff Edit Mismatch errors)
  • Aider Issue #770 (Edit format errors)

Detected Patterns:

  • verification β€” Agent keeps reading same file to verify
  • error_retry β€” Agent retrying same command that errors
  • alternating β€” Aβ†’Bβ†’Aβ†’B pattern
  • edit_loop β€” Agent stuck trying to edit same file
  • chanting β€” Model generating same content repeatedly

Multi-Provider Fallback

The Model Manager automatically handles provider failures:

Primary Model (e.g., Gemini 3 Pro)
 β”‚
 β–Ό (on failure)
Circuit Breaker Opens
 β”‚
 β–Ό
Fallback to Anthropic Claude
 β”‚
 β–Ό (on failure)
Fallback to OpenAI GPT-4
 β”‚
 β–Ό (after timeout)
Circuit Breaker Closes β†’ Retry Primary

Sandbox Provider Abstraction

// Unified interface for all sandbox providers
interface ISandboxProvider {
 name: string;
 createSandbox(options: CreateSandboxOptions): Promise<ISandbox>;
 getSandbox(id: string): Promise<ISandbox | null>;
 listSandboxes(): Promise<ISandbox[]>;
}
// Supported providers
- E2B (Cloud sandboxes)
- Daytona (Self-hosted)
- Local (Development mode)
- Multi (Round-robin across providers)

πŸ“¦ Project Structure

uragent/
β”œβ”€β”€ apps/
β”‚ β”œβ”€β”€ open-swe/ # LangGraph agent (Planner, Programmer, Reviewer)
β”‚ β”œβ”€β”€ web/ # Next.js 15 + React 19 frontend
β”‚ β”œβ”€β”€ cli/ # Command-line interface
β”‚ └── docs/ # Documentation site
β”œβ”€β”€ packages/
β”‚ └── shared/ # Shared utilities, types, constants
β”œβ”€β”€ docker-compose.yml # Local development setup
β”œβ”€β”€ langgraph.json # LangGraph configuration
└── turbo.json # Turborepo build orchestration

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'feat: add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the same terms as the original Open SWE project.

Original Open SWE License

Open SWE is created by LangChain and is licensed under the MIT License.


πŸ™ Acknowledgments

  • LangChain for creating Open SWE
  • LangGraph for the agent framework
  • The open-source community for inspiration on loop detection and reliability patterns

Built with ❀️ for developers who want AI that actually works

About

No description, website, or topics provided.

Resources

License

Security policy

Stars

Watchers

Forks

Packages

Contributors

Languages

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /