Skip to content

Commit 269092a

Browse files
author
Mateusz
committed
Remove legacy tool call loop detection
1 parent 484298a commit 269092a

67 files changed

Lines changed: 96 additions & 8100 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ tmp/
5151
tmp_*.py
5252
tmp_*.md
5353
tmp_*.txt
54+
*.err
55+
*.out
5456

5557
# OS-specific files
5658
.DS_Store

docs/architecture/middleware-parity-analysis.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ This document analyzes all response middleware in the codebase to identify featu
1212
| ThinkTagsFixMiddleware | Yes | Yes | PARTIAL | Different logic paths |
1313
| EditPrecisionResponseMiddleware | Yes | Yes | FULL | Same logic for both |
1414
| ToolCallReactorMiddleware | Yes | Yes | PARTIAL | Different lifecycle handling |
15-
| ToolCallLoopDetectionMiddleware | Yes | Yes | PARTIAL | Different lifecycle reset |
1615
| EmptyResponseMiddleware | No | Yes | GAP | Skips streaming entirely |
1716
| StructuredOutputMiddleware | No | Yes | GAP | Skips streaming entirely |
1817
| JsonRepairMiddleware | No | Yes | GAP | Skips streaming, uses processor |
@@ -64,14 +63,6 @@ This document analyzes all response middleware in the codebase to identify featu
6463
- **Gap**: Lines 100-102 clear state for non-streaming only
6564
- **Migration Priority**: High
6665

67-
#### ToolCallLoopDetectionMiddleware
68-
- **Location**: `src/core/services/tool_call_loop_middleware.py`
69-
- **Feature**: Prevents tool call loops
70-
- **Streaming**: Maintains lifecycle across chunks
71-
- **Non-streaming**: Clears lifecycle on each call (line 134)
72-
- **Gap**: Lifecycle handling differs
73-
- **Migration Priority**: High
74-
7566
### PARITY GAPS (Missing Streaming Support)
7667

7768
#### EmptyResponseMiddleware
@@ -131,7 +122,6 @@ Added streaming support to middleware that previously lacked it:
131122
The following middleware have complex streaming state management and are deferred from full migration:
132123
- `ThinkTagsFixMiddleware` - 700+ lines with sophisticated buffer management
133124
- `ToolCallReactorMiddleware` - Complex lifecycle state handling
134-
- `ToolCallLoopDetectionMiddleware` - Session-based lifecycle tracking
135125
- `EditPrecisionResponseMiddleware` - Already has full parity
136126

137127
These can be wrapped using `MiddlewareToFeatureAdapter` for registry integration.

src/core/commands/handlers/__init__.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
"reasoning_aliases",
1919
"reasoning_handlers",
2020
"set_command_handler",
21-
"tool_loop_max_repeats_command_handler",
22-
"tool_loop_mode_command_handler",
23-
"tool_loop_ttl_command_handler",
2421
"unset_command_handler",
2522
]
2623

src/core/commands/handlers/loop_detection_command_handler.py

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -75,52 +75,3 @@ async def handle(self, command: Command, session: Session) -> CommandResult:
7575
),
7676
new_state=session.state,
7777
)
78-
79-
80-
@command("tool-loop-detection")
81-
class ToolLoopDetectionCommandHandler(ICommandHandler):
82-
"""Handler for the `/tool-loop-detection` command."""
83-
84-
@property
85-
def command_name(self) -> str:
86-
return "tool-loop-detection"
87-
88-
@property
89-
def description(self) -> str:
90-
return "Enable or disable tool loop detection."
91-
92-
@property
93-
def format(self) -> str:
94-
return "tool-loop-detection(enabled=true|false)"
95-
96-
@property
97-
def examples(self) -> list[str]:
98-
return [
99-
"!/tool-loop-detection(enabled=true)",
100-
"!/tool-loop-detection(enabled=false)",
101-
]
102-
103-
async def handle(self, command: Command, session: Session) -> CommandResult:
104-
enabled, invalid = _parse_bool_argument(command.args)
105-
if enabled is None:
106-
return CommandResult(
107-
success=False,
108-
message=(
109-
"Error: Invalid value. Please use 'true' or 'false'."
110-
if invalid is not None
111-
else "Error: Please provide a value (true/false)."
112-
),
113-
)
114-
115-
new_config = session.state.loop_config.with_tool_loop_detection_enabled(enabled)
116-
session.state = session.state.with_loop_config(new_config)
117-
118-
return CommandResult(
119-
success=True,
120-
message=(
121-
"Tool loop detection enabled"
122-
if enabled
123-
else "Tool loop detection disabled"
124-
),
125-
new_state=session.state,
126-
)

0 commit comments

Comments
 (0)