Skip to content

Commit 364d56f

Browse files
committed
fixed agentstack commands to use uv when available
1 parent e911e61 commit 364d56f

3 files changed

Lines changed: 28 additions & 2 deletions

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,14 @@ agentstack tools add
120120

121121
## Running Your Agent
122122

123-
`agentstack run`
123+
```bash
124+
uv run agentstack run
125+
```
124126

125127
Runs the agent project in development mode.<br>
126128

129+
> Note: Always use `uv run` when executing AgentStack commands to ensure proper environment management.
130+
127131
> 👀 Support for easy production deployment of agents is coming soon.
128132
129133
## Philosophy

agentstack/cli/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def init_project_builder(
144144
" uv lock\n"
145145
" uv sync\n\n"
146146
" 6. Try running your agent:\n"
147-
" agentstack run\n\n"
147+
" uv run agentstack run\n\n"
148148
" Run `agentstack quickstart` or `agentstack docs` for next steps.\n"
149149
)
150150

agentstack/main.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import sys
22
import argparse
33
import webbrowser
4+
import os
5+
import subprocess
6+
from pathlib import Path
47

58
from agentstack import conf, auth
69
from agentstack.cli import (
@@ -17,7 +20,26 @@
1720
from agentstack.update import check_for_updates
1821

1922

23+
def ensure_uv_environment():
24+
"""Ensure the command is running in a UV-managed environment."""
25+
if not os.environ.get("VIRTUAL_ENV"):
26+
# If not in a virtual environment, rerun the command with UV
27+
args = ["uv", "run"] + sys.argv
28+
try:
29+
result = subprocess.run(args, check=True)
30+
sys.exit(result.returncode)
31+
except subprocess.CalledProcessError as e:
32+
sys.exit(e.returncode)
33+
except FileNotFoundError:
34+
print("Error: UV is not installed. Please install UV first with: pip install uv")
35+
sys.exit(1)
36+
37+
2038
def main():
39+
# Ensure we're running in a UV environment for all commands except 'init'
40+
if len(sys.argv) > 1 and sys.argv[1] != "init":
41+
ensure_uv_environment()
42+
2143
global_parser = argparse.ArgumentParser(add_help=False)
2244
global_parser.add_argument(
2345
"--path",

0 commit comments

Comments
 (0)