Skip to content

feat(agents): refine file analysis routing#76

Merged
69gg merged 5 commits into
mainfrom
feature/prompt-improvement
Jun 21, 2026
Merged

feat(agents): refine file analysis routing#76
69gg merged 5 commits into
mainfrom
feature/prompt-improvement

Conversation

@69gg

@69gg 69gg commented Jun 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • Merge arXiv paper analysis into file_analysis_agent, add PDF page visual description support, and remove the standalone arxiv_analysis_agent.
  • Add output_mode=uid attachment output paths for arXiv papers and Bilibili videos, with docs and tests updated.
  • Refine Agent intro/prompt boundaries to reduce routing confusion across file analysis, project code, web/info, summary, entertainment, and Naga tasks.
  • Bump all release manifests and locks to 3.6.1, add the v3.6.1 changelog entry, and fix scripts/bump_version.py so JSON version updates preserve Tauri/Biome formatting.

Tests

  • uv run pytest tests/test_bump_version_script.py
  • npm run lint in apps/undefined-console
  • npm run lint in apps/undefined-chat
  • uv run pytest tests/test_bump_version_script.py tests/test_changelog.py tests/test_release_notes_script.py
  • pre-commit via git commit:
    • uv run ruff format --check .
    • uv run ruff check .
    • uv run mypy .
    • npm run check in apps/undefined-console
    • npm run check in apps/undefined-chat

Summary by CodeRabbit

  • New Features
    • File analysis now supports arXiv papers and Bilibili videos via attachment UID handoff.
    • Added targeted PDF page visual description (per-page multimodal summaries).
    • Media tools now support a UID-only mode for chaining into file analysis.
  • Bug Fixes
    • Fixed the version bump script to preserve JSON formatting correctly.
  • Documentation
    • Refreshed agent/tool documentation to clarify capabilities, inputs, and routing boundaries.
  • Chores
    • Bumped version to 3.6.1 across the apps and package manifests.

69gg and others added 3 commits June 21, 2026 10:35
Tests: uv run pytest tests/

Co-authored-by: GPT-5 Codex <noreply@openai.com>
Co-authored-by: GPT-5 Codex <noreply@openai.com>
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jun 21, 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: e8e8e779-3f8d-4407-baab-29f1df317ab9

📥 Commits

Reviewing files that changed from the base of the PR and between 9f7f7b2 and 1e93175.

📒 Files selected for processing (5)
  • src/Undefined/bilibili/sender.py
  • src/Undefined/skills/agents/file_analysis_agent/tools/describe_pdf_page/handler.py
  • src/Undefined/utils/io.py
  • tests/test_agent_tool_registry.py
  • tests/test_arxiv_tools.py
🚧 Files skipped from review as they are similar to previous changes (4)
  • tests/test_agent_tool_registry.py
  • tests/test_arxiv_tools.py
  • src/Undefined/bilibili/sender.py
  • src/Undefined/skills/agents/file_analysis_agent/tools/describe_pdf_page/handler.py

📝 Walkthrough

Walkthrough

Version 3.6.1 removes the standalone arxiv_analysis_agent and instead routes arXiv paper analysis through file_analysis_agent via a new output_mode=uid parameter added to both arxiv_paper and bilibili_video tools. A new describe_pdf_page tool enables per-page visual analysis of PDFs. Multiple agent prompt/intro files are rewritten for clearer capability boundaries, and bump_version.py gains a format-preserving JSON field updater.

Changes

v3.6.1: arXiv/Bilibili UID mode, file_analysis_agent expansion, agent routing convergence

Layer / File(s) Summary
Remove standalone arxiv_analysis_agent
src/Undefined/skills/agents/arxiv_analysis_agent/config.json, src/Undefined/skills/agents/arxiv_analysis_agent/intro.md, src/Undefined/skills/agents/web_agent/callable.json
Deletes all files implementing the dedicated arxiv_analysis_agent (schema, handler, intro, prompt, fetch_paper and read_paper_pages tools). Removes arxiv_analysis_agent from web_agent's allowed_callers list and deletes the corresponding test file.
output_mode=uid for arxiv_paper and bilibili_video tools
src/Undefined/arxiv/sender.py, src/Undefined/bilibili/sender.py, src/Undefined/skills/tools/arxiv_paper/config.json, src/Undefined/skills/tools/arxiv_paper/callable.json, src/Undefined/skills/tools/arxiv_paper/handler.py, src/Undefined/skills/tools/bilibili_video/config.json, src/Undefined/skills/tools/bilibili_video/callable.json, src/Undefined/skills/tools/bilibili_video/handler.py, src/Undefined/utils/io.py, tests/test_arxiv_tools.py, tests/test_bilibili_sender.py
Adds fetch_arxiv_paper_attachment and fetch_bilibili_video_attachment to their respective sender modules with supporting helpers. Extends both tool schemas with an output_mode enum (send/uid). In uid mode, handlers skip message sending and register the downloaded file with AttachmentRegistry, returning <attachment uid="file_xxx"/>. Adds callable.json restricting both tools to file_analysis_agent. Introduces get_file_size async utility. Regression tests verify UID registration, record resolution, file contents, and cleanup.
file_analysis_agent expanded + new describe_pdf_page tool
src/Undefined/skills/agents/file_analysis_agent/config.json, src/Undefined/skills/agents/file_analysis_agent/intro.md, src/Undefined/skills/agents/file_analysis_agent/prompt.md, src/Undefined/skills/agents/file_analysis_agent/README.md, src/Undefined/skills/agents/file_analysis_agent/tools/describe_pdf_page/config.json, src/Undefined/skills/agents/file_analysis_agent/tools/describe_pdf_page/handler.py, tests/test_agent_tool_registry.py, tests/test_file_analysis_pdf_page.py
Updates file_analysis_agent schema and prompt to accept arXiv/Bilibili identifiers as inputs via the shared callable tools. Adds describe_pdf_page tool: parses mixed page ranges, renders each PDF page to PNG at configurable DPI, calls multimodal analysis per page, and aggregates results. Tests cover page-range parsing, per-call 5-page limit, out-of-bounds rejection, and verify that file_analysis_agent sees arxiv_paper/bilibili_video while info_agent does not.
Agent capability boundary prompt/intro rewrites
src/Undefined/skills/agents/web_agent/intro.md, src/Undefined/skills/agents/web_agent/prompt.md, src/Undefined/skills/agents/info_agent/intro.md, src/Undefined/skills/agents/info_agent/prompt.md, src/Undefined/skills/agents/naga_code_analysis_agent/intro.md, src/Undefined/skills/agents/naga_code_analysis_agent/prompt.md, src/Undefined/skills/agents/entertainment_agent/intro.md, src/Undefined/skills/agents/entertainment_agent/prompt.md, src/Undefined/skills/agents/summary_agent/intro.md, src/Undefined/skills/agents/summary_agent/prompt.md, src/Undefined/skills/agents/undefined_self_code_agent/intro.md, src/Undefined/skills/agents/undefined_self_code_agent/prompt.md, src/Undefined/skills/agents/code_delivery_agent/intro.md, src/Undefined/skills/agents/code_delivery_agent/prompt.md, src/Undefined/skills/agents/README.md, tests/test_naga_code_analysis_agent.py
Rewrites intro.md and prompt.md for seven agents to a consistent "能力边界/工具使用原则/回答要求" structure with explicit cross-agent delegation rules. Adds summary_agent and code_delivery_agent entries to the agents README. Updates naga_code_analysis_agent test assertions to match revised boundary wording.
bump_version.py: format-preserving JSON field update
scripts/bump_version.py, scripts/README.md, tests/test_bump_version_script.py
Adds _update_json_string_field which validates the target field exists as a string, then replaces its value via regex while preserving all existing JSON formatting. Switches package.json and tauri.conf.json version updates to this helper. Tests assert that "targets" bundle entries survive the version bump unchanged.
Version bump to 3.6.1, changelog, and docs
pyproject.toml, src/Undefined/__init__.py, apps/undefined-chat/package.json, apps/undefined-chat/src-tauri/Cargo.toml, apps/undefined-chat/src-tauri/tauri.conf.json, apps/undefined-console/package.json, apps/undefined-console/src-tauri/Cargo.toml, apps/undefined-console/src-tauri/tauri.conf.json, CHANGELOG.md, README.md, ARCHITECTURE.md, docs/usage.md, docs/configuration.md, docs/pipelines.md, src/Undefined/skills/tools/arxiv_paper/README.md, src/Undefined/skills/tools/bilibili_video/README.md
Bumps version string to 3.6.1 across all manifests. Adds v3.6.1 changelog entry. Updates README, architecture diagram, and user/configuration/pipeline docs to reflect the new UID-output capability and consolidated file analysis routing.

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant file_analysis_agent
  participant arxiv_paper_tool
  participant AttachmentRegistry
  participant describe_pdf_page
  User->>file_analysis_agent: request arXiv or Bilibili content analysis
  file_analysis_agent->>arxiv_paper_tool: execute with output_mode uid
  arxiv_paper_tool->>AttachmentRegistry: register downloaded file
  AttachmentRegistry-->>arxiv_paper_tool: return attachment uid
  arxiv_paper_tool-->>file_analysis_agent: return uid reference
  file_analysis_agent->>describe_pdf_page: analyze selected pages
  describe_pdf_page-->>file_analysis_agent: return page summaries
  file_analysis_agent-->>User: return analysis result
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐇 The arXiv agent hops away,
Its job now merged in a unified way.
A UID is born, a PDF stored,
describe_pdf_page renders every word!
Prompts rewritten, boundaries clear —
Version 3.6.1 is finally here! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.30% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat(agents): refine file analysis routing' directly reflects the main change: merging arXiv analysis into file_analysis_agent and removing the standalone arxiv_analysis_agent to refine routing.
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 docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/prompt-improvement

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
tests/test_agent_tool_registry.py (1)

161-208: ⚡ Quick win

Add explicit type hints to local variables for strict mypy compliance.

The test functions lack explicit type annotations for tools_dir, registry, and names. Per the coding guidelines, all Python code must have complete type annotations for strict mypy mode.

Add type hints
from pathlib import Path
from src.Undefined.skills.agents.agent_tool_registry import AgentToolRegistry
from typing import Any

def test_file_analysis_agent_can_see_shared_media_fetch_tools() -> None:
    tools_dir: Path = (
        Path(__file__).resolve().parent.parent
        / "src"
        / "Undefined"
        / "skills"
        / "agents"
        / "file_analysis_agent"
        / "tools"
    )
    registry: AgentToolRegistry = AgentToolRegistry(
        tools_dir,
        current_agent_name="file_analysis_agent",
        is_main_agent=False,
    )
    names: set[str] = {
        schema["function"]["name"]
        for schema in registry.get_tools_schema()
        if "function" in schema
    }

    assert "arxiv_paper" in names
    assert "bilibili_video" in names

def test_other_agents_cannot_see_file_analysis_media_fetch_tools() -> None:
    tools_dir: Path = (
        Path(__file__).resolve().parent.parent
        / "src"
        / "Undefined"
        / "skills"
        / "agents"
        / "info_agent"
        / "tools"
    )
    registry: AgentToolRegistry = AgentToolRegistry(
        tools_dir,
        current_agent_name="info_agent",
        is_main_agent=False,
    )
    names: set[str] = {
        schema["function"]["name"]
        for schema in registry.get_tools_schema()
        if "function" in schema
    }

    assert "arxiv_paper" not in names
    assert "bilibili_video" not in names
🤖 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 `@tests/test_agent_tool_registry.py` around lines 161 - 208, Add explicit type
annotations to all local variables in both test functions to comply with strict
mypy mode. In test_file_analysis_agent_can_see_shared_media_fetch_tools() and
test_other_agents_cannot_see_file_analysis_media_fetch_tools(), annotate
tools_dir with type Path, registry with type AgentToolRegistry, and names with
type set[str]. These type hints should be added directly after the variable
names in their assignment statements.

Source: Coding guidelines

🤖 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/Undefined/bilibili/sender.py`:
- Around line 466-467: The synchronous `video_path.stat()` calls at the lines
where `file_size_mb` is calculated and at the similar location at line 488 are
blocking disk I/O on the event loop within an async function. Replace these
blocking synchronous stat() calls with async-safe file operations from
`src/Undefined/utils/io.py` that use asyncio.to_thread for non-blocking I/O, and
ensure you await the result when obtaining the file size to calculate
`file_size_mb`. Import and use the appropriate async file-size reading utility
from `utils/io.py` instead of direct `.stat()` calls.

In
`@src/Undefined/skills/agents/file_analysis_agent/tools/describe_pdf_page/handler.py`:
- Around line 84-87: The execute function in the handler performs blocking file
I/O operations directly on the event loop, which violates project guidelines.
Replace the path.exists() and path.is_file() calls on lines 84-86 with their
async equivalents from src/Undefined/utils/io.py (the exists() and is_file()
functions). Wrap the blocking fitz.open() call on line 97 with
asyncio.to_thread() to make it non-blocking. Wrap the blocking pix.save()
operation on line 109 with asyncio.to_thread() as well. Replace the blocking
file and directory deletion operations on lines 131, 135, and 138 with the async
delete_file() and delete_tree() utilities from utils/io.py. Ensure all these I/O
operations are properly awaited in the execute function to follow the async
pattern established in utils/io.py.

In `@tests/test_arxiv_tools.py`:
- Line 60: The test function uses blocking file I/O operations
Path.write_bytes() and Path.read_bytes() which block the event loop in an async
test. Replace the blocking Path.write_bytes(b"%PDF-1.4") call with await
io.write_bytes(pdf_path, b"%PDF-1.4"), and similarly replace the blocking
Path.read_bytes() call at line 121 with await
io.read_bytes(Path(record.local_path or "")). Import io from Undefined.utils.io
at the top of the test file to access these async-safe file I/O utilities that
use asyncio.to_thread() for non-blocking operations.

---

Nitpick comments:
In `@tests/test_agent_tool_registry.py`:
- Around line 161-208: Add explicit type annotations to all local variables in
both test functions to comply with strict mypy mode. In
test_file_analysis_agent_can_see_shared_media_fetch_tools() and
test_other_agents_cannot_see_file_analysis_media_fetch_tools(), annotate
tools_dir with type Path, registry with type AgentToolRegistry, and names with
type set[str]. These type hints should be added directly after the variable
names in their assignment statements.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: ca8f38c8-b37c-4590-9586-afa7aab79a71

📥 Commits

Reviewing files that changed from the base of the PR and between 049f94a and 9f7f7b2.

⛔ Files ignored due to path filters (5)
  • apps/undefined-chat/package-lock.json is excluded by !**/package-lock.json
  • apps/undefined-chat/src-tauri/Cargo.lock is excluded by !**/*.lock
  • apps/undefined-console/package-lock.json is excluded by !**/package-lock.json
  • apps/undefined-console/src-tauri/Cargo.lock is excluded by !**/*.lock
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (66)
  • ARCHITECTURE.md
  • CHANGELOG.md
  • README.md
  • apps/undefined-chat/package.json
  • apps/undefined-chat/src-tauri/Cargo.toml
  • apps/undefined-chat/src-tauri/tauri.conf.json
  • apps/undefined-console/package.json
  • apps/undefined-console/src-tauri/Cargo.toml
  • apps/undefined-console/src-tauri/tauri.conf.json
  • docs/configuration.md
  • docs/pipelines.md
  • docs/usage.md
  • pyproject.toml
  • scripts/README.md
  • scripts/bump_version.py
  • src/Undefined/__init__.py
  • src/Undefined/arxiv/sender.py
  • src/Undefined/bilibili/sender.py
  • src/Undefined/skills/agents/README.md
  • src/Undefined/skills/agents/arxiv_analysis_agent/__init__.py
  • src/Undefined/skills/agents/arxiv_analysis_agent/callable.json
  • src/Undefined/skills/agents/arxiv_analysis_agent/config.json
  • src/Undefined/skills/agents/arxiv_analysis_agent/handler.py
  • src/Undefined/skills/agents/arxiv_analysis_agent/intro.md
  • src/Undefined/skills/agents/arxiv_analysis_agent/prompt.md
  • src/Undefined/skills/agents/arxiv_analysis_agent/tools/__init__.py
  • src/Undefined/skills/agents/arxiv_analysis_agent/tools/fetch_paper/config.json
  • src/Undefined/skills/agents/arxiv_analysis_agent/tools/fetch_paper/handler.py
  • src/Undefined/skills/agents/arxiv_analysis_agent/tools/read_paper_pages/config.json
  • src/Undefined/skills/agents/arxiv_analysis_agent/tools/read_paper_pages/handler.py
  • src/Undefined/skills/agents/code_delivery_agent/intro.md
  • src/Undefined/skills/agents/code_delivery_agent/prompt.md
  • src/Undefined/skills/agents/entertainment_agent/intro.md
  • src/Undefined/skills/agents/entertainment_agent/prompt.md
  • src/Undefined/skills/agents/file_analysis_agent/README.md
  • src/Undefined/skills/agents/file_analysis_agent/config.json
  • src/Undefined/skills/agents/file_analysis_agent/intro.md
  • src/Undefined/skills/agents/file_analysis_agent/prompt.md
  • src/Undefined/skills/agents/file_analysis_agent/tools/describe_pdf_page/config.json
  • src/Undefined/skills/agents/file_analysis_agent/tools/describe_pdf_page/handler.py
  • src/Undefined/skills/agents/info_agent/intro.md
  • src/Undefined/skills/agents/info_agent/prompt.md
  • src/Undefined/skills/agents/naga_code_analysis_agent/intro.md
  • src/Undefined/skills/agents/naga_code_analysis_agent/prompt.md
  • src/Undefined/skills/agents/summary_agent/intro.md
  • src/Undefined/skills/agents/summary_agent/prompt.md
  • src/Undefined/skills/agents/undefined_self_code_agent/intro.md
  • src/Undefined/skills/agents/undefined_self_code_agent/prompt.md
  • src/Undefined/skills/agents/web_agent/callable.json
  • src/Undefined/skills/agents/web_agent/intro.md
  • src/Undefined/skills/agents/web_agent/prompt.md
  • src/Undefined/skills/tools/arxiv_paper/README.md
  • src/Undefined/skills/tools/arxiv_paper/callable.json
  • src/Undefined/skills/tools/arxiv_paper/config.json
  • src/Undefined/skills/tools/arxiv_paper/handler.py
  • src/Undefined/skills/tools/bilibili_video/README.md
  • src/Undefined/skills/tools/bilibili_video/callable.json
  • src/Undefined/skills/tools/bilibili_video/config.json
  • src/Undefined/skills/tools/bilibili_video/handler.py
  • tests/test_agent_tool_registry.py
  • tests/test_arxiv_analysis_agent.py
  • tests/test_arxiv_tools.py
  • tests/test_bilibili_sender.py
  • tests/test_bump_version_script.py
  • tests/test_file_analysis_pdf_page.py
  • tests/test_naga_code_analysis_agent.py
💤 Files with no reviewable changes (10)
  • src/Undefined/skills/agents/arxiv_analysis_agent/intro.md
  • src/Undefined/skills/agents/arxiv_analysis_agent/tools/fetch_paper/config.json
  • src/Undefined/skills/agents/arxiv_analysis_agent/handler.py
  • tests/test_arxiv_analysis_agent.py
  • src/Undefined/skills/agents/arxiv_analysis_agent/prompt.md
  • src/Undefined/skills/agents/arxiv_analysis_agent/tools/read_paper_pages/config.json
  • src/Undefined/skills/agents/arxiv_analysis_agent/tools/read_paper_pages/handler.py
  • src/Undefined/skills/agents/arxiv_analysis_agent/tools/fetch_paper/handler.py
  • src/Undefined/skills/agents/arxiv_analysis_agent/config.json
  • src/Undefined/skills/agents/arxiv_analysis_agent/callable.json

Comment thread src/Undefined/bilibili/sender.py Outdated
Comment thread tests/test_arxiv_tools.py Outdated
@69gg 69gg merged commit 5c9fa5e into main Jun 21, 2026
4 checks passed
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