feat: integrate Claude Agent SDK for code-aware research#1244
Conversation
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>
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
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)
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
claude-agent-sdkdependency to slackbotresearch_agent.pyto use ClaudeSDKClient with file access tools (Read, Grep, Glob, Bash).research_cache/prefect(works consistently in local and Docker)claude-haiku-4-5-20251001) for cost-effective researchghCLI guidance for searching GitHub discussions and issues.research_cache/to.gitignoreBenefits
parent.parent.parent.venvnavigationTesting
Tested with sandbox prototypes that successfully:
🤖 Generated with Claude Code