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): return compact Conductor wait/poll output by default (#15107)
Abhimanyu Yadavd4b3b9915cdd
diff --git a/autogpt_platform/backend/backend/blocks/conductor/create_session.py b/autogpt_platform/backend/backend/blocks/conductor/create_session.pyindex 8ac01eb408..94ff4aa53e 100644--- a/autogpt_platform/backend/backend/blocks/conductor/create_session.py+++ b/autogpt_platform/backend/backend/blocks/conductor/create_session.py@@ -76,6 +76,12 @@ class ConductorCreateSessionBlock(Block):ge=1,le=300,)+ include_messages: bool = SchemaField(+ description="Also return the raw transcript rows of the turn in "+ "messages. Off by default: a long turn is hundreds of kilobytes, "+ "while reply, session_status and next_after cover the usual needs",+ default=False,+ )class Output(BlockSchemaOutput):session_id: str = SchemaField(description="ID of the new session")@@ -93,15 +99,19 @@ class ConductorCreateSessionBlock(Block):description="idle, working or error once waiting finished")reply: str = SchemaField(description="Text the agent produced in response")+ message_count: int = SchemaField(+ description="Number of transcript rows of the turn that were kept"+ )messages: list[dict] = SchemaField(- description="Raw transcript messages after the prompt"+ description="Raw transcript rows of the turn, oldest first; only "+ "emitted when include_messages is on")timed_out: bool = SchemaField(description="True when the wait ended before the agent went idle")truncated: bool = SchemaField(- description="True when the turn produced more messages than are "- "kept; messages holds the newest ones and reply may be incomplete"+ description="True when the turn produced more rows than are kept; "+ "the newest ones were kept and reply may be incomplete")error_message: str = SchemaField(description="Session error, if any")@@ -126,6 +136,7 @@ class ConductorCreateSessionBlock(Block):"workspace_id": "ws_1","message": "Run the tests","wait_for_reply": True,+ "include_messages": True,},],test_credentials=conductor.get_test_credentials(),@@ -140,6 +151,7 @@ class ConductorCreateSessionBlock(Block):("next_after", "row_1"),("session_status", "idle"),("reply", "All tests pass now."),+ ("message_count", 1),("messages", lambda m: len(m) == 1),("timed_out", False),("truncated", False),@@ -242,9 +254,12 @@ class ConductorCreateSessionBlock(Block):block_id=self.id,) from eyield "next_after", str(waited.get("prompt_row_id") or message_id)+ messages = list(waited.get("messages") or [])yield "session_status", waited["session_status"]yield "reply", waited["reply"]- yield "messages", waited["messages"]+ yield "message_count", len(messages)+ if input_data.include_messages:+ yield "messages", messagesyield "timed_out", waited["timed_out"]yield "truncated", bool(waited.get("truncated", False))yield "error_message", waited["error_message"]diff --git a/autogpt_platform/backend/backend/blocks/conductor/create_workspace.py b/autogpt_platform/backend/backend/blocks/conductor/create_workspace.pyindex 89ebbe5d5a..9fa4f576c7 100644--- a/autogpt_platform/backend/backend/blocks/conductor/create_workspace.py+++ b/autogpt_platform/backend/backend/blocks/conductor/create_workspace.py@@ -105,6 +105,12 @@ class ConductorCreateWorkspaceBlock(Block):ge=1,le=300,)+ include_messages: bool = SchemaField(+ description="Also return the raw transcript rows of the turn in "+ "messages. Off by default: a long turn is hundreds of kilobytes, "+ "while reply, session_status and next_after cover the usual needs",+ default=False,+ )@model_validator(mode="before")@classmethod@@ -144,15 +150,19 @@ class ConductorCreateWorkspaceBlock(Block):description="idle, working or error once waiting finished")reply: str = SchemaField(description="Text the agent produced in response")+ message_count: int = SchemaField(+ description="Number of transcript rows of the turn that were kept"+ )messages: list[dict] = SchemaField(- description="Raw transcript messages after the prompt"+ description="Raw transcript rows of the turn, oldest first; only "+ "emitted when include_messages is on")timed_out: bool = SchemaField(description="True when the wait ended before the agent went idle")truncated: bool = SchemaField(- description="True when the turn produced more messages than are "- "kept; messages holds the newest ones and reply may be incomplete"+ description="True when the turn produced more rows than are kept; "+ "the newest ones were kept and reply may be incomplete")error_message: str = SchemaField(description="Session error, if any")@@ -181,6 +191,7 @@ class ConductorCreateWorkspaceBlock(Block):"base_branch": "dev","message": "Fix the login bug","wait_for_reply": True,+ "include_messages": True,},],test_credentials=conductor.get_test_credentials(),@@ -199,6 +210,7 @@ class ConductorCreateWorkspaceBlock(Block):("next_after", "row_1"),("session_status", "idle"),("reply", "Done, the fix is on branch fix-login."),+ ("message_count", 1),("messages", lambda m: len(m) == 1),("timed_out", False),("truncated", False),@@ -350,9 +362,12 @@ class ConductorCreateWorkspaceBlock(Block):block_id=self.id,) from eyield "next_after", str(waited.get("prompt_row_id") or message_id)+ messages = list(waited.get("messages") or [])yield "session_status", waited["session_status"]yield "reply", waited["reply"]- yield "messages", waited["messages"]+ yield "message_count", len(messages)+ if input_data.include_messages:+ yield "messages", messagesyield "timed_out", waited["timed_out"]yield "truncated", bool(waited.get("truncated", False))yield "error_message", waited["error_message"]diff --git a/autogpt_platform/backend/backend/blocks/conductor/get_session.py b/autogpt_platform/backend/backend/blocks/conductor/get_session.pyindex d85aca2ee8..bd3bd2246f 100644--- a/autogpt_platform/backend/backend/blocks/conductor/get_session.py+++ b/autogpt_platform/backend/backend/blocks/conductor/get_session.py@@ -50,6 +50,12 @@ class ConductorGetSessionBlock(Block):"(not a prompt ID returned by Send Message)",default="",)+ include_messages: bool = SchemaField(+ description="Also return the raw transcript rows in messages. Off by "+ "default: status, latest_reply and next_after cover a poll loop "+ "without the rows, which can be hundreds of kilobytes",+ default=False,+ )class Output(BlockSchemaOutput):session: dict = SchemaField(@@ -58,16 +64,19 @@ class ConductorGetSessionBlock(Block):)status: str = SchemaField(description="idle, working or error")error_message: str = SchemaField(description="Last session error, if any")+ message_count: int = SchemaField(+ description="Number of transcript messages in the read slice"+ )messages: list[dict] = SchemaField(description="Transcript messages, oldest first: id, sessionIndex, "- "type, content, receivedAt"+ "type, content, receivedAt; only emitted when include_messages is on")latest_reply: str = SchemaField(description="Text of the newest agent message with visible text in "- "the returned transcript slice"+ "the read transcript slice")has_more: bool = SchemaField(- description="True when the transcript has messages beyond the returned "+ description="True when the transcript has messages beyond the read ""slice: older ones by default, newer ones when after is set")next_after: str = SchemaField(@@ -89,15 +98,31 @@ class ConductorGetSessionBlock(Block):effect=BlockEffect.READ,input_schema=self.Input,output_schema=self.Output,- test_input={- "credentials": conductor.get_test_credentials().model_dump(),- "session_id": "sess_1",- },+ test_input=[+ {+ "credentials": conductor.get_test_credentials().model_dump(),+ "session_id": "sess_1",+ },+ {+ "credentials": conductor.get_test_credentials().model_dump(),+ "session_id": "sess_1",+ "include_messages": True,+ },+ ],test_credentials=conductor.get_test_credentials(),test_output=[("session", lambda s: s["id"] == "sess_1"),("status", "idle"),("error_message", ""),+ ("message_count", 2),+ ("latest_reply", "All tests pass now."),+ ("has_more", False),+ ("next_after", "row_2"),+ ("deep_link", "conductor://s/1"),+ ("session", lambda s: s["id"] == "sess_1"),+ ("status", "idle"),+ ("error_message", ""),+ ("message_count", 2),("messages", lambda m: len(m) == 2),("latest_reply", "All tests pass now."),("has_more", False),@@ -168,7 +193,9 @@ class ConductorGetSessionBlock(Block):yield "error_message", str(status.get("errorMessage") or status.get("lastError") or "")- yield "messages", messages+ yield "message_count", len(messages)+ if input_data.include_messages:+ yield "messages", messagesyield "latest_reply", latest_reply(messages)yield "has_more", bool(listing.get("hasMore", False))cursor = str(data.get("cursor") or input_data.after)diff --git a/autogpt_platform/backend/backend/blocks/conductor/send_message.py b/autogpt_platform/backend/backend/blocks/conductor/send_message.pyindex a63c2a5ff7..abcb04637f 100644--- a/autogpt_platform/backend/backend/blocks/conductor/send_message.py+++ b/autogpt_platform/backend/backend/blocks/conductor/send_message.py@@ -47,6 +47,12 @@ class ConductorSendMessageBlock(Block):ge=1,le=300,)+ include_messages: bool = SchemaField(+ description="Also return the raw transcript rows of the turn in "+ "messages. Off by default: a long turn is hundreds of kilobytes, "+ "while reply, session_status and next_after cover the usual needs",+ default=False,+ )class Output(BlockSchemaOutput):message_id: str = SchemaField(description="ID of the sent prompt")@@ -62,15 +68,19 @@ class ConductorSendMessageBlock(Block):description="idle, working or error once waiting finished")reply: str = SchemaField(description="Text the agent produced in response")+ message_count: int = SchemaField(+ description="Number of transcript rows of the turn that were kept"+ )messages: list[dict] = SchemaField(- description="Raw transcript messages after the prompt"+ description="Raw transcript rows of the turn, oldest first; only "+ "emitted when include_messages is on")timed_out: bool = SchemaField(description="True when the wait ended before the agent went idle")truncated: bool = SchemaField(- description="True when the turn produced more messages than are "- "kept; messages holds the newest ones and reply may be incomplete"+ description="True when the turn produced more rows than are kept; "+ "the newest ones were kept and reply may be incomplete")error_message: str = SchemaField(description="Session error, if any")@@ -83,11 +93,19 @@ class ConductorSendMessageBlock(Block):effect=BlockEffect.EXTERNAL,input_schema=self.Input,output_schema=self.Output,- test_input={- "credentials": conductor.get_test_credentials().model_dump(),- "session_id": "sess_1",- "message": "Run the tests",- },+ test_input=[+ {+ "credentials": conductor.get_test_credentials().model_dump(),+ "session_id": "sess_1",+ "message": "Run the tests",+ },+ {+ "credentials": conductor.get_test_credentials().model_dump(),+ "session_id": "sess_1",+ "message": "Run the tests",+ "include_messages": True,+ },+ ],test_credentials=conductor.get_test_credentials(),test_output=[("message_id", "msg_1"),@@ -96,6 +114,17 @@ class ConductorSendMessageBlock(Block):("next_after", "row_1"),("session_status", "idle"),("reply", "All tests pass now."),+ ("message_count", 1),+ ("timed_out", False),+ ("truncated", False),+ ("error_message", ""),+ ("message_id", "msg_1"),+ ("state", "queued"),+ ("deep_link", "conductor://m/1"),+ ("next_after", "row_1"),+ ("session_status", "idle"),+ ("reply", "All tests pass now."),+ ("message_count", 1),("messages", lambda m: len(m) == 1),("timed_out", False),("truncated", False),@@ -193,9 +222,12 @@ class ConductorSendMessageBlock(Block):block_id=self.id,) from eyield "next_after", str(waited.get("prompt_row_id") or message_id)+ messages = list(waited.get("messages") or [])yield "session_status", waited["session_status"]yield "reply", waited["reply"]- yield "messages", waited["messages"]+ yield "message_count", len(messages)+ if input_data.include_messages:+ yield "messages", messagesyield "timed_out", waited["timed_out"]yield "truncated", bool(waited.get("truncated", False))yield "error_message", waited["error_message"]diff --git a/autogpt_platform/backend/backend/blocks/conductor/test_compact_outputs.py b/autogpt_platform/backend/backend/blocks/conductor/test_compact_outputs.pynew file mode 100644index 0000000000..2eba2c5e4f--- /dev/null+++ b/autogpt_platform/backend/backend/blocks/conductor/test_compact_outputs.py@@ -0,0 +1,266 @@+"""The wait/poll blocks answer compactly by default (SECRT-2790).++A turn's raw transcript rows run to hundreds of kilobytes, which pushed every+poll through the copilot's digest and a sandbox re-parse. The blocks now emit+`reply`/`latest_reply`, the status, `next_after` and a row count by default+and the raw rows only when `include_messages` is on.+"""++import json+from typing import Any+from unittest import mock++import pytest++from backend.blocks.conductor._transcript import reply_text+from backend.blocks.conductor.create_session import ConductorCreateSessionBlock+from backend.blocks.conductor.create_workspace import ConductorCreateWorkspaceBlock+from backend.blocks.conductor.get_session import ConductorGetSessionBlock+from backend.blocks.conductor.send_message import ConductorSendMessageBlock+from backend.blocks.conductor.test_fixtures import (+ CLAUDE_TOOL_USE,+ OLD_TURN,+ RECEIPT,+ TEST_CREDENTIALS_INPUT,+ FakeTranscript,+ agent_row,+ claude_text,+ claude_turn,+ collect,+ mock_block,+ user_row,+ wait_client,+ wait_clock,+)+from backend.copilot.tools.base import _DIGEST_THRESHOLD++COMPACT_WAIT_OUTPUTS = {+ "session_status",+ "reply",+ "next_after",+ "message_count",+ "timed_out",+ "truncated",+ "error_message",+}+++def long_turn(rows: int = 1000) -> list[dict[str, Any]]:+ """A prompt, mostly tool calls with occasional interim text, then the+ answer: the shape of a real coding-agent turn, long enough to fill the+ kept-row budget."""+ turn = [user_row("row-0", RECEIPT, 0)]+ for i in range(1, rows - 1):+ raw = claude_text(f"Step {i} of the work.") if i % 25 == 0 else CLAUDE_TOOL_USE+ turn.append(agent_row(f"row-{i}", RECEIPT, i, raw))+ turn.append(agent_row(f"row-{rows - 1}", RECEIPT, rows - 1, claude_text("Done.")))+ return turn+++def waited_with(rows: list[dict[str, Any]]) -> dict[str, Any]:+ return {+ "session_status": "idle",+ "error_message": "",+ "messages": rows,+ "reply": reply_text(rows),+ "timed_out": False,+ "truncated": False,+ "prompt_row_id": rows[0]["id"],+ }+++def serialized_size(outputs: dict[str, Any]) -> int:+ """Size of the outputs as the copilot's run_capability tool serialises a+ block result (each output name mapped to its list of values)."""+ return len(json.dumps({name: [value] for name, value in outputs.items()}))+++SENT = {"messageId": RECEIPT, "state": "sent", "deepLink": "conductor://m/1"}+CREATED_SESSION = {+ "id": "sess_1",+ "deepLink": "conductor://s/1",+ "initialMessage": SENT,+}+CREATED_WORKSPACE = {+ "workspaceId": "ws_1",+ "sessionId": "sess_1",+ "deepLink": "conductor://w/1",+ "initialMessage": SENT,+}+++def waiting_blocks(rows: list[dict[str, Any]]):+ waited = waited_with(rows)+ cases = [+ (+ ConductorSendMessageBlock(),+ {"_send": lambda *a, **k: SENT, "_wait": lambda *a, **k: waited},+ {"session_id": "s1", "message": "go"},+ ),+ (+ ConductorCreateSessionBlock(),+ {+ "_create": lambda *a, **k: CREATED_SESSION,+ "_wait": lambda *a, **k: waited,+ },+ {"workspace_id": "ws_1", "message": "go", "wait_for_reply": True},+ ),+ (+ ConductorCreateWorkspaceBlock(),+ {+ "_create": lambda *a, **k: CREATED_WORKSPACE,+ "_wait": lambda *a, **k: waited,+ },+ {+ "repository_url": "https://github.com/x/y",+ "message": "go",+ "wait_for_reply": True,+ },+ ),+ ]+ for block, mocks, inputs in cases:+ mock_block(block, mocks)+ yield block, {"credentials": TEST_CREDENTIALS_INPUT, **inputs}+++async def test_waiting_blocks_omit_raw_rows_by_default():+ rows = long_turn(5)+ for block, inputs in waiting_blocks(rows):+ outputs = await collect(block, inputs)++ assert "messages" not in outputs, type(block).__name__+ assert COMPACT_WAIT_OUTPUTS <= set(outputs), type(block).__name__+ assert outputs["reply"] == reply_text(rows)+ assert outputs["next_after"] == "row-0"+ assert outputs["message_count"] == 5+++async def test_waiting_blocks_return_raw_rows_on_request():+ rows = long_turn(5)+ for block, inputs in waiting_blocks(rows):+ outputs = await collect(block, {**inputs, "include_messages": True})++ assert outputs["messages"] == rows, type(block).__name__+ assert outputs["message_count"] == 5+++async def test_default_wait_outputs_stay_under_the_digest_threshold():+ rows = long_turn(1000)+ for block, inputs in waiting_blocks(rows):+ compact = await collect(block, inputs)+ raw = await collect(block, {**inputs, "include_messages": True})++ assert compact["reply"] == reply_text(rows), type(block).__name__+ assert serialized_size(compact) < _DIGEST_THRESHOLD, type(block).__name__+ assert serialized_size(raw) > _DIGEST_THRESHOLD, type(block).__name__+++def get_session_block(rows: list[dict[str, Any]]) -> ConductorGetSessionBlock:+ block = ConductorGetSessionBlock()+ mock_block(+ block,+ {+ "_fetch": lambda *a, **k: {+ "session": {"id": "sess_1", "deepLink": "conductor://s/1"},+ "status": {"status": "working"},+ "messages": {"data": rows, "hasMore": True},+ }+ },+ )+ return block+++async def test_get_session_omits_raw_rows_by_default():+ rows = long_turn(500)+ outputs = await collect(+ get_session_block(rows),+ {"credentials": TEST_CREDENTIALS_INPUT, "session_id": "s1"},+ )++ assert "messages" not in outputs+ assert outputs["status"] == "working"+ assert outputs["latest_reply"] == "Done."+ assert outputs["next_after"] == "row-499"+ assert outputs["message_count"] == 500+ assert outputs["has_more"] is True+ assert serialized_size(outputs) < _DIGEST_THRESHOLD+++async def test_get_session_returns_raw_rows_on_request():+ rows = long_turn(3)+ outputs = await collect(+ get_session_block(rows),+ {+ "credentials": TEST_CREDENTIALS_INPUT,+ "session_id": "s1",+ "include_messages": True,+ },+ )++ assert outputs["messages"] == rows+ assert outputs["message_count"] == 3+++async def test_wait_next_after_hands_off_to_get_session():+ """A compact wait result is enough to keep polling: its next_after,+ passed as Get Session's after, pages the turn from the prompt row with no+ receipt lookup and surfaces the turn's answer as latest_reply."""+ turn = claude_turn(RECEIPT, 2, "Done")+ rows = [+ user_row("row-old", OLD_TURN, 0),+ agent_row("row-old-reply", OLD_TURN, 1, claude_text("Earlier answer")),+ user_row("row-prompt", RECEIPT, 2),+ *turn,+ ]+ transcript = FakeTranscript(rows)+ sender = ConductorSendMessageBlock()+ mock_block(sender, {"_send": lambda *a, **k: SENT})+ with (+ mock.patch(+ "backend.blocks.conductor.send_message.ConductorClient",+ return_value=wait_client(transcript, [{"status": "idle"}]),+ ),+ wait_clock(),+ ):+ waited = await collect(+ sender,+ {+ "credentials": TEST_CREDENTIALS_INPUT,+ "session_id": "s1",+ "message": "go",+ },+ )++ assert "messages" not in waited+ assert waited["reply"].endswith("Done")+ assert waited["next_after"] == "row-prompt"++ transcript.calls.clear()+ session_client = mock.Mock()+ session_client.get_session = mock.AsyncMock(return_value={"id": "s1"})+ session_client.session_status = mock.AsyncMock(return_value={"status": "idle"})+ session_client.list_messages = transcript.list_messages+ with mock.patch(+ "backend.blocks.conductor.get_session.ConductorClient",+ return_value=session_client,+ ):+ polled = await collect(+ ConductorGetSessionBlock(),+ {+ "credentials": TEST_CREDENTIALS_INPUT,+ "session_id": "s1",+ "after": waited["next_after"],+ "message_limit": 20,+ },+ )++ assert polled["latest_reply"] == "Done"+ assert polled["message_count"] == len(turn)+ assert polled["next_after"] == turn[-1]["id"]+ assert transcript.calls == [{"after": "row-prompt", "limit": 20, "offset": None}]diff --git a/autogpt_platform/backend/backend/blocks/conductor/test_conductor.py b/autogpt_platform/backend/backend/blocks/conductor/test_conductor.pyindex 3165707110..e3302ab5fe 100644--- a/autogpt_platform/backend/backend/blocks/conductor/test_conductor.py+++ b/autogpt_platform/backend/backend/blocks/conductor/test_conductor.py@@ -262,6 +262,8 @@ async def test_send_message_surfaces_truncation():)assert outputs["truncated"] is Trueassert outputs["reply"] == "partial"+ assert outputs["next_after"] == "m1"+ assert outputs["message_count"] == 0@pytest.mark.asynciodiff --git a/autogpt_platform/backend/backend/blocks/conductor/test_listing_blocks.py b/autogpt_platform/backend/backend/blocks/conductor/test_listing_blocks.pyindex 304fa00fe7..29bc6e9a08 100644--- a/autogpt_platform/backend/backend/blocks/conductor/test_listing_blocks.py+++ b/autogpt_platform/backend/backend/blocks/conductor/test_listing_blocks.py@@ -61,6 +61,7 @@ async def test_get_session_returns_the_recent_tail_by_default():"credentials": TEST_CREDENTIALS_INPUT,"session_id": "s1","message_limit": 20,+ "include_messages": True,},)ids = [m["id"] for m in outputs["messages"]]@@ -83,7 +84,12 @@ async def test_get_session_short_transcript_needs_a_single_request():return_value=_session_client(transcript),):outputs = await collect(- block, {"credentials": TEST_CREDENTIALS_INPUT, "session_id": "s1"}+ block,+ {+ "credentials": TEST_CREDENTIALS_INPUT,+ "session_id": "s1",+ "include_messages": True,+ },)assert [m["id"] for m in outputs["messages"]] == [r["id"] for r in rows]assert outputs["latest_reply"] == "Done"@@ -107,6 +113,7 @@ async def test_get_session_after_reads_forward_from_the_cursor():"session_id": "s1","after": "r-tool","message_limit": 2,+ "include_messages": True,},)assert [m["id"] for m in outputs["messages"]] == ["r-progress", "r-result"]diff --git a/autogpt_platform/backend/backend/blocks/conductor/test_session_cursor.py b/autogpt_platform/backend/backend/blocks/conductor/test_session_cursor.pyindex eb218b5c81..83dddf63cb 100644--- a/autogpt_platform/backend/backend/blocks/conductor/test_session_cursor.py+++ b/autogpt_platform/backend/backend/blocks/conductor/test_session_cursor.py@@ -69,7 +69,9 @@ async def test_initial_message_id_works_as_the_after_cursor():turn = claude_turn(RECEIPT, 0, "Done")transcript = FakeTranscript([user_row(PROMPT_ROW, RECEIPT, 0), *turn])- outputs = await _get_session(transcript, after=RECEIPT, message_limit=20)+ outputs = await _get_session(+ transcript, after=RECEIPT, message_limit=20, include_messages=True+ )assert [m["id"] for m in outputs["messages"]] == [r["id"] for r in turn]assert outputs["latest_reply"] == "Done"@@ -87,7 +89,7 @@ async def test_after_receipt_with_no_reply_yet_returns_the_prompt_row_as_cursor([user_row("row-0", OLD_TURN, 0), user_row(PROMPT_ROW, RECEIPT, 1)])- outputs = await _get_session(transcript, after=RECEIPT)+ outputs = await _get_session(transcript, after=RECEIPT, include_messages=True)assert outputs["messages"] == []assert outputs["has_more"] is False@@ -107,7 +109,9 @@ async def test_after_receipt_is_found_beyond_the_newest_rows():]transcript = FakeTranscript(rows)- outputs = await _get_session(transcript, after=RECEIPT, message_limit=3)+ outputs = await _get_session(+ transcript, after=RECEIPT, message_limit=3, include_messages=True+ )assert [m["id"] for m in outputs["messages"]] == ["r-sys", "r-life", "r-think"]assert outputs["has_more"] is True@@ -119,7 +123,9 @@ async def test_a_row_id_cursor_is_paged_without_a_lookup():rows = [user_row(PROMPT_ROW, RECEIPT, 0), *claude_turn(RECEIPT, 0, "Done")]transcript = FakeTranscript(rows)- outputs = await _get_session(transcript, after=PROMPT_ROW, message_limit=2)+ outputs = await _get_session(+ transcript, after=PROMPT_ROW, message_limit=2, include_messages=True+ )assert [m["id"] for m in outputs["messages"]] == ["r-sys", "r-life"]assert transcript.calls == [{"after": PROMPT_ROW, "limit": 2, "offset": None}]@@ -162,6 +168,7 @@ async def test_incremental_poll_preserves_cursor_without_a_new_row_id(messages:"credentials": TEST_CREDENTIALS_INPUT,"session_id": "s1","after": "last-seen-row",+ "include_messages": True,},)diff --git a/autogpt_platform/backend/migrations/20261016120000_conductor_include_messages_for_wired_nodes/migration.sql b/autogpt_platform/backend/migrations/20261016120000_conductor_include_messages_for_wired_nodes/migration.sqlnew file mode 100644index 0000000000..b520b1e9c0--- /dev/null+++ b/autogpt_platform/backend/migrations/20261016120000_conductor_include_messages_for_wired_nodes/migration.sql@@ -0,0 +1,30 @@+-- The Conductor wait/poll blocks stopped emitting their raw `messages` rows by+-- default; a new `include_messages` input (default false) opts back in. Saved+-- graphs that already wire `messages` downstream predate that input, so their+-- nodes would resolve it to false and the downstream node would silently stop+-- running. Turn it on for exactly those nodes so they keep their behaviour.+--+-- A link's sourceName is either the pin itself or a dynamic sub-pin+-- (`messages_$_0`, `messages_#_key`, `messages_@_attr`). Nodes that already+-- carry an explicit `include_messages` are left alone.++UPDATE "AgentNode" AS n+SET "constantInput" = JSONB_SET(+ n."constantInput"::jsonb,+ '{include_messages}',+ 'true'::jsonb,+ true+ )+WHERE n."agentBlockId" IN (+ '4f22dbe5-2855-498a-ab82-6857441ea4b1', -- ConductorSendMessageBlock+ '3d4b2ccb-d654-4b5d-9750-e67f393f53f0', -- ConductorCreateSessionBlock+ 'd419c562-873c-4a67-b83f-9bcf11254f3f', -- ConductorCreateWorkspaceBlock+ 'fabe3db0-fb32-4b05-8e68-b169477b02ec' -- ConductorGetSessionBlock+ )+ AND NOT (n."constantInput"::jsonb ? 'include_messages')+ AND EXISTS (+ SELECT 1+ FROM "AgentNodeLink" AS l+ WHERE l."agentNodeSourceId" = n."id"+ AND l."sourceName" ~ '^messages(_[$#@]_.*)?$'+ );diff --git a/docs/integrations/block-integrations/conductor/create_session.md b/docs/integrations/block-integrations/conductor/create_session.mdindex 13fb474514..13515cc226 100644--- a/docs/integrations/block-integrations/conductor/create_session.md+++ b/docs/integrations/block-integrations/conductor/create_session.md@@ -10,7 +10,7 @@ Start a new agent session (chat) in an existing Conductor workspace, optionally### How it works<!-- MANUAL: how_it_works -->-The block posts to `POST /v0/sessions` with `workspaceId`, `agent` and any non-blank `model`, `effort`, `name` or `message`. When `message` is given the returned `initial_message_id` identifies the prompt and `next_after` is the prompt's transcript row ID to pass as `after` to Get Session (the receipt itself while the prompt is still queued, which Get Session also accepts); with `wait_for_reply` the block waits the same way as Send Message: it reads the transcript and then the session status on every poll (a wall-clock bound of `timeout_seconds`, reported through `timed_out`), correlates the rows with the prompt's turn, treats the session as done only once it is idle after the turn progressed past its startup events, and returns the rows in `messages` 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/sessions` with `workspaceId`, `agent` and any non-blank `model`, `effort`, `name` or `message`. When `message` is given the returned `initial_message_id` identifies the prompt and `next_after` is the prompt's transcript row ID to pass as `after` to Get Session (the receipt itself while the prompt is still queued, which Get Session also accepts); with `wait_for_reply` the block waits the same way as Send Message: it reads the transcript and then the session status on every poll (a wall-clock bound of `timeout_seconds`, reported through `timed_out`), correlates the rows with the prompt's turn, treats the session as done only once it is idle after the turn progressed past its startup events, and returns the visible agent text joined into `reply` and the kept-row `message_count` (`truncated` is set when the turn exceeded the 1000 rows kept or its start was older than the rows read). The raw rows are only returned, in `messages`, when `include_messages` is on.<!-- END MANUAL -->### Inputs@@ -27,6 +27,7 @@ The block posts to `POST /v0/sessions` with `workspaceId`, `agent` and any non-b| wait_for_reply | After sending the initial prompt, wait until the agent is idle and return its reply | bool | No || timeout_seconds | How long to wait for the reply | int | No || poll_interval_seconds | Seconds between status checks while waiting | int | No |+| include_messages | Also return the raw transcript rows of the turn in messages. Off by default: a long turn is hundreds of kilobytes, while reply, session_status and next_after cover the usual needs | bool | No |### Outputs@@ -39,9 +40,10 @@ The block posts to `POST /v0/sessions` with `workspaceId`, `agent` and any non-b| 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 || reply | Text the agent produced in response | str |-| messages | Raw transcript messages after the prompt | List[Dict[str, Any]] |+| message_count | Number of transcript rows of the turn that were kept | int |+| messages | Raw transcript rows of the turn, oldest first; only emitted when include_messages is on | List[Dict[str, Any]] || timed_out | True when the wait ended before the agent went idle | bool |-| truncated | True when the turn produced more messages than are kept; messages holds the newest ones and reply may be incomplete | bool |+| truncated | True when the turn produced more rows than are kept; the newest ones were kept and reply may be incomplete | bool || error_message | Session error, if any | str |### Possible use casediff --git a/docs/integrations/block-integrations/conductor/create_workspace.md b/docs/integrations/block-integrations/conductor/create_workspace.mdindex 9a240b5d66..3eb7449584 100644--- a/docs/integrations/block-integrations/conductor/create_workspace.md+++ b/docs/integrations/block-integrations/conductor/create_workspace.md@@ -10,7 +10,7 @@ Create a Conductor cloud workspace for a project or repository, optionally start### 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. `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).+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 the visible agent text joined into `reply` and the kept-row `message_count` (`truncated` is set when the turn exceeded the 1000 rows kept or its start was older than the rows read). The raw rows are only returned, in `messages`, when `include_messages` is on.<!-- END MANUAL -->### Inputs@@ -32,6 +32,7 @@ The block posts to `POST /v0/workspaces` with exactly one of `project_id` or `re| wait_for_reply | After sending the initial prompt, wait until the agent is idle and return its reply | bool | No || timeout_seconds | How long to wait for the reply | int | No || poll_interval_seconds | Seconds between status checks while waiting | int | No |+| include_messages | Also return the raw transcript rows of the turn in messages. Off by default: a long turn is hundreds of kilobytes, while reply, session_status and next_after cover the usual needs | bool | No |### Outputs@@ -46,9 +47,10 @@ The block posts to `POST /v0/workspaces` with exactly one of `project_id` or `re| 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 || reply | Text the agent produced in response | str |-| messages | Raw transcript messages after the prompt | List[Dict[str, Any]] |+| message_count | Number of transcript rows of the turn that were kept | int |+| messages | Raw transcript rows of the turn, oldest first; only emitted when include_messages is on | List[Dict[str, Any]] || timed_out | True when the wait ended before the agent went idle | bool |-| truncated | True when the turn produced more messages than are kept; messages holds the newest ones and reply may be incomplete | bool |+| truncated | True when the turn produced more rows than are kept; the newest ones were kept and reply may be incomplete | bool || error_message | Session error, if any | str |### Possible use casediff --git a/docs/integrations/block-integrations/conductor/get_session.md b/docs/integrations/block-integrations/conductor/get_session.mdindex 8e207342db..a86d0d6172 100644--- a/docs/integrations/block-integrations/conductor/get_session.md+++ b/docs/integrations/block-integrations/conductor/get_session.md@@ -10,7 +10,7 @@ Get a Conductor agent session: its details, whether the agent is idle, working o### How it works<!-- MANUAL: how_it_works -->-The block calls `GET /v0/sessions/{id}` and `GET /v0/sessions/{id}/status`, then reads the transcript through `GET /v0/sessions/{id}/messages`. The API only pages from the start in ascending order (100 rows per request at most), so by default the block locates the end of the transcript with cheap one-row probes and returns the newest `message_limit` messages; with `after` it instead reads the next `message_limit` messages following that message, which is how to poll incrementally (`next_after` is the row ID to pass on the next call). `after` takes a transcript row ID, such as `next_after` from Send Message, Create Session, Create Workspace or a previous Get Session call; the prompt ID those blocks return as `message_id` / `initial_message_id` is a different namespace that the API rejects with 404, so when it is passed the block locates the prompt's row itself (newest 300 rows, then up to 1000 older ones) and pages from there, reporting that row ID through `next_after` when nothing follows it yet. `has_more` reports whether older (default) or newer (`after`) messages exist beyond the slice; set `message_limit` to 0 to skip the transcript. `latest_reply` is the newest message with visible agent text, so trailing tool, lifecycle or status events do not hide the answer. Live rows are `userMessage` prompts and `agent` events wrapping the harness's raw payload; only Claude `assistant` text parts and completed Codex `agentMessage` items count as visible text. Pass `message_id` to also fetch one message via `GET /v0/messages/{id}` (a transcript row ID, not a send receipt).+The block calls `GET /v0/sessions/{id}` and `GET /v0/sessions/{id}/status`, then reads the transcript through `GET /v0/sessions/{id}/messages`. The API only pages from the start in ascending order (100 rows per request at most), so by default the block locates the end of the transcript with cheap one-row probes and returns the newest `message_limit` messages; with `after` it instead reads the next `message_limit` messages following that message, which is how to poll incrementally (`next_after` is the row ID to pass on the next call). `after` takes a transcript row ID, such as `next_after` from Send Message, Create Session, Create Workspace or a previous Get Session call; the prompt ID those blocks return as `message_id` / `initial_message_id` is a different namespace that the API rejects with 404, so when it is passed the block locates the prompt's row itself (newest 300 rows, then up to 1000 older ones) and pages from there, reporting that row ID through `next_after` when nothing follows it yet. `has_more` reports whether older (default) or newer (`after`) messages exist beyond the slice; set `message_limit` to 0 to skip the transcript. `latest_reply` is the newest message with visible agent text, so trailing tool, lifecycle or status events do not hide the answer. The raw rows are only returned, in `messages`, when `include_messages` is on; by default `message_count` reports how many were read. Live rows are `userMessage` prompts and `agent` events wrapping the harness's raw payload; only Claude `assistant` text parts and completed Codex `agentMessage` items count as visible text. Pass `message_id` to also fetch one message via `GET /v0/messages/{id}` (a transcript row ID, not a send receipt).<!-- END MANUAL -->### Inputs@@ -21,6 +21,7 @@ The block calls `GET /v0/sessions/{id}` and `GET /v0/sessions/{id}/status`, then| message_limit | How many transcript messages to return: the most recent ones, or the ones following `after` when it is set; 0 skips the transcript | int | No || after | Read forward from this message (exclusive) instead of returning the most recent messages. Accepts a transcript row ID (next_after from a previous call or from Send Message / Create Session) or the prompt ID those blocks return as message_id / initial_message_id, which is resolved to the prompt's row | str | No || message_id | Also fetch this single message by its transcript row ID (not a prompt ID returned by Send Message) | str | No |+| include_messages | Also return the raw transcript rows in messages. Off by default: status, latest_reply and next_after cover a poll loop without the rows, which can be hundreds of kilobytes | bool | No |### Outputs@@ -30,9 +31,10 @@ The block calls `GET /v0/sessions/{id}` and `GET /v0/sessions/{id}/status`, then| session | Session: id, name, model, resolvedModel, effort, fastMode, deepLink, archivedAt | Dict[str, Any] || status | idle, working or error | str || error_message | Last session error, if any | str |-| messages | Transcript messages, oldest first: id, sessionIndex, type, content, receivedAt | List[Dict[str, Any]] |-| latest_reply | Text of the newest agent message with visible text in the returned transcript slice | str |-| has_more | True when the transcript has messages beyond the returned slice: older ones by default, newer ones when after is set | bool |+| message_count | Number of transcript messages in the read slice | int |+| messages | Transcript messages, oldest first: id, sessionIndex, type, content, receivedAt; only emitted when include_messages is on | List[Dict[str, Any]] |+| latest_reply | Text of the newest agent message with visible text in the read transcript slice | str |+| has_more | True when the transcript has messages beyond the read slice: older ones by default, newer ones when after is set | bool || next_after | Transcript row ID of the last returned message (or the row `after` resolved to when nothing followed it); pass it as after to read what follows | str || message | The single message requested by message_id | Dict[str, Any] || deep_link | Link that opens the session | str |diff --git a/docs/integrations/block-integrations/conductor/send_message.md b/docs/integrations/block-integrations/conductor/send_message.mdindex ef8cb612ae..41421c1c2d 100644--- a/docs/integrations/block-integrations/conductor/send_message.md+++ b/docs/integrations/block-integrations/conductor/send_message.md@@ -10,7 +10,7 @@ Send a prompt to a Conductor agent session and, by default, wait for the agent t### How it works<!-- MANUAL: how_it_works -->-The block posts `{message}` to `POST /v0/sessions/{id}/messages` and returns the receipt (`message_id`, `state` queued or sent, `deep_link`). With `wait_for_reply` (the default) it then polls every `poll_interval_seconds`: each poll reads the transcript rows that arrived since the previous one and then `GET /v0/sessions/{id}/status`, so the status is never older than the rows it is judged against. The receipt ID is the prompt's `content.id` in the transcript, not its row ID, and the API only accepts row IDs as `after` cursors; the block looks for that row among the newest 300 rows, then in up to 1000 older rows, and otherwise resolves the turn from agent rows tagged with the receipt as their `turnId`, reporting the omitted history through `truncated`. Either way it returns the prompt row's ID as `next_after`, ready to pass to Get Session's `after` (without `wait_for_reply` it checks the newest rows once; while the prompt is still queued and has no row, `next_after` is the receipt itself, which Get Session also resolves). It finishes when the session reports `error`, or `idle` after the turn has progressed past its startup events (Claude `system`/`command_lifecycle`, Codex `thread.started`/`turn.started`), reading the transcript once more for rows written just before the status changed; a session that is idle because the prompt is still queued, or has only launched the agent, is not treated as finished. `reply` joins the visible agent text of the turn (Claude `assistant` text, completed Codex `agentMessage` items); `messages` has the raw rows of the turn, newest kept when a turn exceeds 1000 rows (`truncated` is set). `timeout_seconds` is a wall-clock bound: sleeps and requests are capped by it, nothing is requested once it has elapsed, and when it elapses `timed_out` is set and whatever arrived so far is returned. The block's own execution cap is two hours, so `timeout_seconds` is limited to that.+The block posts `{message}` to `POST /v0/sessions/{id}/messages` and returns the receipt (`message_id`, `state` queued or sent, `deep_link`). With `wait_for_reply` (the default) it then polls every `poll_interval_seconds`: each poll reads the transcript rows that arrived since the previous one and then `GET /v0/sessions/{id}/status`, so the status is never older than the rows it is judged against. The receipt ID is the prompt's `content.id` in the transcript, not its row ID, and the API only accepts row IDs as `after` cursors; the block looks for that row among the newest 300 rows, then in up to 1000 older rows, and otherwise resolves the turn from agent rows tagged with the receipt as their `turnId`, reporting the omitted history through `truncated`. Either way it returns the prompt row's ID as `next_after`, ready to pass to Get Session's `after` (without `wait_for_reply` it checks the newest rows once; while the prompt is still queued and has no row, `next_after` is the receipt itself, which Get Session also resolves). It finishes when the session reports `error`, or `idle` after the turn has progressed past its startup events (Claude `system`/`command_lifecycle`, Codex `thread.started`/`turn.started`), reading the transcript once more for rows written just before the status changed; a session that is idle because the prompt is still queued, or has only launched the agent, is not treated as finished. `reply` joins the visible agent text of the turn (Claude `assistant` text, completed Codex `agentMessage` items) and `message_count` is the number of rows of the turn that were kept (the newest 1000 when a turn is longer; `truncated` is set). The raw rows are only returned, in `messages`, when `include_messages` is on. `timeout_seconds` is a wall-clock bound: sleeps and requests are capped by it, nothing is requested once it has elapsed, and when it elapses `timed_out` is set and whatever arrived so far is returned. The block's own execution cap is two hours, so `timeout_seconds` is limited to that.<!-- END MANUAL -->### Inputs@@ -22,6 +22,7 @@ The block posts `{message}` to `POST /v0/sessions/{id}/messages` and returns the| wait_for_reply | Wait until the agent is idle and return its reply | bool | No || timeout_seconds | How long to wait for the reply | int | No || poll_interval_seconds | Seconds between status checks while waiting | int | No |+| include_messages | Also return the raw transcript rows of the turn in messages. Off by default: a long turn is hundreds of kilobytes, while reply, session_status and next_after cover the usual needs | bool | No |### Outputs@@ -34,9 +35,10 @@ The block posts `{message}` to `POST /v0/sessions/{id}/messages` and returns the| 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 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 || reply | Text the agent produced in response | str |-| messages | Raw transcript messages after the prompt | List[Dict[str, Any]] |+| message_count | Number of transcript rows of the turn that were kept | int |+| messages | Raw transcript rows of the turn, oldest first; only emitted when include_messages is on | List[Dict[str, Any]] || timed_out | True when the wait ended before the agent went idle | bool |-| truncated | True when the turn produced more messages than are kept; messages holds the newest ones and reply may be incomplete | bool |+| truncated | True when the turn produced more rows than are kept; the newest ones were kept and reply may be incomplete | bool || error_message | Session error, if any | str |### Possible use case