AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix(blocks): make Conductor Create Workspace's base branch explicit and report it (#15108)
Abhimanyu Yadavac3c7693407e
diff --git a/autogpt_platform/backend/backend/blocks/conductor/create_workspace.py b/autogpt_platform/backend/backend/blocks/conductor/create_workspace.pyindex 41f0bfeb46..89ebbe5d5a 100644--- a/autogpt_platform/backend/backend/blocks/conductor/create_workspace.py+++ b/autogpt_platform/backend/backend/blocks/conductor/create_workspace.py@@ -1,5 +1,7 @@from typing import Any+from pydantic import model_validator+from backend.sdk import (APIKeyCredentials,Block,@@ -49,7 +51,15 @@ class ConductorCreateWorkspaceBlock(Block):default="",advanced=False,)- branch: str = SchemaField(description="Branch to start from", default="")+ base_branch: str = SchemaField(+ description="Branch the workspace branches from. Empty = Conductor "+ "project default, which may differ from the repository's PR target "+ "branch (for example a project that defaults to master while PRs "+ "go to dev). Set it explicitly for repos whose default is not the "+ "PR target, otherwise the PR inherits commits from the wrong base.",+ default="",+ advanced=False,+ )name: str = SchemaField(description="Workspace name", default="")session_name: str = SchemaField(description="Name of the initial agent session", default=""@@ -96,10 +106,31 @@ class ConductorCreateWorkspaceBlock(Block):le=300,)+ @model_validator(mode="before")+ @classmethod+ def _accept_legacy_branch(cls, data: Any) -> Any:+ # Nodes saved before the input was renamed still carry `branch`,+ # as a stored default or as the sink of a link. Both reach this+ # model, so map it here rather than only in the defaults hook.+ if (+ isinstance(data, dict)+ and "base_branch" not in data+ and data.get("branch")+ ):+ return {**data, "base_branch": data["branch"]}+ return data+class Output(BlockSchemaOutput):workspace_id: str = SchemaField(description="ID of the new workspace")session_id: str = SchemaField(description="ID of the initial session")deep_link: str = SchemaField(description="Link that opens the workspace")+ base_branch: str = SchemaField(+ description="Branch the workspace was asked to branch from, as sent "+ "to Conductor. Empty when Conductor's project default was used: the "+ "API does not report the resolved branch, so an empty value means "+ "the base is unknown. Verify this matches the PR target before "+ "opening a PR."+ )initial_message_id: str = SchemaField(description="ID of the initial prompt message, empty when none was sent")@@ -130,7 +161,10 @@ class ConductorCreateWorkspaceBlock(Block):id="d419c562-873c-4a67-b83f-9bcf11254f3f",description="Create a Conductor cloud workspace for a project or ""repository, optionally start its agent with a prompt and wait for "- "the reply.",+ "the reply. Set base_branch explicitly when the repository's PR "+ "target differs from the Conductor project default; an empty "+ "base_branch uses that default, which Conductor does not report "+ "back.",categories={BlockCategory.DEVELOPER_TOOLS},effect=BlockEffect.EXTERNAL,input_schema=self.Input,@@ -144,6 +178,7 @@ class ConductorCreateWorkspaceBlock(Block):{"credentials": conductor.get_test_credentials().model_dump(),"project_id": "proj_1",+ "base_branch": "dev","message": "Fix the login bug","wait_for_reply": True,},@@ -153,11 +188,13 @@ class ConductorCreateWorkspaceBlock(Block):("workspace_id", "ws_1"),("session_id", "sess_1"),("deep_link", "conductor://workspace/ws_1"),+ ("base_branch", ""),("initial_message_id", "msg_1"),("next_after", "row_1"),("workspace_id", "ws_1"),("session_id", "sess_1"),("deep_link", "conductor://workspace/ws_1"),+ ("base_branch", "dev"),("initial_message_id", "msg_1"),("next_after", "row_1"),("session_status", "idle"),@@ -255,7 +292,7 @@ class ConductorCreateWorkspaceBlock(Block):{"projectId": input_data.project_id,"repositoryUrl": input_data.repository_url,- "branch": input_data.branch,+ "branch": input_data.base_branch,"name": input_data.name,"sessionName": input_data.session_name,"agent": input_data.agent,@@ -286,6 +323,9 @@ class ConductorCreateWorkspaceBlock(Block):yield "workspace_id", str(created.get("workspaceId") or "")yield "session_id", session_idyield "deep_link", str(created.get("deepLink") or "")+ # The create and get responses carry no branch, so the requested base+ # is the only record of it; empty means Conductor's project default.+ yield "base_branch", input_data.base_branchyield "initial_message_id", message_idif not (session_id and message_id):diff --git a/autogpt_platform/backend/backend/blocks/conductor/get_workspace.py b/autogpt_platform/backend/backend/blocks/conductor/get_workspace.pyindex 0f8c9f8cda..71a953ecc9 100644--- a/autogpt_platform/backend/backend/blocks/conductor/get_workspace.py+++ b/autogpt_platform/backend/backend/blocks/conductor/get_workspace.py@@ -73,6 +73,12 @@ class ConductorGetWorkspaceBlock(Block):description="session_offset to request the next page of sessions")deep_link: str = SchemaField(description="Link that opens the workspace")+ base_branch: str = SchemaField(+ description="Branch the workspace was created from, when Conductor "+ "reports it. The API currently omits it, so this is empty; keep the "+ "base_branch output of Create Workspace instead. Verify it matches "+ "the PR target before opening a PR."+ )def __init__(self):super().__init__(@@ -99,6 +105,7 @@ class ConductorGetWorkspaceBlock(Block):("sessions_has_more", False),("next_session_offset", 1),("deep_link", "conductor://workspace/ws_1"),+ ("base_branch", ""),],test_mock={"_fetch": lambda *args, **kwargs: {@@ -181,6 +188,14 @@ class ConductorGetWorkspaceBlock(Block):)yield "next_session_offset", input_data.session_offset + len(sessions)yield "deep_link", str(workspace.get("deepLink") or "")+ yield "base_branch", _base_branch(workspace)+++def _base_branch(workspace: dict[str, Any]) -> str:+ """GET /workspaces/{id} does not return the branch a workspace was cut+ from today; read it under the names it is likely to appear as so the+ output fills in once Conductor adds it."""+ return str(workspace.get("baseBranch") or workspace.get("branch") or "")async def _list_sessions(diff --git a/autogpt_platform/backend/backend/blocks/conductor/test_conductor.py b/autogpt_platform/backend/backend/blocks/conductor/test_conductor.pyindex d6003230f8..3165707110 100644--- a/autogpt_platform/backend/backend/blocks/conductor/test_conductor.py+++ b/autogpt_platform/backend/backend/blocks/conductor/test_conductor.py@@ -134,7 +134,7 @@ async def test_create_workspace_builds_a_clean_payload():{"credentials": TEST_CREDENTIALS_INPUT,"repository_url": "https://github.com/x/y",- "branch": "main",+ "base_branch": "dev","agent": "codex","fast_mode": True,"env": {"FOO": "bar"},@@ -144,16 +144,65 @@ async def test_create_workspace_builds_a_clean_payload():)assert seen == {"repositoryUrl": "https://github.com/x/y",- "branch": "main",+ "branch": "dev","agent": "codex","fastMode": True,"env": {"FOO": "bar"},"access": {"restricted": True},}+ assert outputs["base_branch"] == "dev"assert outputs["initial_message_id"] == ""assert "reply" not in outputs+def test_create_workspace_input_accepts_the_branch_key_from_before_the_rename():+ validate = ConductorCreateWorkspaceBlock.Input.model_validate+ base = {"credentials": TEST_CREDENTIALS_INPUT, "project_id": "p1"}+ assert validate({**base, "branch": "dev"}).base_branch == "dev"+ assert (+ validate({**base, "branch": "main", "base_branch": "dev"}).base_branch == "dev"+ )+ assert validate(base).base_branch == ""+++async def test_create_workspace_sends_a_branch_linked_under_the_old_name():+ """A link wired to the old `branch` pin delivers its value under that key+ at run time, not through the stored defaults, and must still reach the+ API and the base_branch output."""+ block = ConductorCreateWorkspaceBlock()+ seen: dict[str, Any] = {}++ def create(_creds, payload):+ seen.update(payload)+ return {"workspaceId": "ws_1", "sessionId": "s1", "deepLink": "d"}++ mock_block(block, {"_create": create})+ outputs = await collect(+ block,+ {"credentials": TEST_CREDENTIALS_INPUT, "project_id": "p1", "branch": "dev"},+ )+ assert seen["branch"] == "dev"+ assert outputs["base_branch"] == "dev"+++async def test_create_workspace_without_base_branch_reports_it_as_unknown():+ block = ConductorCreateWorkspaceBlock()+ seen: dict[str, Any] = {}++ def create(_creds, payload):+ seen.update(payload)+ return {"workspaceId": "ws_1", "sessionId": "s1", "deepLink": "d"}++ mock_block(block, {"_create": create})+ outputs = await collect(+ block, {"credentials": TEST_CREDENTIALS_INPUT, "project_id": "p1"}+ )+ assert "branch" not in seen+ assert outputs["base_branch"] == ""++@pytest.mark.asyncioasync def test_send_message_without_waiting_returns_only_the_receipt():block = ConductorSendMessageBlock()diff --git a/autogpt_platform/backend/backend/blocks/conductor/test_listing_blocks.py b/autogpt_platform/backend/backend/blocks/conductor/test_listing_blocks.pyindex f77751ee59..304fa00fe7 100644--- a/autogpt_platform/backend/backend/blocks/conductor/test_listing_blocks.py+++ b/autogpt_platform/backend/backend/blocks/conductor/test_listing_blocks.py@@ -164,6 +164,35 @@ async def test_get_workspace_pages_sessions_up_to_the_limit():assert [c["offset"] for c in calls] == [1, 4]+ "workspace, expected",+ [+ ({"id": "ws_1", "state": "ready"}, ""),+ ({"id": "ws_1", "state": "ready", "branch": "dev"}, "dev"),+ ({"id": "ws_1", "state": "ready", "baseBranch": "dev"}, "dev"),+ ],+)+async def test_get_workspace_reports_base_branch_only_when_the_api_does(+ workspace: dict, expected: str+):+ client = mock.Mock()+ client.get_workspace = mock.AsyncMock(return_value=workspace)+ client.workspace_status = mock.AsyncMock(return_value={"status": "ready"})+ client.get_preview = mock.AsyncMock(return_value={})+ client.workspace_sessions = mock.AsyncMock(+ return_value={"data": [], "offset": 0, "hasMore": False}+ )+ block = ConductorGetWorkspaceBlock()+ with mock.patch(+ "backend.blocks.conductor.get_workspace.ConductorClient", return_value=client+ ):+ outputs = await collect(+ block, {"credentials": TEST_CREDENTIALS_INPUT, "workspace_id": "ws_1"}+ )+ assert outputs["base_branch"] == expected++# --- list workspaces (R1-07) --------------------------------------------------diff --git a/docs/integrations/block-integrations/conductor/create_workspace.md b/docs/integrations/block-integrations/conductor/create_workspace.mdindex a6a835bfde..9a240b5d66 100644--- a/docs/integrations/block-integrations/conductor/create_workspace.md+++ b/docs/integrations/block-integrations/conductor/create_workspace.md@@ -6,11 +6,11 @@ Creates a Conductor cloud workspace for a project or repository, optionally star## Conductor Create Workspace### What it is-Create a Conductor cloud workspace for a project or repository, optionally start its agent with a prompt and wait for the reply.+Create a Conductor cloud workspace for a project or repository, optionally start its agent with a prompt and wait for the reply. Set base_branch explicitly when the repository's PR target differs from the Conductor project default; an empty base_branch uses that default, which Conductor does not report back.### How it works<!-- MANUAL: how_it_works -->-The block posts to `POST /v0/workspaces` with exactly one of `project_id` or `repository_url` (both or neither is an input error). Blank optional fields are omitted so Conductor applies its defaults; `model` is passed through as-is, so use an id Conductor accepts (for example `fable-5-1`, `opus-5-5-1m`, `sonnet-5-1m`, `gpt-6-astra` or `auto`). When `message` is set the agent starts on it immediately and `initial_message_id` is returned, together with `next_after`: the prompt's transcript row ID to pass as `after` to Get Session (the receipt itself while the prompt has no row yet, which Get Session also accepts). With `wait_for_reply` the block then waits the same way as Send Message: it reads the transcript and then `GET /v0/sessions/{id}/status` every `poll_interval_seconds` (a wall-clock bound of `timeout_seconds`, reported through `timed_out`), correlates the transcript rows with the prompt's turn (a freshly initializing workspace reports idle until the agent actually starts, and startup events alone are not treated as done), and returns those rows with their visible agent text joined into `reply` (`truncated` is set when the turn exceeded the 1000 rows kept or its start was older than the rows read).+The block posts to `POST /v0/workspaces` with exactly one of `project_id` or `repository_url` (both or neither is an input error). Blank optional fields are omitted so Conductor applies its defaults. `base_branch` is sent as the API's `branch`: leave it empty and the workspace is cut from the Conductor project's default branch, which can differ from the branch the repository's PRs target (an AutoGPT workspace defaults to `master` while PRs go to `dev`), so set it explicitly for such repositories. Neither the create response nor `GET /v0/workspaces/{id}` reports the branch a workspace was cut from, so the `base_branch` output echoes what was requested and is empty when the default was used; check it against the PR target before opening a PR. `model` is passed through as-is, so use an id Conductor accepts (for example `fable-5-1`, `opus-5-5-1m`, `sonnet-5-1m`, `gpt-6-astra` or `auto`). When `message` is set the agent starts on it immediately and `initial_message_id` is returned, together with `next_after`: the prompt's transcript row ID to pass as `after` to Get Session (the receipt itself while the prompt has no row yet, which Get Session also accepts). With `wait_for_reply` the block then waits the same way as Send Message: it reads the transcript and then `GET /v0/sessions/{id}/status` every `poll_interval_seconds` (a wall-clock bound of `timeout_seconds`, reported through `timed_out`), correlates the transcript rows with the prompt's turn (a freshly initializing workspace reports idle until the agent actually starts, and startup events alone are not treated as done), and returns those rows with their visible agent text joined into `reply` (`truncated` is set when the turn exceeded the 1000 rows kept or its start was older than the rows read).<!-- END MANUAL -->### Inputs@@ -20,7 +20,7 @@ The block posts to `POST /v0/workspaces` with exactly one of `project_id` or `re| project_id | Project (repository) to open the workspace in. Find IDs with Get Account. Use this or repository_url, not both. | str | No || repository_url | Git repository URL to open instead of a project ID | str | No || message | Initial prompt for the agent. Leave empty to create an idle workspace. | str | No |-| branch | Branch to start from | str | No |+| base_branch | Branch the workspace branches from. Empty = Conductor project default, which may differ from the repository's PR target branch (for example a project that defaults to master while PRs go to dev). Set it explicitly for repos whose default is not the PR target, otherwise the PR inherits commits from the wrong base. | str | No || name | Workspace name | str | No || session_name | Name of the initial agent session | str | No || agent | Agent for the initial session | "claude" \| "codex" \| "cursor" \| "acp" | No |@@ -41,6 +41,7 @@ The block posts to `POST /v0/workspaces` with exactly one of `project_id` or `re| workspace_id | ID of the new workspace | str || session_id | ID of the initial session | str || deep_link | Link that opens the workspace | str |+| base_branch | Branch the workspace was asked to branch from, as sent to Conductor. Empty when Conductor's project default was used: the API does not report the resolved branch, so an empty value means the base is unknown. Verify this matches the PR target before opening a PR. | str || initial_message_id | ID of the initial prompt message, empty when none was sent | str || next_after | Transcript row ID of the prompt's row; pass it as `after` to Get Session to read the agent's turn. Falls back to initial_message_id while the prompt has no row yet, which Get Session also accepts | str || session_status | idle, working or error once waiting finished | str |diff --git a/docs/integrations/block-integrations/conductor/get_workspace.md b/docs/integrations/block-integrations/conductor/get_workspace.mdindex 2f4a6f6cbf..5f9c7ab7bf 100644--- a/docs/integrations/block-integrations/conductor/get_workspace.md+++ b/docs/integrations/block-integrations/conductor/get_workspace.md@@ -10,7 +10,7 @@ Get everything about one Conductor workspace: details, current status, shared pr### How it works<!-- MANUAL: how_it_works -->-The block calls `GET /v0/workspaces/{id}` and `GET /v0/workspaces/{id}/status`, then best-effort `GET /v0/workspaces/{id}/preview` and `GET /v0/workspaces/{id}/sessions` (a workspace that is still initializing may not serve those yet, in which case `preview_url` is empty and `sessions` is empty). The session listing is paged in requests of up to 100 rows until `session_limit` sessions have been collected starting at `session_offset`; `sessions_has_more` and `next_session_offset` let a graph read the following page. `status` is one of initializing, ready, sleeping, archived, deleted, updating or unstarted; `lifecycle_step` and `error_message` explain an initializing or failed workspace.+The block calls `GET /v0/workspaces/{id}` and `GET /v0/workspaces/{id}/status`, then best-effort `GET /v0/workspaces/{id}/preview` and `GET /v0/workspaces/{id}/sessions` (a workspace that is still initializing may not serve those yet, in which case `preview_url` is empty and `sessions` is empty). The session listing is paged in requests of up to 100 rows until `session_limit` sessions have been collected starting at `session_offset`; `sessions_has_more` and `next_session_offset` let a graph read the following page. `status` is one of initializing, ready, sleeping, archived, deleted, updating or unstarted; `lifecycle_step` and `error_message` explain an initializing or failed workspace. `base_branch` is filled from the workspace record when Conductor reports the branch it was cut from; the API currently omits it, so the output is empty and the `base_branch` output of Create Workspace is the record to keep.<!-- END MANUAL -->### Inputs@@ -37,6 +37,7 @@ The block calls `GET /v0/workspaces/{id}` and `GET /v0/workspaces/{id}/status`,| sessions_has_more | True when the workspace has more sessions than returned | bool || next_session_offset | session_offset to request the next page of sessions | int || deep_link | Link that opens the workspace | str |+| base_branch | Branch the workspace was created from, when Conductor reports it. The API currently omits it, so this is empty; keep the base_branch output of Create Workspace instead. Verify it matches the PR target before opening a PR. | str |### Possible use case<!-- MANUAL: use_case -->