Skip to content

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(backend): surface sub-agent workspace files in run_sub_session result (#13381)

Abhimanyu Yadav55e4d9b635e1
diff --git a/autogpt_platform/backend/backend/copilot/tools/get_sub_session_result.py b/autogpt_platform/backend/backend/copilot/tools/get_sub_session_result.py
index 1b85c4f22f..70044640c0 100644
--- a/autogpt_platform/backend/backend/copilot/tools/get_sub_session_result.py
+++ b/autogpt_platform/backend/backend/copilot/tools/get_sub_session_result.py
@@ -42,6 +42,7 @@ from .models import (
from .run_sub_session import (
MAX_SUB_SESSION_WAIT_SECONDS,
_sub_session_link,
+ list_sub_workspace_files,
response_from_outcome,
)
@@ -215,12 +216,22 @@ class GetSubSessionResultTool(BaseTool):
progress=progress,
)
+ # On completion, read the authoritative workspace-file manifest from the
+ # sub's session. This covers the cold-poll / already-terminal path where
+ # ``result.tool_calls`` reflects only the last persisted message and so
+ # would miss files the sub wrote in earlier turns (SECRT-2377).
+ workspace_files = (
+ await list_sub_workspace_files(user_id, inner_session_id)
+ if outcome == "completed"
+ else None
+ )
return response_from_outcome(
outcome=outcome,
result=result,
inner_session_id=inner_session_id,
parent_session_id=session.session_id,
elapsed=elapsed,
+ workspace_files=workspace_files,
)
diff --git a/autogpt_platform/backend/backend/copilot/tools/models.py b/autogpt_platform/backend/backend/copilot/tools/models.py
index 9b6790d0bf..e0a47acaf5 100644
--- a/autogpt_platform/backend/backend/copilot/tools/models.py
+++ b/autogpt_platform/backend/backend/copilot/tools/models.py
@@ -343,6 +343,23 @@ class SubSessionProgressSnapshot(BaseModel):
)
+class WorkspaceFileInfoData(BaseModel):
+ """Workspace file metadata (not a response itself).
+
+ Shared by ``list_workspace_files`` and the ``sub_workspace_files`` manifest
+ on :class:`SubSessionStatusResponse` (SECRT-2377). When it describes a file a
+ sub-AutoPilot wrote, ``path`` is already session-qualified
+ (``/sessions/<sub_id>/...``) and can be passed straight to
+ ``read_workspace_file(path=...)`` for cross-session retrieval.
+ """
+
+ file_id: str
+ name: str
+ path: str
+ mime_type: str
+ size_bytes: int
+
+
class SubSessionStatusResponse(ToolResponseBase):
"""Status / result of a sub-AutoPilot run started by ``run_sub_session``.
@@ -390,6 +407,16 @@ class SubSessionStatusResponse(ToolResponseBase):
default=None,
description="Tool calls made during the sub-AutoPilot run.",
)
+ sub_workspace_files: list[WorkspaceFileInfoData] | None = Field(
+ default=None,
+ description=(
+ "Persistent workspace files the sub wrote during the run. "
+ "Populated when status=completed and the sub used "
+ "write_workspace_file — lets the parent recover work delivered "
+ "via files rather than inline text. Read each via "
+ "read_workspace_file(path=<read_path>)."
+ ),
+ )
error: str | None = Field(
default=None,
description="Error message when status=error.",
diff --git a/autogpt_platform/backend/backend/copilot/tools/run_sub_session.py b/autogpt_platform/backend/backend/copilot/tools/run_sub_session.py
index f0c2015dcc..f0d7400cc4 100644
--- a/autogpt_platform/backend/backend/copilot/tools/run_sub_session.py
+++ b/autogpt_platform/backend/backend/copilot/tools/run_sub_session.py
@@ -23,22 +23,29 @@ copilot turn routed through the same queue and event bus as every
other turn.
"""
+import json
import logging
import time
from typing import Any
from backend.copilot.active_turns import running_turn_limit_message
from backend.copilot.constants import MAX_TOOL_WAIT_SECONDS
-from backend.copilot.context import get_current_permissions
+from backend.copilot.context import get_current_permissions, get_workspace_manager
from backend.copilot.model import ChatSession, create_chat_session, get_chat_session
from backend.copilot.sdk.session_waiter import (
SessionOutcome,
SessionResult,
run_copilot_turn_via_queue,
)
+from backend.copilot.sdk.stream_accumulator import ToolCallEntry
from .base import BaseTool
-from .models import ErrorResponse, SubSessionStatusResponse, ToolResponseBase
+from .models import (
+ ErrorResponse,
+ SubSessionStatusResponse,
+ ToolResponseBase,
+ WorkspaceFileInfoData,
+)
logger = logging.getLogger(__name__)
@@ -48,6 +55,10 @@ logger = logging.getLogger(__name__)
# 2x headroom holds uniformly.
MAX_SUB_SESSION_WAIT_SECONDS = MAX_TOOL_WAIT_SECONDS
+# Cap on how many sub-written files we enumerate in a completed response's
+# manifest. Bounds context size; a sub producing more than this is pathological.
+_WORKSPACE_FILE_MANIFEST_LIMIT = 50
+
class RunSubSessionTool(BaseTool):
"""Delegate a task to a fresh sub-AutoPilot via the copilot_executor queue."""
@@ -161,12 +172,18 @@ class RunSubSessionTool(BaseTool):
tool_name="run_sub_session",
)
elapsed = time.monotonic() - started_at
+ workspace_files = (
+ await list_sub_workspace_files(user_id, inner_session_id)
+ if outcome == "completed"
+ else None
+ )
return response_from_outcome(
outcome=outcome,
result=result,
inner_session_id=inner_session_id,
parent_session_id=session.session_id,
elapsed=elapsed,
+ workspace_files=workspace_files,
)
@@ -182,6 +199,115 @@ def _sub_session_link(inner_session_id: str | None) -> str | None:
return f"/copilot?sessionId={inner_session_id}"
+async def list_sub_workspace_files(
+ user_id: str,
+ inner_session_id: str,
+) -> list[WorkspaceFileInfoData] | None:
+ """Authoritative manifest of the persistent files a sub wrote, read from
+ the sub's session workspace.
+
+ A sub may deliver its real output by writing workspace files and only
+ summarising in its final message (SECRT-2377). This queries the sub's
+ session for ``agent-created`` files directly, so it captures writes from
+ *any* turn — including ones absent from the current turn's tool-call log
+ (e.g. the cold-poll / already-terminal path in ``get_sub_session_result``).
+
+ The ``origin=agent-created`` filter means only files the sub persisted via
+ ``write_workspace_file`` are listed — transient working-directory artefacts
+ (e.g. a ``git clone`` the sub inspects but never persists) are not workspace
+ files and never appear here. When the sub persists more than
+ ``_WORKSPACE_FILE_MANIFEST_LIMIT`` files, the most recently written ones win
+ (the listing is ordered ``createdAt`` descending).
+
+ Returns ``None`` on lookup failure so callers can fall back to mining the
+ tool-call log; an empty list means the sub genuinely wrote nothing.
+ """
+ try:
+ manager = await get_workspace_manager(user_id, inner_session_id)
+ files = await manager.list_files(
+ limit=_WORKSPACE_FILE_MANIFEST_LIMIT,
+ metadata_equals={"origin": "agent-created"},
+ )
+ except Exception:
+ logger.warning(
+ f"Failed to list workspace files for sub {inner_session_id[:12]}",
+ exc_info=True,
+ )
+ return None
+ return [
+ WorkspaceFileInfoData(
+ file_id=f.id,
+ name=f.name,
+ path=f.path,
+ mime_type=f.mime_type,
+ size_bytes=f.size_bytes,
+ )
+ for f in files
+ ]
+
+
+def _workspace_files_from_tool_calls(
+ tool_calls: list[ToolCallEntry],
+) -> list[WorkspaceFileInfoData]:
+ """Mine the files a sub wrote from its tool-call log — the cheap fallback
+ when the authoritative workspace listing is unavailable.
+
+ ``write_workspace_file`` outputs already carry the fully session-qualified
+ ``path`` (the workspace manager resolves it on write), so it is directly
+ usable with ``read_workspace_file``. The output is an opaque
+ ``WorkspaceWriteResponse`` payload — a JSON string on the live-drain path,
+ a dict on the persisted-replay path — so we parse defensively and skip
+ anything that doesn't carry the fields we need.
+ """
+ files: list[WorkspaceFileInfoData] = []
+ seen_ids: set[str] = set()
+ for tc in tool_calls:
+ if tc.tool_name != "write_workspace_file" or tc.success is False:
+ continue
+ payload = _as_payload(tc.output)
+ if payload is None:
+ continue
+ file_id = payload.get("file_id")
+ path = payload.get("path")
+ if not file_id or not path or file_id in seen_ids:
+ continue
+ seen_ids.add(file_id)
+ files.append(
+ WorkspaceFileInfoData(
+ file_id=file_id,
+ name=payload.get("name") or path.rsplit("/", 1)[-1],
+ path=path,
+ mime_type=payload.get("mime_type") or "",
+ size_bytes=_coerce_size_bytes(payload.get("size_bytes")),
+ )
+ )
+ return files
+
+
+def _coerce_size_bytes(raw: Any) -> int:
+ """Coerce a mined ``size_bytes`` to a non-negative int — the payload is
+ untrusted (JSON parsed from the tool log), so a missing, malformed, or
+ negative value must not surface as invalid size data."""
+ try:
+ return max(0, int(raw or 0))
+ except (TypeError, ValueError):
+ return 0
+
+
+def _as_payload(output: Any) -> dict[str, Any] | None:
+ """Coerce a tool-call ``output`` (JSON string or dict) into a dict, or
+ ``None`` when it isn't a usable object."""
+ if isinstance(output, dict):
+ return output
+ if isinstance(output, str):
+ try:
+ parsed = json.loads(output)
+ except (json.JSONDecodeError, ValueError):
+ return None
+ return parsed if isinstance(parsed, dict) else None
+ return None
+
+
def response_from_outcome(
*,
outcome: SessionOutcome,
@@ -189,11 +315,16 @@ def response_from_outcome(
inner_session_id: str,
parent_session_id: str | None,
elapsed: float,
+ workspace_files: list[WorkspaceFileInfoData] | None = None,
) -> SubSessionStatusResponse:
"""Translate a ``(SessionOutcome, SessionResult)`` tuple into the
``SubSessionStatusResponse`` contract the LLM sees.
- ``completed`` surfaces the aggregated response text + tool calls.
+ ``completed`` surfaces the aggregated response text + tool calls, plus a
+ manifest of any workspace files the sub wrote (SECRT-2377). Pass
+ ``workspace_files`` to supply the authoritative listing from the sub's
+ session; when omitted, the files are mined from ``result.tool_calls`` as a
+ fallback.
``failed`` returns the error marker with the same handles.
``running`` returns just the polling handles so the agent can resume.
``queued`` means the target session already had a turn in flight; the
@@ -260,9 +391,21 @@ def response_from_outcome(
elapsed_seconds=round(elapsed, 2),
)
- # completed
+ # completed — prefer the authoritative listing supplied by the caller;
+ # fall back to mining the tool-call log when it's unavailable.
+ if workspace_files is None:
+ workspace_files = _workspace_files_from_tool_calls(result.tool_calls)
+ message = f"Sub-AutoPilot completed.{f' View at {link}.' if link else ''}"
+ if workspace_files:
+ # The sub may have put its real output in files and only summarised in
+ # `response`. Flag the files explicitly so the parent reads them rather
+ # than treating the run as empty (SECRT-2377).
+ message += (
+ f" It wrote {len(workspace_files)} workspace file(s); read them via "
+ "read_workspace_file(path=<read_path>) — see sub_workspace_files."
+ )
return SubSessionStatusResponse(
- message=f"Sub-AutoPilot completed.{f' View at {link}.' if link else ''}",
+ message=message,
session_id=parent_session_id,
status="completed",
sub_session_id=inner_session_id,
@@ -270,5 +413,6 @@ def response_from_outcome(
sub_autopilot_session_link=link,
response=result.response_text,
tool_calls=[tc.model_dump() for tc in result.tool_calls],
+ sub_workspace_files=workspace_files or None,
elapsed_seconds=round(elapsed, 2),
)
diff --git a/autogpt_platform/backend/backend/copilot/tools/sub_session_test.py b/autogpt_platform/backend/backend/copilot/tools/sub_session_test.py
index 4d62ad0c22..1b08d2e0a5 100644
--- a/autogpt_platform/backend/backend/copilot/tools/sub_session_test.py
+++ b/autogpt_platform/backend/backend/copilot/tools/sub_session_test.py
@@ -10,13 +10,22 @@ tests patch the three integration seams — ``enqueue_copilot_turn``,
from __future__ import annotations
+import json
from unittest.mock import AsyncMock, MagicMock
import pytest
+from backend.copilot.permissions import CopilotPermissions
+from backend.copilot.sdk.session_waiter import SessionResult
+from backend.copilot.sdk.stream_accumulator import ToolCallEntry
+
from .get_sub_session_result import GetSubSessionResultTool
-from .models import ErrorResponse, SubSessionStatusResponse
-from .run_sub_session import MAX_SUB_SESSION_WAIT_SECONDS, RunSubSessionTool
+from .models import ErrorResponse, SubSessionStatusResponse, WorkspaceFileInfoData
+from .run_sub_session import (
+ MAX_SUB_SESSION_WAIT_SECONDS,
+ RunSubSessionTool,
+ response_from_outcome,
+)
def _session(user_id: str = "u", session_id: str = "s1") -> MagicMock:
@@ -73,7 +82,6 @@ def mock_waiter(monkeypatch):
``run_copilot_turn_via_queue`` mock (used by run_sub_session) and
the ``wait_for_session_result`` mock (used by get_sub_session_result)
wired to return ``("running", SessionResult())`` by default."""
- from backend.copilot.sdk.session_waiter import SessionResult
turn_mock = AsyncMock(return_value=("running", SessionResult()))
result_mock = AsyncMock(return_value=("running", SessionResult()))
@@ -90,6 +98,27 @@ def mock_waiter(monkeypatch):
return turn_mock
[email protected](autouse=True)
+def stub_workspace_listing(monkeypatch):
+ """Stub the authoritative sub workspace-file listing for every test.
+
+ Default return is ``None`` so completed paths fall back to tool-call mining
+ and never touch the workspace DB. Tests that exercise the listing override
+ ``return_value``. A single mock backs both tool-module bindings so an
+ override applies wherever the listing is read.
+ """
+ listing = AsyncMock(return_value=None)
+ monkeypatch.setattr(
+ "backend.copilot.tools.run_sub_session.list_sub_workspace_files",
+ listing,
+ )
+ monkeypatch.setattr(
+ "backend.copilot.tools.get_sub_session_result.list_sub_workspace_files",
+ listing,
+ )
+ return listing
+
+
@pytest.fixture
def mock_model(monkeypatch):
"""Patch the model-layer helpers the tools call for session CRUD +
@@ -192,7 +221,6 @@ class TestRunSubSession:
):
"""The parent's CopilotPermissions must be passed through to the
queue primitive so the worker applies the same filter."""
- from backend.copilot.permissions import CopilotPermissions
perms = CopilotPermissions(tools=["run_block"], tools_exclude=False)
monkeypatch.setattr(
@@ -235,8 +263,6 @@ class TestRunSubSession:
"""When the queue primitive returns 'completed' + a SessionResult,
the tool surfaces response_text + tool_calls directly — no DB
round-trip needed for the content."""
- from backend.copilot.sdk.session_waiter import SessionResult
- from backend.copilot.sdk.stream_accumulator import ToolCallEntry
res = SessionResult()
res.response_text = "the answer"
@@ -264,6 +290,39 @@ class TestRunSubSession:
assert r.tool_calls[0]["tool_name"] == "foo"
mock_waiter.assert_awaited_once()
+ @pytest.mark.asyncio
+ async def test_completed_surfaces_workspace_file_manifest(
+ self, mock_queue, mock_waiter, mock_model, stub_workspace_listing
+ ):
+ """On completion run_sub_session reads the authoritative workspace
+ listing for the sub and surfaces it as sub_workspace_files."""
+
+ res = SessionResult()
+ res.response_text = "delivered in the docs, what's next?"
+ mock_waiter.return_value = ("completed", res)
+ stub_workspace_listing.return_value = [
+ WorkspaceFileInfoData(
+ file_id="file-1",
+ name="PLAN.md",
+ path="/sessions/inner-1/PLAN.md",
+ mime_type="text/markdown",
+ size_bytes=14563,
+ )
+ ]
+
+ r = await RunSubSessionTool()._execute(
+ user_id="alice",
+ session=_session("alice"),
+ prompt="audit the platform",
+ wait_for_result=60,
+ )
+ assert isinstance(r, SubSessionStatusResponse)
+ assert r.status == "completed"
+ stub_workspace_listing.assert_awaited_once_with("alice", "inner-1")
+ assert r.sub_workspace_files is not None
+ assert r.sub_workspace_files[0].path == "/sessions/inner-1/PLAN.md"
+ assert "workspace file" in (r.message or "")
+
@pytest.mark.asyncio
async def test_queued_outcome_surfaces_queued_status(
self, mock_queue, mock_waiter, mock_model
@@ -271,7 +330,6 @@ class TestRunSubSession:
"""When the shared primitive reports the target session already has
a turn running, the tool surfaces ``status='queued'`` so the LLM can
decide whether to poll or move on."""
- from backend.copilot.sdk.session_waiter import SessionResult
queued_res = SessionResult(queued=True, pending_buffer_length=2)
mock_waiter.return_value = ("queued", queued_res)
@@ -380,7 +438,6 @@ class TestGetSubSessionResult:
@pytest.mark.asyncio
async def test_wait_returns_completed_with_response(self, monkeypatch, mock_waiter):
"""'completed' outcome surfaces the SessionResult directly."""
- from backend.copilot.sdk.session_waiter import SessionResult
sub = MagicMock(user_id="alice", messages=[]) # not terminal-looking
@@ -524,3 +581,190 @@ class TestGetSubSessionResult:
assert r.status == "cancelled"
mock_queue["enqueue_cancel"].assert_awaited_once_with("inner-5")
mock_waiter.result_mock.assert_not_awaited()
+
+ @pytest.mark.asyncio
+ async def test_terminal_path_surfaces_files_from_listing(
+ self, monkeypatch, mock_waiter, stub_workspace_listing
+ ):
+ """SECRT-2377 terminal-path fix: when the sub already finished (cold
+ poll, last message terminal) the waiter is skipped and the tool-call
+ log only holds the last message — yet the file manifest is still
+ populated from the authoritative workspace listing."""
+
+ sub = MagicMock(user_id="alice")
+ assistant = MagicMock()
+ assistant.role = "assistant"
+ assistant.content = "done — see the docs I wrote"
+ assistant.tool_calls = None # no write calls on the last message
+ sub.messages = [assistant]
+
+ async def fake_get(_sid):
+ return sub
+
+ async def no_active_session(_sid):
+ return None
+
+ monkeypatch.setattr(
+ "backend.copilot.tools.get_sub_session_result.get_chat_session",
+ fake_get,
+ )
+ monkeypatch.setattr(
+ "backend.copilot.tools.get_sub_session_result.stream_registry.get_session",
+ no_active_session,
+ )
+ stub_workspace_listing.return_value = [
+ WorkspaceFileInfoData(
+ file_id="file-1",
+ name="AUDIT.md",
+ path="/sessions/inner-9/AUDIT.md",
+ mime_type="text/markdown",
+ size_bytes=16170,
+ )
+ ]
+
+ r = await GetSubSessionResultTool()._execute(
+ user_id="alice",
+ session=_session("alice"),
+ sub_session_id="inner-9",
+ wait_if_running=30,
+ )
+ assert isinstance(r, SubSessionStatusResponse)
+ assert r.status == "completed"
+ # Waiter skipped (terminal short-circuit) — the tool-call log is stale.
+ mock_waiter.result_mock.assert_not_awaited()
+ # ...but the manifest is still populated, from the workspace listing.
+ stub_workspace_listing.assert_awaited_once_with("alice", "inner-9")
+ assert r.sub_workspace_files is not None
+ assert r.sub_workspace_files[0].path == "/sessions/inner-9/AUDIT.md"
+ assert "workspace file" in (r.message or "")
+
+
+# ---------------------------------------------------------------------------
+# SECRT-2377 — hollow response after delivering work via workspace files
+# ---------------------------------------------------------------------------
+
+
+class TestHollowResponseRepro:
+ """Deterministic repro for SECRT-2377.
+
+ A sub-AutoPilot that does its real work into workspace files and then
+ returns a short "delivered in three docs, what's next?" message finishes
+ ``COMPLETED`` with a hollow body. ``response_from_outcome`` surfaces only
+ ``response_text`` plus a raw tool-call log to the parent — it carries no
+ discoverable manifest of the files the sub wrote, and those files are
+ scoped to the sub's own session, so the parent silently loses the work
+ and re-does it.
+
+ The test exercises the pure ``response_from_outcome`` function (no queue,
+ Redis, or DB) and asserts the fixed contract: the completed response
+ exposes ``sub_workspace_files`` — a manifest of the files the sub created,
+ each with a cross-session ``read_path`` — so the parent can retrieve them.
+ """
+
+ @staticmethod
+ def _hollow_completed_result():
+ """A completed SessionResult mirroring the incident: 3 large files
+ written to the workspace, then a 227-token hollow final message."""
+
+ def _write_call(idx: int, name: str, size: int) -> ToolCallEntry:
+ # write_workspace_file's stream output is a WorkspaceWriteResponse
+ # JSON string carrying only a 200-char content_preview — never the
+ # full body. Its `path` is already session-qualified (the workspace
+ # manager resolves it on write). This is all the parent could mine
+ # from the tool log, and it is not the findings.
+ return ToolCallEntry(
+ tool_call_id=f"tc-{idx}",
+ tool_name="write_workspace_file",
+ input={"filename": name},
+ output=json.dumps(
+ {
+ "type": "workspace_file_written",
+ "file_id": f"file-{idx}",
+ "name": name,
+ "path": f"/sessions/inner-1/{name}",
+ "size_bytes": size,
+ "content_preview": "A" * 200,
+ }
+ ),
+ success=True,
+ )
+
+ res = SessionResult()
+ res.response_text = (
+ "Since the comprehensive audit has been completed and delivered "
+ "in three workspace documents, I'm ready to assist with the next "
+ "phase. What would you like me to do next?"
+ )
+ res.tool_calls = [
+ _write_call(1, "ANTHROPIC_MODEL_AUDIT_claude-opus-4-8.md", 16170),
+ _write_call(2, "MODEL_CHANGES_QUICK_REFERENCE.md", 6528),
+ _write_call(3, "EXACT_CODE_SNIPPETS.md", 14563),
+ ]
+ res.total_tokens = 22667
+ res.completion_tokens = 227
+ return res
+
+ def test_completed_status_is_surfaced(self):
+ """Sanity: the hollow result still reports COMPLETED — the failure
+ mode is invisible, which is exactly why it wastes tokens silently."""
+ r = response_from_outcome(
+ outcome="completed",
+ result=self._hollow_completed_result(),
+ inner_session_id="inner-1",
+ parent_session_id="parent-1",
+ elapsed=12.3,
+ )
+ assert isinstance(r, SubSessionStatusResponse)
+ assert r.status == "completed"
+ # The body the parent reads is the hollow summary, nothing more.
+ assert "next phase" in (r.response or "")
+
+ def test_completed_response_exposes_workspace_files_written(self):
+ r = response_from_outcome(
+ outcome="completed",
+ result=self._hollow_completed_result(),
+ inner_session_id="inner-1",
+ parent_session_id="parent-1",
+ elapsed=12.3,
+ )
+ # Fixed contract: the parent can discover the 3 files the sub wrote
+ # without scraping the raw tool log. Each path is session-qualified and
+ # ready to hand straight to read_workspace_file.
+ manifest = r.sub_workspace_files
+ assert manifest, "no workspace-file manifest surfaced to the parent"
+ by_path = {f.path: f for f in manifest}
+ assert set(by_path) == {
+ "/sessions/inner-1/ANTHROPIC_MODEL_AUDIT_claude-opus-4-8.md",
+ "/sessions/inner-1/MODEL_CHANGES_QUICK_REFERENCE.md",
+ "/sessions/inner-1/EXACT_CODE_SNIPPETS.md",
+ }
+ audit = by_path["/sessions/inner-1/ANTHROPIC_MODEL_AUDIT_claude-opus-4-8.md"]
+ assert audit.size_bytes == 16170
+ # The message nudges the parent toward the files so a hollow `response`
+ # isn't mistaken for an empty run.
+ assert "workspace file" in (r.message or "")
+
+ def test_no_manifest_when_sub_returned_inline(self):
+ """A sub that answered inline (no file writes) must not grow an empty
+ or noisy manifest — sub_workspace_files stays None."""
+
+ res = SessionResult()
+ res.response_text = "Here is the full answer, inline."
+ res.tool_calls = [
+ ToolCallEntry(
+ tool_call_id="tc-1",
+ tool_name="web_search",
+ input={"q": "x"},
+ output="some results",
+ success=True,
+ )
+ ]
+ r = response_from_outcome(
+ outcome="completed",
+ result=res,
+ inner_session_id="inner-2",
+ parent_session_id="parent-1",
+ elapsed=1.0,
+ )
+ assert r.sub_workspace_files is None
+ assert "workspace file" not in (r.message or "")
diff --git a/autogpt_platform/backend/backend/copilot/tools/workspace_files.py b/autogpt_platform/backend/backend/copilot/tools/workspace_files.py
index 45b27aff47..722369c91c 100644
--- a/autogpt_platform/backend/backend/copilot/tools/workspace_files.py
+++ b/autogpt_platform/backend/backend/copilot/tools/workspace_files.py
@@ -6,8 +6,6 @@ import mimetypes
import os
from typing import Any, Optional
-from pydantic import BaseModel
-
from backend.api.features.store.exceptions import VirusDetectedError, VirusScanError
from backend.copilot.context import (
E2B_WORKDIR,
@@ -25,7 +23,7 @@ from backend.util.settings import Config
from backend.util.workspace import WorkspaceManager
from .base import BaseTool
-from .models import ErrorResponse, ResponseType, ToolResponseBase
+from .models import ErrorResponse, ResponseType, ToolResponseBase, WorkspaceFileInfoData
logger = logging.getLogger(__name__)
@@ -257,16 +255,6 @@ async def _resolve_file(
return file_info.id, file_info
-class WorkspaceFileInfoData(BaseModel):
- """Data model for workspace file information (not a response itself)."""
-
- file_id: str
- name: str
- path: str
- mime_type: str
- size_bytes: int
-
-
class WorkspaceFileListResponse(ToolResponseBase):
"""Response containing list of workspace files."""