Commit Graph

2 Commits

Author SHA1 Message Date
Chiguyong aacec29948 fix(iq): apply code review fixes — P0 deadlock + P1 gate/tracking/filter
Test / backend-test (pull_request) Has been cancelled Details
Test / frontend-unit (pull_request) Has been cancelled Details
Test / api-e2e (pull_request) Has been cancelled Details
Test / frontend-e2e (pull_request) Has been cancelled Details
P0 #1: Fix autonomy_paused event deadlock — split _check_autonomy_pause
into _detect_autonomy_pause (non-blocking) + _await_autonomy_resume
(blocking). Caller now yields the pause event BEFORE awaiting resume,
so the frontend receives it and the resume handler doesn't deadlock.

P1 #2+#6: Fix retrieve_prompt_reflection field mapping — read
output_summary/reflection/quality_score from MemoryItem.value dict
(matching EpisodicMemory.search shape) instead of metadata. Score
filtering uses stored quality_score, not search relevance score.

P1 #3: Add optional task_type filter to cleanup_expired so
prompt_reflection TTL cleanup doesn't delete all episodic records.

P1 #4: Disable parallel tool execution in autonomy mode — dangerous
tools must go through _check_autonomy_gate, which only runs in the
serial path.

P1 #5: Add _track_tool_result_for_autonomy to parallel result loop
so tool failures are counted toward the consecutive_failures threshold.

Tests: adapt test_autonomy_paused.py to new detect/await interface;
fix test_lead_reflection_retrieval.py mock shape (fields in value dict).
137 IQ-boost tests pass, ruff clean.
2026-07-06 15:07:59 +08:00
Chiguyong 7627403a8a feat(react): U3 PLAN_EXEC autonomy pause + autonomy_paused event (R10)
Add autonomy pause mechanism for PLAN_EXEC mode: when execution exceeds
timeout (default 30min) or hits consecutive failures (default 3), engine
emits `autonomy_paused` event and awaits user resume via resume_handler.

- DangerousToolsConfig: add autonomy_timeout_minutes + max_consecutive_failures
- ReActEngine: add _check_autonomy_pause() + _track_tool_result_for_autonomy()
  Called in serial + text-parsed tool paths (between tool_call event and
  autonomy gate). resume_handler=None → auto-resume (REST/testing).
- chat.py: WebSocket `resume` message handler + _resume_handler closure
  (Future-based, 30min hard timeout). pending_autonomy_resumes cleanup
  in finally block. autonomy_paused event forwarded to frontend.

Tests: 21 new tests (track_result + no_trigger + timeout + failures +
config parsing + handler exception). All pass; U1/U2 no regression.
2026-07-06 13:34:31 +08:00