From c263fbca5c47774ee2056e7a9674304f06cefc32 Mon Sep 17 00:00:00 2001 From: Zamil Majdy Date: Thu, 16 Apr 2026 14:10:15 +0700 Subject: [PATCH] docs(backend/copilot): document tool_calls flattening in extract_context_messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a note to the extract_context_messages docstring explaining that assistant messages derived from JSONL entries have tool_use blocks flattened to text (same behaviour as the old _compress_session_messages path — no regression). Gap messages from DB preserve their structured tool_calls field. --- autogpt_platform/backend/backend/copilot/transcript.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/autogpt_platform/backend/backend/copilot/transcript.py b/autogpt_platform/backend/backend/copilot/transcript.py index 57471ebae6..3d60c8ea63 100644 --- a/autogpt_platform/backend/backend/copilot/transcript.py +++ b/autogpt_platform/backend/backend/copilot/transcript.py @@ -846,6 +846,12 @@ def extract_context_messages( - Returns *prior* messages only (excluding the current user turn at ``session_messages[-1]``). Callers that need the current turn append ``session_messages[-1]`` themselves. + - **Tool calls from transcript entries are flattened to text**: assistant + messages derived from the JSONL use ``_flatten_assistant_content``, which + serialises ``tool_use`` blocks as human-readable text rather than + structured ``tool_calls``. Gap messages (from DB) preserve their + original ``tool_calls`` field. This is the same trade-off as the old + ``_compress_session_messages(session.messages)`` approach — no regression. Args: download: The ``TranscriptDownload`` from GCS, or ``None`` when no