fix: worker creates venv before execution, prompt enforces uv pip install

This commit is contained in:
Fam Zheng 2026-04-06 20:38:20 +01:00
parent c56bfd9377
commit 63b577ee46
2 changed files with 11 additions and 2 deletions

View File

@ -27,6 +27,7 @@
## 环境信息 ## 环境信息
- 工作目录是独立的项目工作区Python venv 已预先激活(.venv/ - 工作目录是独立的项目工作区Python venv 已预先激活(.venv/
- 使用 `uv add <包名>``pip install <包名>` 安装依赖 - 安装 Python 包**必须**使用 `uv pip install <包名>`(不要用裸 pip
- 运行 Python 脚本直接用 `python3 xxx.py`venv 已在 PATH 中)
请使用中文回复。 请使用中文回复。

View File

@ -150,7 +150,15 @@ async fn connect_and_run(server_url: &str, worker_name: &str, llm_config: &crate
let llm = LlmClient::new(llm_config); let llm = LlmClient::new(llm_config);
let exec = LocalExecutor::new(None); let exec = LocalExecutor::new(None);
let workdir = format!("workspaces/{}", project_id); let workdir = format!("workspaces/{}", project_id);
let instructions = String::new(); // TODO: load from template let instructions = String::new();
// Ensure workspace has a venv
let _ = tokio::fs::create_dir_all(&workdir).await;
let venv_path = format!("{}/.venv", workdir);
if !std::path::Path::new(&venv_path).exists() {
tracing::info!("Setting up venv in {}", workdir);
let _ = exec.execute("uv venv .venv", &workdir).await;
}
// update channel → serialize → WebSocket // update channel → serialize → WebSocket
let (update_tx, mut update_rx) = mpsc::channel::<AgentUpdate>(64); let (update_tx, mut update_rx) = mpsc::channel::<AgentUpdate>(64);