(self, prompt: str, limit: int = 5, max_turns: int = 3, structured_output: bool = False)
| 152 | ) |
| 153 | |
| 154 | def run_turn_loop(self, prompt: str, limit: int = 5, max_turns: int = 3, structured_output: bool = False) -> list[TurnResult]: |
| 155 | engine = QueryEnginePort.from_workspace() |
| 156 | engine.config = QueryEngineConfig(max_turns=max_turns, structured_output=structured_output) |
| 157 | matches = self.route_prompt(prompt, limit=limit) |
| 158 | command_names = tuple(match.name for match in matches if match.kind == 'command') |
| 159 | tool_names = tuple(match.name for match in matches if match.kind == 'tool') |
| 160 | results: list[TurnResult] = [] |
| 161 | for turn in range(max_turns): |
| 162 | turn_prompt = prompt if turn == 0 else f'{prompt} [turn {turn + 1}]' |
| 163 | result = engine.submit_message(turn_prompt, command_names, tool_names, ()) |
| 164 | results.append(result) |
| 165 | if result.stop_reason != 'completed': |
| 166 | break |
| 167 | return results |
| 168 | |
| 169 | def _infer_permission_denials(self, matches: list[RoutedMatch]) -> list[PermissionDenial]: |
| 170 | denials: list[PermissionDenial] = [] |
no test coverage detected