import dataclasses import pathlib import sys import unittest sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) from agent_cycle.doubles import PROMPTS from model_routing.route import Route from model_routing.ladder import Rung from agent_cycle import worker_prompts class TypedAnswers(unittest.TestCase): def test_splits_the_prompt_handing_over_the_answer_into_the_answer_on_the_line_after_its_marker_and_the_rest_and_no_other_prompt(self): route = Route(Rung("worker-model")) marked = "The human answered your question at a-driver's terminal:\nB" typed = worker_prompts.typed_answer(PROMPTS.typed("Which one?", "Use B.", route, None, False)) self.assertEqual(typed.answer, "Use B.") self.assertTrue(typed.loop_words.startswith("Your question was: Which one?\n\nContinue the task.")) self.assertEqual(worker_prompts.typed_answer(PROMPTS.typed(f"Which one?\n{marked}", "Use B.", route, None, False)).answer, "Use B.") # A ruling that stepped the worker up adds the sentences naming its new rung. self.assertEqual(worker_prompts.typed_answer(PROMPTS.typed("Which one?", "Use B.", Route(Rung("claude-sonnet-5-5", "high"), 179, 2, 5), None, True)).answer, "Use B.") self.assertIsNone(worker_prompts.typed_answer(PROMPTS.answered("Which one?", marked, route, None, False))) self.assertIsNone(worker_prompts.typed_answer(PROMPTS.resumed(marked, route, None))) def test_the_typed_answers_prompt_names_the_entry_points_answer_destinations(self): ledger = dataclasses.replace(PROMPTS, answer_destinations="the ledger") self.assertIn("is recorded in the ledger at the one place it governs.", ledger.typed("Which one?", "Use B.", Route(Rung("worker-model")), None, False)) if __name__ == "__main__": unittest.main()