Commit Graph

3 Commits

Author SHA1 Message Date
Chiguyong bcfa4fb5f6 fix(iq): 补齐 PR #27 的 5 个实现缺口 + 2 个 P2 residuals
F1: 前端 autonomy_paused 事件处理
  - 新增 AutonomyPausedCard.vue 组件(reason + progress + resume 按钮)
  - chatStore/chatStream 接收 autonomy_paused 事件并渲染暂停卡片
  - ChatView 集成暂停卡片显示

F2: cleanup_expired 定时调用
  - episodic.py 的 prompt_reflection 记录 30 天过期清理接入

F3: SharedWorkspace.lock() TOCTOU 防护
  - _phase_executor.py 并行子任务写入用 lock() 防护
  - shared_workspace.py 补充锁实现

F4: retrieve_prompt_reflection KTD5 门控
  - react.py/reflexion.py 按 verify 二次失败/循环检测条件门控

F5: configs/agentkit.yaml.example 配置示例
  - 包含 dangerous_tools 配置示例

F6: resume Future 注册顺序消除竞态

F7: 用户拒绝危险工具不计入 _consecutive_failures

测试:112 个单元测试全部通过
2026-07-06 20:31:50 +08:00
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