"""`end_turn` and `no_reply` called from a real cell end a multi-cell turn cleanly, without the nudge a silent turn gets. The nudge itself (asked once, never kept, an error when silent twice) is checked in process by apps/albedo/test/albedo/session/turn_transcript_test.gleam. """ import json import unittest from harness import Albedo, Provider, python NUDGE = "your previous response ended with no reply and no tool call" def nudged(request): return NUDGE in json.dumps(request["input"][-1]) class SpeechlessTurnTest(unittest.TestCase): def run_turn(self, script): provider = Provider(script) with Albedo(provider, protocol="responses") as app: session = app.session() app.prompt(session, "what now").close() snapshot = app.idle(session) history = json.dumps(app.history(session)) errors = [ line["text"] for line in snapshot["activity"]["lines"] if line["kind"] == "error" ] return provider.requests, history, errors def test_end_turn_and_no_reply_finish_multi_cell_turns_cleanly(self): for call in ("await end_turn('done')", "await no_reply('alias')"): with self.subTest(call=call): def script(request, call=call): last = request["input"][-1] if last.get("type") == "function_call_output": return python( f"assert step_one == 1\n{call}\nprint('STEP_TWO')" ) return python("step_one = 1\nprint('STEP_ONE')") requests, history, errors = self.run_turn(script) self.assertEqual(len(requests), 2) self.assertIn("STEP_ONE", history) self.assertIn("STEP_TWO", history) self.assertNotIn(NUDGE, json.dumps(requests)) self.assertNotIn(NUDGE, history) self.assertEqual(errors, []) if __name__ == "__main__": unittest.main()