fix: capture hook return values to allow plugin context modification#582
Open
yadinae wants to merge 12 commits into
Open
fix: capture hook return values to allow plugin context modification#582yadinae wants to merge 12 commits into
yadinae wants to merge 12 commits into
Conversation
- 更新autonomous_operation_sop + task_planning - 更新SOP引用链(github_contribution, goal_hive, incubator等) - ljqCtrl优化, ui_detect简化 - memory_cleanup, morphling, review等SOP同步 - 新增task_engine.db
- R166: discriminator_reality_checker SOP实战 (self_discriminate流) - R167: procmem_scanner SOP实测 (进程内存安全扫描) - R168: solver_architect SOP实战 (Hermes Dashboard架构分析) - R169: TMWebDriver 数据库端点验证报告 - R170: solver_team_index完整度Gap分析 - scheduler.py: 新增validate_task_json() schema校验 - memory_drift_check.json: 修复缺prompt字段问题
- agentmail_bridge.py: 程序化API - auto_repair.py: diagnose触发AgentMail告警 - health_server.py: /api/agentmail端点
- 替换shell Xvfb启动为pyvirtualdisplay(纯Python Display管理) - 替换scrot截图为mss(纯Python截图) - subprocess tesseract保留为OCR引擎(轻量级,防OOM) - 修复tesseract OOM根因:chi_sim语言模型~50MB被内核kill - 默认OCR语言改为eng(原为eng+chi_sim) - 图片降采样max_dim=800降低内存需求 - 子进程失败不降级pytesseract(防主进程OOM) - capture_and_ocr及时释放临时文件+显式GC - knowledge_assets #43追加OCR子进程OOM陷阱
- Hermes Gateway 8901/8902: pgrep检测+重启+HTTP健康检查 - AgentMail: --watch持久daemon模式+看门狗 - 验收通过: 模拟DOWN后≤2min自动恢复 (AM:763811→764123, H2:763797→764150) - 报告: autonomous_reports/R405_watchdog_extension.md
- health_dashboard_server.py: 新增 /api/benchmark 和 /benchmark 端点 - 使用Chart.js渲染延迟/成功率趋势图 - 主Dashboard页添加Benchmark入口链接 - 支持benchmark_trend.json的时序数据可视化
- bridge.service (systemd user) 停用+删除, 终止58985次循环重启 - global_mem.txt更新: 移除bridge_service警告条目, 更新R406记录 - 系统日志不再被每5秒的bridge.service重启污染
All _hook() calls in agent_loop.py (agent_before, turn_before, llm_before, llm_after, turn_after, agent_after, tool_before, tool_after) discarded the return dict from plugins/hooks.py trigger(), preventing plugins from modifying execution context (system_prompt, messages, response, etc.). Fix: capture return value and update corresponding local variables. Fixes lsdefine#537
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
All
_hook()calls inagent_loop.pydiscarded the return dict fromplugins/hooks.pytrigger(), preventing plugins from modifying execution context (system_prompt, messages, response, etc.).Root Cause
The
_hookfunction (aliased fromplugins.hooks.trigger) passeslocals()to registered callbacks and returns the (potentially modified) context dict. However, all 8 call sites inagent_loop.pyignored the return value, making hook-based context modification ineffective.Fix
For each hook call site, capture the return value and update the corresponding local variable:
tool_beforeargstool_afterretagent_beforesystem_promptturn_beforemessagesllm_beforemessagesllm_afterresponseturn_afternext_promptagent_afterexit_reasonTesting
Fixes #537