trace_callers
Trace all callers of a function level by level, from direct callers up to 5 levels deep. Discover which code is affected when changing a function, with confidence indicators for each call.
Instructions
BFS 逐层找出调用指定函数的函数:depth=1 为直接调用者,depth=2 再找「调用者的调用者」,依此类推(上限 5 层)。适合回答「改了函数 X,影响会波及到哪里?」返回 {target, max_depth, total_found, truncated, levels:[{depth, callers:[{file, line, caller_function, callee, confidence}]}]}。confidence=high 表示 foo(x) 直呼;medium 表示 obj.foo() 按方法名匹配,可能是其他类的同名方法。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| depth | No | 追踪层数,1=直接调用者,最大 5,默认 1 | |
| max_results | No | 所有层合计最大返回数,默认 500 | |
| exclude_dirs | No | 排除目录,不传则使用默认排除列表,传 [] 则不排除任何目录 | |
| project_path | Yes | Python 项目根目录绝对路径 | |
| function_name | Yes | 要追踪的函数名,如 'get_eq_partition' |