fix: gate BEFORE_TOOL_DEFINITIONS deepcopy behind has_hooks#3172
fix: gate BEFORE_TOOL_DEFINITIONS deepcopy behind has_hooks#3172praisonai-triage-agent[bot] wants to merge 1 commit into
Conversation
|
@coderabbitai review |
|
/review |
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more β On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
β Action performedReview finished.
|
|
No actionable comments were generated in the recent review. π βΉοΈ Recent review infoβοΈ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: π Files selected for processing (1)
π WalkthroughWalkthrough
ChangesTool Definition Hook Gating
Estimated code review effort: 1 (Trivial) | ~5 minutes Suggested reviewers: π₯ Pre-merge checks | β 5β Passed checks (5 passed)
β¨ Finishing Touchesπ Generate docstrings
π§ͺ Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR avoids unnecessary tool-schema copies when no definition hook is registered. The main changes are:
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (1): Last reviewed commit: "fix: gate BEFORE_TOOL_DEFINITIONS deepco..." | Re-trigger Greptile |
|
@claude You are the FINAL architecture reviewer. If the branch is under MervinPraison/PraisonAI (not a fork), you are able to make modifications to this branch and push directly. SCOPE: Focus ONLY on Python packages (praisonaiagents, praisonai). Do NOT modify praisonai-rust or praisonai-ts. Read ALL comments above from Gemini, Qodo, CodeRabbit, and Copilot carefully before responding. Phase 1: Review per AGENTS.md
Phase 2: FIX Valid Issues Phase 3: Final Verdict |
|
Claude finished @MervinPraison's task ββ View job Final Architecture Review β PR #3172
Verdict: β APPROVE β merge as-isThis is a clean, minimal, correct hot-path fix. No code changes needed. Phase 1 β Architecture review (AGENTS.md)
Correctness checks I independently verified
Phase 2 β Fixes: None required. No valid issues raised by CodeRabbit (no actionable comments), Greptile (5/5, safe to merge), or found independently. Phase 3 β Testing Files modified this review: none. |
Fixes #3171
Summary
On the tool-calling hot path,
_apply_before_tool_definitions_hookdeep-copied the full formatted tool schema on every LLM round-trip whenever the agent had tools β even when noBEFORE_TOOL_DEFINITIONShook was registered. The existing guard only checked_hook_runner, which is a property that is neverNoneonce accessed, so it never short-circuited when tools were present.This gates the work behind the same cheap
registry.has_hooks(...)check used by every other hook event (tool_execution.py,chat_mixin.pyBEFORE_AGENT), so the deep copy only happens when a hook is actually registered.Changes
_apply_before_tool_definitions_hook(sync) and_aapply_before_tool_definitions_hook(async) inchat_mixin.pynow short-circuit viahas_hooks(HookEvent.BEFORE_TOOL_DEFINITIONS)before building input / deep-copying.Capability preserved
Testing
tests/unit/hooks/test_before_tool_definitions.pyandtests/unit/plugins/test_hook_bridge.py: 35 passed.Generated with Claude Code
Summary by CodeRabbit