fix: make call feature guard detect missing optional deps#3169
fix: make call feature guard detect missing optional deps#3169praisonai-triage-agent[bot] wants to merge 1 commit into
Conversation
Co-authored-by: MervinPraison <MervinPraison@users.noreply.github.com>
|
@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.
|
π WalkthroughWalkthroughThe call feature loader now imports ChangesCall feature import guard
Estimated code review effort: 1 (Trivial) | ~3 minutes π₯ 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 changes how the optional call feature is loaded.
Confidence Score: 4/5The intended CLI error handling remains inactive on the production call paths.
src/praisonai/praisonai/cli/legacy/inbuilt_tools.py and the active call loaders in praisonai-code. Important Files Changed
Reviews (1): Last reviewed commit: "fix: make call feature guard detect miss..." | Re-trigger Greptile |
| def get_call_module(): | ||
| import importlib.util | ||
|
|
||
| if not importlib.util.find_spec("praisonai.api.call"): | ||
| try: | ||
| from praisonai.api import call as call_module |
There was a problem hiding this comment.
The active call command paths use separate _get_call_module() implementations in praisonai-code/cli/main.py and praisonai-code/cli/legacy/praison_ai.py, both of which retain the old find_spec() guard. A normal CLI invocation with a missing call dependency therefore never reaches this handler and still exposes the raw import failure this change is intended to replace.
|
@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 Claude Architecture Review β PR #3169 β Approve
Phase 1 β Architecture Review (per AGENTS.md)
Phase 2 β Verification of the fixThe change replaces the ineffective def get_call_module():
try:
from praisonai.api import call as call_module
except ImportError as exc:
raise ImportError(
'Call feature is not installed. Install with: pip install "praisonai[call]"'
) from exc
return call_moduleI confirmed I also grepped the entire in-scope On the Greptile P1 finding ("Updated Guard Is Not Reached")Greptile is technically correct that Phase 3 β Final Verdictβ
Approve. The fix is correct, minimal, lightweight, backward-compatible, and properly routed. No code changes required β the diff already resolves issue #3168 for the Files modified by me: none (fix is already correct). |
There was a problem hiding this comment.
Actionable comments posted: 1
π€ Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/praisonai/praisonai/cli/legacy/inbuilt_tools.py`:
- Around line 27-32: Update the import handling around call_module in the legacy
inbuilt-tools initialization to use the existing find_spec("praisonai.api.call")
guard, or otherwise only translate a confirmed missing optional module into the
installation message. Let ImportError exceptions raised within
praisonai.api.call propagate unchanged instead of masking them as a missing
extra.
πͺ Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
βΉοΈ Review info
βοΈ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: c6904878-ae2d-4e5f-ae81-5ce6d570462e
π Files selected for processing (1)
src/praisonai/praisonai/cli/legacy/inbuilt_tools.py
| try: | ||
| from praisonai.api import call as call_module | ||
| except ImportError as exc: | ||
| raise ImportError( | ||
| 'Call feature is not installed. Install with: pip install "praisonai[call]"' | ||
| ) | ||
| from praisonai.api import call as call_module | ||
| ) from exc |
There was a problem hiding this comment.
π― Functional Correctness | π‘ Minor | β‘ Quick win
π§© Analysis chain
π Script executed:
#!/bin/bash
# Inspect the call module's import graph and callers before narrowing the exception.
rg -n -C3 '^(from|import) ' src/praisonai src/praisonai-code --glob '*call*.py'
rg -n -C4 'get_call_module|from praisonai\.api import call' src/praisonai src/praisonai-codeRepository: MervinPraison/PraisonAI
Length of output: 9247
π Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== inbuilt_tools ==\n'
sed -n '1,120p' src/praisonai/praisonai/cli/legacy/inbuilt_tools.py
printf '\n== praisonai_code cli main around _get_call_module ==\n'
sed -n '70,120p' src/praisonai-code/praisonai_code/cli/main.py
printf '\n== praisonai_code legacy praison_ai around _get_call_module ==\n'
sed -n '60,100p' src/praisonai-code/praisonai_code/cli/legacy/praison_ai.pyRepository: MervinPraison/PraisonAI
Length of output: 4608
π Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
import importlib.util
spec = importlib.util.find_spec("praisonai.api.call")
print("spec:", spec)
PYRepository: MervinPraison/PraisonAI
Length of output: 339
π Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== full inbuilt_tools with line numbers ==\n'
cat -n src/praisonai/praisonai/cli/legacy/inbuilt_tools.py
printf '\n== search for similar import guards ==\n'
rg -n 'find_spec\("praisonai\.api\.call"\)|except ImportError as exc|Call feature is not installed' src/praisonai src/praisonai-codeRepository: MervinPraison/PraisonAI
Length of output: 5763
π Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== callers of get_call_module in wrapper package ==\n'
rg -n -C4 'get_call_module\(' src/praisonai src/praisonai-codeRepository: MervinPraison/PraisonAI
Length of output: 4340
π Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C3 'import_wrapper_module\("praisonai\.cli\.legacy\.inbuilt_tools"\)|from praisonai\.cli\.legacy\.inbuilt_tools import|get_call_module\(' src/praisonai src/praisonai-codeRepository: MervinPraison/PraisonAI
Length of output: 7100
Avoid masking unrelated import failures here β use the same find_spec("praisonai.api.call") guard used elsewhere, or let other ImportErrors bubble up. Right now any import problem inside praisonai.api.call is reported as a missing praisonai[call] extra.
π€ Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/praisonai/praisonai/cli/legacy/inbuilt_tools.py` around lines 27 - 32,
Update the import handling around call_module in the legacy inbuilt-tools
initialization to use the existing find_spec("praisonai.api.call") guard, or
otherwise only translate a confirmed missing optional module into the
installation message. Let ImportError exceptions raised within
praisonai.api.call propagate unchanged instead of masking them as a missing
extra.
Fixes #3168
Summary
The
callfeature's availability guard usedimportlib.util.find_spec("praisonai.api.call"), which succeeds whenever the wrapper submodule file exists on disk. It did not detect the missing third-party dependencies (fastapi,twilio,websockets,pyngrok) thatpraisonai/api/call.pyimports at module top, so the friendly hint never fired and users saw a rawImportError: No module named 'fastapi'.Change
Replaced the ineffective
find_speccheck inget_call_module(praisonai/cli/legacy/inbuilt_tools.py) with atry/except ImportErroraround the real import, re-raising the existing friendly install message. This mirrors the correct pattern already used inapi/agent_invoke.py.Notes
praisonai[call]optional-dependency set are unchanged.call.pyloads only on demand) β correctness/UX fix, not an import-time regression.Generated with Claude Code
Summary by CodeRabbit