Replace trajectory audit with isolated prefix scoring
This commit is contained in:
+36
-1
@@ -1,6 +1,11 @@
|
||||
"""Tests for prompt-only trajectory compaction."""
|
||||
|
||||
from swe_data_processing.evidence import compact_text, compact_trajectory
|
||||
from swe_data_processing.evidence import (
|
||||
BOUNDARY_BLOCK_TURNS,
|
||||
build_trajectory_blocks,
|
||||
compact_text,
|
||||
compact_trajectory,
|
||||
)
|
||||
|
||||
|
||||
def test_compact_text_preserves_short_values() -> None:
|
||||
@@ -36,3 +41,33 @@ def test_compact_trajectory_prioritizes_test_observations() -> None:
|
||||
compacted, metadata = compact_trajectory(trajectory, signals)
|
||||
assert compacted[2]["content"] == long_content
|
||||
assert 3 in metadata["important_turn_ids"]
|
||||
|
||||
|
||||
def test_boundary_blocks_preserve_absolute_turns_without_overlap() -> None:
|
||||
trajectory = [
|
||||
{"turn_id": turn, "role": "assistant", "content": f"turn {turn}"}
|
||||
for turn in range(1, BOUNDARY_BLOCK_TURNS + 3)
|
||||
]
|
||||
blocks, metadata = build_trajectory_blocks(trajectory, {})
|
||||
assert len(blocks) == 2
|
||||
assert blocks[0]["start_turn"] == 1
|
||||
assert blocks[0]["end_turn"] == BOUNDARY_BLOCK_TURNS
|
||||
assert blocks[1]["start_turn"] == BOUNDARY_BLOCK_TURNS + 1
|
||||
assert blocks[1]["end_turn"] == BOUNDARY_BLOCK_TURNS + 2
|
||||
turn_ids = [
|
||||
message["turn_id"] for block in blocks for message in block["messages"]
|
||||
]
|
||||
assert turn_ids == list(range(1, BOUNDARY_BLOCK_TURNS + 3))
|
||||
assert metadata["block_count"] == 2
|
||||
|
||||
|
||||
def test_boundary_block_keeps_immediate_tool_result_with_assistant() -> None:
|
||||
trajectory = [
|
||||
{"turn_id": turn, "role": "user", "content": f"turn {turn}"}
|
||||
for turn in range(1, BOUNDARY_BLOCK_TURNS + 2)
|
||||
]
|
||||
trajectory[BOUNDARY_BLOCK_TURNS - 1]["role"] = "assistant"
|
||||
trajectory[BOUNDARY_BLOCK_TURNS]["role"] = "tool"
|
||||
blocks, _ = build_trajectory_blocks(trajectory, {})
|
||||
assert blocks[0]["end_turn"] == BOUNDARY_BLOCK_TURNS + 1
|
||||
assert len(blocks) == 1
|
||||
|
||||
Reference in New Issue
Block a user