Skip to content

Fix agentic_rag demos crashing on import (wrong kwarg + hardcoded PDF path)#245

Open
douxiao398 wants to merge 1 commit into
patchy631:mainfrom
douxiao398:fix/agentic-rag-documentsearchtool-kwarg
Open

Fix agentic_rag demos crashing on import (wrong kwarg + hardcoded PDF path)#245
douxiao398 wants to merge 1 commit into
patchy631:mainfrom
douxiao398:fix/agentic-rag-documentsearchtool-kwarg

Conversation

@douxiao398

@douxiao398 douxiao398 commented Jun 18, 2026

Copy link
Copy Markdown

While trying to run the agentic_rag demo I hit a TypeError the moment the crew module is imported. Digging in, it comes down to the tool being constructed with a keyword that doesn't exist on its constructor.

In agentic_rag/src/agentic_rag/crew.py the tool is created like this:

pdf_tool = DocumentSearchTool(pdf='/Users/akshaypachaar/Eigen/ai-engineering/agentic_rag/knowledge/dspy.pdf')

but DocumentSearchTool.__init__ (in tools/custom_tool.py) is actually defined as:

def __init__(self, file_path: str):

There is no pdf parameter, so importing crew.py fails with TypeError: __init__() got an unexpected keyword argument 'pdf'. Because that line runs at module load time, the demo can't even start.

There's a second problem hiding behind it: the PDF path is hardcoded to the original author's machine (/Users/akshaypachaar/...). So even once the keyword is fixed, it would still fail with FileNotFoundError for anyone else — even though each demo already ships its own copy at knowledge/dspy.pdf.

The exact same two issues exist in the agentic_rag_deepseek variant, so I fixed both.

What changed

  • Pass file_path= instead of the non-existent pdf= kwarg.
  • Resolve the bundled knowledge/dspy.pdf relative to crew.py with os.path, so it works no matter where the repo is cloned instead of pointing at one person's home directory.

Diff is small (2 files, the two crew.py entry points). Both modules now import cleanly and pick up the PDF that's already in each demo's knowledge/ folder.

Summary by CodeRabbit

Bug Fixes

  • Fixed PDF file path resolution by switching from hardcoded absolute paths to runtime relative path computation, so the bundled PDF can be found correctly across different machines and environments.

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6db95d8f-fb16-4016-a8d4-d47fa5ea5df1

📥 Commits

Reviewing files that changed from the base of the PR and between d98ca76 and 90a2926.

📒 Files selected for processing (2)
  • agentic_rag/src/agentic_rag/crew.py
  • agentic_rag_deepseek/src/agentic_rag/crew.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • agentic_rag/src/agentic_rag/crew.py
  • agentic_rag_deepseek/src/agentic_rag/crew.py

📝 Walkthrough

Walkthrough

Both agentic_rag and agentic_rag_deepseek crew modules replace a hard-coded absolute path to dspy.pdf with a dynamically computed PDF_PATH using os.path.join relative to __file__. The pdf_tool is re-initialized with DocumentSearchTool(file_path=PDF_PATH).

Changes

Portable PDF Path Resolution

Layer / File(s) Summary
Relative PDF path in both crew modules
agentic_rag/src/agentic_rag/crew.py, agentic_rag_deepseek/src/agentic_rag/crew.py
Adds os import and PDF_PATH = os.path.join(os.path.dirname(__file__), ...) in both files, replacing the hard-coded absolute path previously passed to DocumentSearchTool(pdf=...) with DocumentSearchTool(file_path=PDF_PATH).

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

  • patchy631/ai-engineering-hub#18: Modifies the same agentic_rag/src/agentic_rag/crew.py file to change how pdf_tool is instantiated with DocumentSearchTool, directly related to the same initialization pattern being updated here.

Poem

🐇 A path set in stone makes the bunny groan,
Hard-coded and brittle, it worked only at home.
With __file__ and os.path, we hop where we please,
The PDF now found on any machine with ease.
No more broken demos — just carrots and glee! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main issues being fixed: the incorrect kwarg name and the hardcoded PDF path that prevent the demos from importing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

… path

The agentic_rag and agentic_rag_deepseek demos crash on import: crew.py
calls DocumentSearchTool(pdf=...) but the tool constructor expects
file_path (custom_tool.py: def __init__(self, file_path: str)), raising
TypeError. The PDF path was also hardcoded to the original author's
absolute path (/Users/akshaypachaar/...), so it also fails with
FileNotFoundError on any other machine.

Fix both demos by:
- passing file_path= instead of the non-existent pdf= kwarg
- resolving the bundled knowledge/dspy.pdf relative to crew.py via os.path
  so the demo runs on any machine
@douxiao398 douxiao398 force-pushed the fix/agentic-rag-documentsearchtool-kwarg branch from d98ca76 to 90a2926 Compare June 18, 2026 13:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant