docs(backend/copilot): document tool_calls flattening in extract_context_messages

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.
This commit is contained in:
Zamil Majdy
2026-04-16 14:10:15 +07:00
parent 0c3a15832b
commit c263fbca5c

View File

@@ -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