Always append tool results to session before verification gate check
- SHA
395c2ecb56bb9275922428bc5635352491ace483- Parents
-
dd052a1 - Tree
d99a737
395c2ec
395c2ecb56bb9275922428bc5635352491ace483dd052a1
d99a737| Status | File | + | - |
|---|---|---|---|
| M |
src/loader/runtime/tool_batches.py
|
8 | 5 |
src/loader/runtime/tool_batches.pymodified@@ -172,6 +172,13 @@ class ToolBatchRunner: | ||
| 172 | 172 | ) |
| 173 | 173 | ) |
| 174 | 174 | |
| 175 | + # Always append tool results to the session so the model sees | |
| 176 | + # its own output. The verification gate may inject a correction | |
| 177 | + # prompt, but the original result must still be in context — | |
| 178 | + # otherwise the model operates blind and loops. | |
| 179 | + self.context.session.append(outcome.message) | |
| 180 | + summary.tool_result_messages.append(outcome.message) | |
| 181 | + | |
| 175 | 182 | should_continue = await self.verification_gate.should_continue( |
| 176 | 183 | tool_call=tool_call, |
| 177 | 184 | outcome=outcome, |
@@ -179,21 +186,17 @@ class ToolBatchRunner: | ||
| 179 | 186 | ) |
| 180 | 187 | |
| 181 | 188 | rlog = get_runtime_logger() |
| 182 | - appended = not should_continue | |
| 183 | 189 | rlog.tool_exec( |
| 184 | 190 | name=tool_call.name, |
| 185 | 191 | state=outcome.state.value, |
| 186 | 192 | is_error=outcome.is_error, |
| 187 | 193 | result_preview=outcome.event_content, |
| 188 | - appended_to_session=appended, | |
| 194 | + appended_to_session=True, | |
| 189 | 195 | ) |
| 190 | 196 | if should_continue: |
| 191 | 197 | rlog.verification_gate(tool_call.name, should_continue=True) |
| 192 | 198 | continue |
| 193 | 199 | |
| 194 | - self.context.session.append(outcome.message) | |
| 195 | - summary.tool_result_messages.append(outcome.message) | |
| 196 | - | |
| 197 | 200 | if result.consecutive_errors >= 3: |
| 198 | 201 | final_response = ( |
| 199 | 202 | "I ran into some issues. " |