#!/usr/bin/env python3 # -*- coding: utf-8 -*- """查 on_tool_end(...) 在新 Agent 工具执行路径中的调用位置与参数。""" from __future__ import annotations import sys import _bootstrap # noqa: F401 import _config as C from dify_api import Dify def main() -> int: d = Dify(C.DIFY_EMAIL, C.DIFY_PASSWORD) try: d.login() # 重点抓 callback 调用处:如果看不到 message_id 参数,基本就会导致 ToolTraceInfo 无法落库 cmd = ( "docker exec docker-api-1 sh -lc " "\"grep -RIn --line-number 'on_tool_end(' /app/api/core /app/api/agent 2>/dev/null | head -80\"" ) out, err = d.sh(cmd, t=240) print(out or err) return 0 finally: d.close() if __name__ == '__main__': sys.exit(main())