File size: 1,176 Bytes
ccd25ed
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
"""MCP tool: read_transcript -- read transcript entries for a turn range."""

from __future__ import annotations

from debatemind.models.observation import TranscriptEntry


def read_transcript(
    start_turn: int,
    end_turn: int,
    transcript: list[TranscriptEntry],
) -> dict:
    """Return transcript entries for the specified turn range.

    The range is clamped to valid bounds so out-of-range values are
    handled gracefully rather than raising errors.

    Args:
        start_turn: First turn to include (inclusive).
        end_turn: Last turn to include (inclusive).
        transcript: Full list of transcript entries.

    Returns:
        A dict with an "entries" key containing a list of dicts,
        each with turn, actor, action_type, and content fields.
    """
    # Clamp to valid bounds
    start_turn = max(0, start_turn)
    end_turn = max(start_turn, end_turn)

    entries = [
        {
            "turn": e.turn,
            "actor": e.actor,
            "action_type": e.action_type,
            "content": e.content,
        }
        for e in transcript
        if start_turn <= e.turn <= end_turn
    ]
    return {"entries": entries}