Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions tests/agents/test_orchestrator_chain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import pytest

from utu.agents.common import TaskRecorder
from utu.agents.orchestrator.chain import ChainPlanner
from utu.agents.orchestrator.common import Recorder


def test_parse_reports_missing_plan_block() -> None:
planner = object.__new__(ChainPlanner)
recorder = Recorder(input="summarize the report")

with pytest.raises(AssertionError, match="No tasks parsed from plan"):
planner._parse("<analysis>the response was truncated</analysis>", recorder)


def test_task_recorder_defaults_input_to_list() -> None:
assert TaskRecorder().input == []
2 changes: 1 addition & 1 deletion utu/agents/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def to_dict(self):
class TaskRecorder(DataClassWithStreamEvents):
task: str = ""
trace_id: str = ""
input: str | list[TResponseInputItem] = field(default_factory=dict)
input: str | list[TResponseInputItem] = field(default_factory=list)

# from RunResultStreaming
final_output: str = ""
Expand Down
2 changes: 1 addition & 1 deletion utu/agents/orchestrator/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def _parse(self, text: str, recorder: Recorder) -> Plan:
analysis = match.group(1).strip() if match else ""

match = re.search(r"<plan>\s*\[(.*?)\]\s*</plan>", text, re.DOTALL)
plan_content = match.group(1).strip()
plan_content = match.group(1).strip() if match else ""
tasks: list[Task] = []
task_pattern = r'\{"name":\s*"([^"]+)",\s*"task":\s*"([^"]+)"\s*\}'
task_matches = re.findall(task_pattern, plan_content, re.IGNORECASE)
Expand Down