@@ -171,6 +171,79 @@ class TurnCompletionController: |
| 171 | 171 | detail="Checking completion policy", |
| 172 | 172 | reason_code="completion_gate", |
| 173 | 173 | ) |
| 174 | + progress_messages = list(getattr(self.context.session, "messages", []) or []) |
| 175 | + progress_intent = _build_in_progress_continuation( |
| 176 | + content=content, |
| 177 | + dod=dod, |
| 178 | + project_root=self.context.project_root, |
| 179 | + messages=progress_messages, |
| 180 | + ) |
| 181 | + if progress_intent is not None: |
| 182 | + assistant_message = Message(role=Role.ASSISTANT, content=response_content) |
| 183 | + self.context.session.append(assistant_message) |
| 184 | + summary.assistant_messages.append(assistant_message) |
| 185 | + if ( |
| 186 | + progress_intent.target is not None |
| 187 | + and continuation_count == 0 |
| 188 | + and _confirmed_output_file_count( |
| 189 | + dod, |
| 190 | + project_root=self.context.project_root, |
| 191 | + ) |
| 192 | + == 0 |
| 193 | + and not _recent_concrete_target_prompt( |
| 194 | + progress_messages, |
| 195 | + target=progress_intent.target, |
| 196 | + ) |
| 197 | + ): |
| 198 | + self._append_completion_trace_entry( |
| 199 | + summary=summary, |
| 200 | + stage="continuation_check", |
| 201 | + outcome="continue", |
| 202 | + decision_code="in_progress_transition_continue", |
| 203 | + decision_summary=( |
| 204 | + "continued to let the assistant finish the concrete next " |
| 205 | + "planned step without interrupting it yet" |
| 206 | + ), |
| 207 | + ) |
| 208 | + self._record_completion_decision( |
| 209 | + summary=summary, |
| 210 | + decision_code="in_progress_transition_continue", |
| 211 | + decision_summary=( |
| 212 | + "continued to let the assistant finish the concrete next " |
| 213 | + "planned step without interrupting it yet" |
| 214 | + ), |
| 215 | + ) |
| 216 | + return TurnCompletionDecision( |
| 217 | + action=TurnCompletionAction.CONTINUE, |
| 218 | + continuation_count=continuation_count + 1, |
| 219 | + ) |
| 220 | + |
| 221 | + self.context.session.append( |
| 222 | + Message(role=Role.USER, content=progress_intent.prompt) |
| 223 | + ) |
| 224 | + self._append_completion_trace_entry( |
| 225 | + summary=summary, |
| 226 | + stage="continuation_check", |
| 227 | + outcome="continue", |
| 228 | + decision_code="in_progress_transition_continue", |
| 229 | + decision_summary=( |
| 230 | + "continued because the assistant described the next planned step " |
| 231 | + "without executing it yet" |
| 232 | + ), |
| 233 | + ) |
| 234 | + self._record_completion_decision( |
| 235 | + summary=summary, |
| 236 | + decision_code="in_progress_transition_continue", |
| 237 | + decision_summary=( |
| 238 | + "continued because the assistant described the next planned step " |
| 239 | + "without executing it yet" |
| 240 | + ), |
| 241 | + ) |
| 242 | + return TurnCompletionDecision( |
| 243 | + action=TurnCompletionAction.CONTINUE, |
| 244 | + continuation_count=continuation_count + 1, |
| 245 | + ) |
| 246 | + |
| 174 | 247 | text_loop_decision = await self.completion_policy.maybe_stop_for_text_loop( |
| 175 | 248 | content=content, |
| 176 | 249 | emit=emit, |
@@ -269,79 +342,6 @@ class TurnCompletionController: |
| 269 | 342 | finalize_reason_summary=continuation_decision.decision_summary, |
| 270 | 343 | ) |
| 271 | 344 | |
| 272 | | - progress_messages = list(getattr(self.context.session, "messages", []) or []) |
| 273 | | - progress_intent = _build_in_progress_continuation( |
| 274 | | - content=content, |
| 275 | | - dod=dod, |
| 276 | | - project_root=self.context.project_root, |
| 277 | | - messages=progress_messages, |
| 278 | | - ) |
| 279 | | - if progress_intent is not None: |
| 280 | | - assistant_message = Message(role=Role.ASSISTANT, content=response_content) |
| 281 | | - self.context.session.append(assistant_message) |
| 282 | | - summary.assistant_messages.append(assistant_message) |
| 283 | | - if ( |
| 284 | | - progress_intent.target is not None |
| 285 | | - and continuation_count == 0 |
| 286 | | - and _confirmed_output_file_count( |
| 287 | | - dod, |
| 288 | | - project_root=self.context.project_root, |
| 289 | | - ) |
| 290 | | - == 0 |
| 291 | | - and not _recent_concrete_target_prompt( |
| 292 | | - progress_messages, |
| 293 | | - target=progress_intent.target, |
| 294 | | - ) |
| 295 | | - ): |
| 296 | | - self._append_completion_trace_entry( |
| 297 | | - summary=summary, |
| 298 | | - stage="continuation_check", |
| 299 | | - outcome="continue", |
| 300 | | - decision_code="in_progress_transition_continue", |
| 301 | | - decision_summary=( |
| 302 | | - "continued to let the assistant finish the concrete next " |
| 303 | | - "planned step without interrupting it yet" |
| 304 | | - ), |
| 305 | | - ) |
| 306 | | - self._record_completion_decision( |
| 307 | | - summary=summary, |
| 308 | | - decision_code="in_progress_transition_continue", |
| 309 | | - decision_summary=( |
| 310 | | - "continued to let the assistant finish the concrete next " |
| 311 | | - "planned step without interrupting it yet" |
| 312 | | - ), |
| 313 | | - ) |
| 314 | | - return TurnCompletionDecision( |
| 315 | | - action=TurnCompletionAction.CONTINUE, |
| 316 | | - continuation_count=continuation_count + 1, |
| 317 | | - ) |
| 318 | | - |
| 319 | | - self.context.session.append( |
| 320 | | - Message(role=Role.USER, content=progress_intent.prompt) |
| 321 | | - ) |
| 322 | | - self._append_completion_trace_entry( |
| 323 | | - summary=summary, |
| 324 | | - stage="continuation_check", |
| 325 | | - outcome="continue", |
| 326 | | - decision_code="in_progress_transition_continue", |
| 327 | | - decision_summary=( |
| 328 | | - "continued because the assistant described the next planned step " |
| 329 | | - "without executing it yet" |
| 330 | | - ), |
| 331 | | - ) |
| 332 | | - self._record_completion_decision( |
| 333 | | - summary=summary, |
| 334 | | - decision_code="in_progress_transition_continue", |
| 335 | | - decision_summary=( |
| 336 | | - "continued because the assistant described the next planned step " |
| 337 | | - "without executing it yet" |
| 338 | | - ), |
| 339 | | - ) |
| 340 | | - return TurnCompletionDecision( |
| 341 | | - action=TurnCompletionAction.CONTINUE, |
| 342 | | - continuation_count=continuation_count + 1, |
| 343 | | - ) |
| 344 | | - |
| 345 | 345 | final_response = self.completion_policy.finalize_response_text( |
| 346 | 346 | content=content, |
| 347 | 347 | actions_taken=actions_taken, |