Skip to content

fix: fix package path error.#15

Merged
LeiGuo622 merged 1 commit into
mainfrom
fix/import-path-error
Apr 16, 2026
Merged

fix: fix package path error.#15
LeiGuo622 merged 1 commit into
mainfrom
fix/import-path-error

Conversation

@LeiGuo622
Copy link
Copy Markdown
Owner

No description provided.

Copilot AI review requested due to automatic review settings April 16, 2026 11:42
@LeiGuo622 LeiGuo622 merged commit 4c1c5e8 into main Apr 16, 2026
2 checks passed
@LeiGuo622 LeiGuo622 deleted the fix/import-path-error branch April 16, 2026 11:44
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts import/path handling in the prejudge LLM judging components to address a “package path” import error when executing the tools.

Changes:

  • Update judge_llm.py to add src/prejudge to sys.path and import JudgeAgent via from judge_agent import JudgeAgent.
  • Update judge_agent.py to add src/prejudge to sys.path and switch imports to from judge_tools ... / from judge_prompt ....

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/prejudge/judge_llm.py Changes path setup and imports to load JudgeAgent as a top-level module.
src/prejudge/judge_agent.py Adds import-time sys.path mutation and switches to top-level sibling imports for internal modules.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/prejudge/judge_llm.py
Comment on lines +38 to +43
# Add the directory containing judge_agent to path
_prejudge_path = Path(__file__).parent
if str(_prejudge_path) not in sys.path:
sys.path.insert(0, str(_prejudge_path))

from prejudge.judge_agent import JudgeAgent
from judge_agent import JudgeAgent
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Importing sibling modules by mutating sys.path and then using top-level imports (e.g., from judge_agent import JudgeAgent) makes prejudge behave differently depending on execution context, and can shadow/override unrelated modules named judge_agent. Since src/prejudge is a real package (has __init__.py), prefer package-relative imports (e.g., from .judge_agent import JudgeAgent) and avoid modifying sys.path here; if direct CLI execution is needed, prefer python -m prejudge.judge_llm / setting PYTHONPATH=src at the entrypoint instead of per-function path hacks.

Copilot uses AI. Check for mistakes.
Comment on lines +24 to +33
# Add current directory to path for imports
_prejudge_path = Path(__file__).parent
_src_path = Path(__file__).parent.parent
if str(_prejudge_path) not in sys.path:
sys.path.insert(0, str(_prejudge_path))
if str(_src_path) not in sys.path:
sys.path.insert(0, str(_src_path))

from prejudge.judge_tools import create_locate_symbol_tool, create_view_code_tool
from prejudge.judge_prompt import JUDGE_SYSTEM_PROMPT, JUDGE_USER_PROMPT
from judge_tools import create_locate_symbol_tool, create_view_code_tool
from judge_prompt import JUDGE_SYSTEM_PROMPT, JUDGE_USER_PROMPT
Copy link

Copilot AI Apr 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This adds src/prejudge (and src/) to sys.path at import time and switches to top-level imports (from judge_tools ..., from judge_prompt ...). Import-time sys.path mutation is a global side effect that can cause hard-to-debug module shadowing and makes the package’s import behavior depend on runtime order. Since prejudge is a package (see src/prejudge/__init__.py), prefer package-relative imports (e.g., from .judge_tools ..., from .judge_prompt ...) and remove the sys.path manipulation (or confine any path tweaks to the __main__ CLI path only).

Copilot uses AI. Check for mistakes.
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.

2 participants