feat: remove agent_working_dir from settings (#1874)

* remove configurable agent_working_dir

(cherry picked from commit 285b3e04abceeb8e4a4ee1be16e3de97a8f32299)

* calculate agent_working_dir on create and start task

* i18n
This commit is contained in:
Gabriel Gordon-Hall
2026-01-12 09:14:48 +00:00
committed by GitHub
parent b6518fd930
commit 8fa5b9d098
15 changed files with 28 additions and 167 deletions

View File

@@ -176,16 +176,17 @@ pub async fn create_task_attempt(
.await?
.ok_or(SqlxError::RowNotFound)?;
let project = task
.parent_project(pool)
.await?
.ok_or(SqlxError::RowNotFound)?;
let agent_working_dir = project
.default_agent_working_dir
.as_ref()
.filter(|dir| !dir.is_empty())
.cloned();
// Compute agent_working_dir based on repo count:
// - Single repo: use repo name as working dir (agent runs in repo directory)
// - Multiple repos: use None (agent runs in workspace root)
let agent_working_dir = if payload.repos.len() == 1 {
let repo = Repo::find_by_id(pool, payload.repos[0].repo_id)
.await?
.ok_or(RepoError::NotFound)?;
Some(repo.name)
} else {
None
};
let attempt_id = Uuid::new_v4();
let git_branch_name = deployment

View File

@@ -14,8 +14,7 @@ use axum::{
};
use db::models::{
image::TaskImage,
project::{Project, ProjectError},
repo::Repo,
repo::{Repo, RepoError},
task::{CreateTask, Task, TaskWithAttemptStatus, UpdateTask},
workspace::{CreateWorkspace, Workspace},
workspace_repo::{CreateWorkspaceRepo, WorkspaceRepo},
@@ -178,21 +177,23 @@ pub async fn create_task_and_start(
)
.await;
let project = Project::find_by_id(pool, task.project_id)
.await?
.ok_or(ProjectError::ProjectNotFound)?;
let attempt_id = Uuid::new_v4();
let git_branch_name = deployment
.container()
.git_branch_from_workspace(&attempt_id, &task.title)
.await;
let agent_working_dir = project
.default_agent_working_dir
.as_ref()
.filter(|dir: &&String| !dir.is_empty())
.cloned();
// Compute agent_working_dir based on repo count:
// - Single repo: use repo name as working dir (agent runs in repo directory)
// - Multiple repos: use None (agent runs in workspace root)
let agent_working_dir = if payload.repos.len() == 1 {
let repo = Repo::find_by_id(pool, payload.repos[0].repo_id)
.await?
.ok_or(RepoError::NotFound)?;
Some(repo.name)
} else {
None
};
let workspace = Workspace::create(
pool,