Skip to content

feat: integrate Claude Agent SDK for code-aware research#1244

Merged
zzstoatzz merged 4 commits into
mainfrom
add-claude-agent-sdk-research
Nov 18, 2025
Merged

feat: integrate Claude Agent SDK for code-aware research#1244
zzstoatzz merged 4 commits into
mainfrom
add-claude-agent-sdk-research

Conversation

@zzstoatzz
Copy link
Copy Markdown
Collaborator

Summary

Replace pydantic-ai research agent with Claude Agent SDK to enable direct source code inspection, eliminating hallucination by allowing the agent to read actual Prefect implementations.

Changes

  • Add claude-agent-sdk dependency to slackbot
  • Rewrite research_agent.py to use ClaudeSDKClient with file access tools (Read, Grep, Glob, Bash)
  • Clone-based source access: Agent clones/updates Prefect source to .research_cache/prefect (works consistently in local and Docker)
  • Switch to Claude Haiku 4.5 (claude-haiku-4-5-20251001) for cost-effective research
  • Add gh CLI guidance for searching GitHub discussions and issues
  • Add .research_cache/ to .gitignore

Benefits

  • No more hallucination: Agent reads actual code instead of guessing
  • Always accurate: Based on implementation, not docs
  • Self-verifying: Can verify its own answers by reading source
  • Community-aware: Can search GitHub discussions for verified patterns
  • Clean paths: No more parent.parent.parent.venv navigation

Testing

Tested with sandbox prototypes that successfully:

  • Clone/update Prefect source code
  • Search for event emission patterns
  • Read actual implementation files
  • Use Claude Haiku 4.5 model

🤖 Generated with Claude Code

Replace pydantic-ai research agent with Claude Agent SDK to enable direct
source code inspection, eliminating hallucination by allowing the agent to
read actual Prefect implementations.

Key changes:
- Add claude-agent-sdk dependency to slackbot
- Rewrite research_agent.py to use ClaudeSDKClient with file access tools
- Agent clones/updates Prefect source to .research_cache/prefect
- Use Claude Haiku 4.5 for cost-effective research
- Add gh CLI guidance for searching community discussions
- Add .research_cache/ to .gitignore

The agent now has Read, Grep, Glob, and Bash tools to verify everything
against actual source code instead of guessing from documentation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings November 7, 2025 16:14
Copy link
Copy Markdown
Contributor

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 refactors the Slackbot research agent to use Claude Agent SDK for direct source code inspection instead of documentation search. The agent now clones and reads the actual Prefect repository to verify information, reducing hallucination risks.

  • Replaces pydantic-ai based research agent with Claude Agent SDK implementation
  • Adds direct file system access (Read, Grep, Glob, Bash tools) for code inspection
  • Implements caching of cloned Prefect repository in .research_cache/

Reviewed Changes

Copilot reviewed 2 out of 4 changed files in this pull request and generated 1 comment.

File Description
examples/slackbot/src/slackbot/research_agent.py Complete refactor from structured pydantic-ai agent to Claude Agent SDK with code access tools
examples/slackbot/pyproject.toml Added claude-agent-sdk dependency
uv.lock Added claude-agent-sdk package and additional greenlet wheels for musllinux_1_2 platforms
.gitignore Excluded .research_cache/ directory from version control

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

# Use a consistent cache location relative to the app root
# In Docker: /app/.research_cache/prefect
# Locally: <marvin_repo>/.research_cache/prefect
app_root = Path(__file__).parent.parent.parent.parent.parent
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

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

Using five levels of .parent is fragile and error-prone. Consider using Path(__file__).resolve().parents[4] or defining a more robust method to find the app root, such as searching for a marker file (e.g., pyproject.toml) or using an environment variable.

Copilot uses AI. Check for mistakes.
Use /app/.research_cache for both local and Docker since Docker
WORKDIR is /app. No more parent navigation.
Works in both local and Docker:
- Locally: uses current working directory
- Docker: uses /app (the WORKDIR)
@zzstoatzz zzstoatzz merged commit f2e5280 into main Nov 18, 2025
4 checks passed
@zzstoatzz zzstoatzz deleted the add-claude-agent-sdk-research branch November 18, 2025 01:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants