v3.7.0: Intelligence Routing — self-healing parser system

Layer 1 (FIX 23): Deep URL extraction from nested JSON in explore_agent blocks.
Layer 2 (FIX 24): Auto-proceed on require_escalation / request_escalation_permission.
Layer 3 (FIX 25): Intent-based command synthesis with 5 heuristics when all parsers fail.

Module-level _build_explore_cmd() for reuse across parser + stream path.
54 self-test patterns (up from 41).
This commit is contained in:
admin
2026-05-22 16:29:45 +04:00
Unverified
parent 8e99821606
commit c52b801cde
5 changed files with 316 additions and 37 deletions

View File

@@ -1,5 +1,48 @@
# Changelog
## v3.7.0 (2026-05-22)
**Intelligence Routing — Self-Healing Parser System**
When the Command Code model produces output in unpredictable or unrecognized formats, the multi-format parser chain (DSML, XML, explore_agent, bash blocks, raw JSON, fallback regex) can return empty. This causes the Codex agent loop to stall — zero tool calls means nothing to execute.
Intelligence Routing is a **three-layer self-healing system** that ensures the agent loop always continues:
### Layer 1: Deep URL Extraction (FIX 23)
- **Problem**: `<explore_agent>` body contained `messages: [{"content": "https://..."}]` — URLs hidden inside JSON values. Regex couldn't match because it excluded the `"` character that terminates JSON strings.
- **Solution**: `_build_explore_cmd()` extracted to module level (was a closure inside `_parse_commandcode_text_tool_calls`). After initial regex fails, tries `json.loads()`, iterates list items, extracts `content` field to find URLs. Added `"` to regex exclusion set.
- **Self-tests**: Pattern M, O, O2 verify URL extraction from nested JSON.
### Layer 2: Escalation Block Handling (FIX 24)
- **Problem**: Model produces `<require_escalation>` and `<request_escalation_permission>` blocks when it wants elevated permissions. CC adapter doesn't support escalation — blocks silently dropped → `parsed_tool_calls=0` → stall.
- **Solution**: Two handlers:
- FIX 24a: Closed-tag blocks — extracts URL if present and runs explore command; otherwise echoes auto-proceed.
- FIX 24b: Bare/unclosed tags (`<require_escalation />`) — auto-proceeds with diagnostic echo.
- **Self-tests**: Pattern N, N2 verify both closed and bare escalation blocks.
### Layer 3: Intent-Based Command Synthesis (FIX 25 — THE CORE)
- **Problem**: After ALL parsers return empty, the agent loop has zero tool calls. Model may have written plain English ("I need to fetch the README"), partial JSON, or completely unrecognized formats.
- **Solution**: 5-heuristic synthesis chain in `cc_stream_to_sse()`, run when `parsed_tool_calls=0` and text has content:
1. **URL in text**`curl` to fetch it
2. **File path reference** ("read the file /path/to/X") → `cat` or `ls` that file
3. **Shell command in backticks/quotes** → extract and run it
4. **"explore"/"fetch"/"investigate"/"repository" intent** + last user URL → `_build_explore_cmd()` with `_last_user_urls` deque
5. **"I need to"/"let me"/"please" intent text** → echo diagnostic with the intent
- The system NEVER returns empty tool calls when there's text to analyze.
- **Self-tests**: Patterns M-O2 cover the full pipeline.
### Architecture
```
_parse_commandcode_text_tool_calls() ← Layer 1 + Layer 2
cc_stream_to_sse() ← Layer 3 (after parser chain + fallback)
_last_user_urls deque (maxlen=20) ← Session-wide URL memory for heuristic 4
```
### Test Coverage
- **54 self-test patterns** (up from 41 in v3.6.0)
- 13 new tests covering all three Intelligence Routing layers
- Tests verify: nested JSON URL extraction, closed/bare escalation blocks, module-level explore command builder
## v3.6.0 (2026-05-22)
**Performance & Stability Hardening — Connection Pooling, Stream Idle Timeouts, Retry-After**