feat(agents): implement PRP-10 agentic layer with PydanticAI#55
Conversation
Post Phase-9 review updates: - Bump pydantic-ai from 0.1.0 to 1.48.0 (v1 stable release) - Update Claude model identifier to claude-sonnet-4-5 format - Add service method mappings for tool implementations - Add mock_pydantic_ai_agent fixture pattern - Increase confidence score from 7.5 to 8.0/10 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add full agentic layer for autonomous experiment orchestration and evidence-grounded Q&A: - Add PydanticAI agents (experiment, rag_assistant) with lazy initialization - Create agent tools for registry, backtesting, forecasting, and RAG - Implement AgentService with session management and approval workflow - Add REST routes and WebSocket streaming endpoint - Create Alembic migration for agent_session table with JSONB storage - Add 92 unit tests with full type checking coverage - Update config with agent settings (provider, model, session TTL) Human-in-the-loop approval required for create_alias and archive_run. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the
✨ Finishing touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Sorry @w7-mgfcode, your pull request is larger than the review limit of 150000 diff characters
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
- Mark Phase 9 as completed in PHASE-index.md with comprehensive summary - Create new docs/PHASE/9-AGENTIC_LAYER.md with full implementation details - Executive summary, deliverables, and architecture highlights - Database schema (agent_session table) - Agent definitions (Experiment Orchestrator, RAG Assistant) - Tool modules (registry, backtesting, forecasting, RAG) - Service layer API, REST routes, and WebSocket streaming - Configuration settings and environment variables - Test coverage (92 unit tests) and validation results - Directory structure and next phase preparation - Update README.md to include Agentic Layer - Add to Features section - Add comprehensive API endpoints section with examples - Update project structure to include agents/ and rag/ features Phase 9 implements PydanticAI-based agents for autonomous experimentation and evidence-grounded Q&A with human-in-the-loop approval workflow. Related: PR #55 (+7,835 additions, 92 unit tests) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
…ayer) - Update component diagram to include Agentic Layer and Agent Sessions - Update backend layout to include rag/ and agents/ features - Add comprehensive Section 9: RAG Knowledge Base (marked as IMPLEMENTED) - OpenAI and Ollama embedding providers - pgvector HNSW indexing, idempotent content hash - API endpoints, database schema, configuration - Location, tests, and migration details - Add comprehensive Section 10: Agentic Layer (marked as IMPLEMENTED) - PydanticAI agents (Experiment Orchestrator, RAG Assistant) - Session management with JSONB message history - Human-in-the-loop approval workflow - WebSocket streaming architecture - Tool integration, database schema, configuration - Location, tests, and dependencies - Update Section 11: Dashboard to include Agent Chat Interface - Renumber Quality section from 11 to 12 - Update Section 13: Roadmap with completed phases 0-9 - Detailed phase descriptions with PRP references - Phase 10 (Dashboard), 11 (ML Models), 12 (Production) as pending Phase 8 (PRP-9) and Phase 9 (PRP-10) now fully documented in architecture. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Fix Ruff formatting issues: - Reformat 7 files in app/features/agents/ Fix test failures: - test_create_session_invalid_type: change expected status from 400 to 422 (Pydantic validation) - test_health_with_agents: change expected status from 'healthy' to 'ok' (actual health endpoint response) Fix schema validation: - Import models in __init__.py to register AgentSession with SQLAlchemy metadata - Prevents "relation agent_session does not exist" error in alembic check All CI checks should now pass: - Ruff format: ✅ 7 files reformatted - Tests: ✅ 2 test assertions fixed - Schema validation: ✅ Models properly registered Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The agents models were not being imported in alembic/env.py, causing Alembic to not detect the agent_session table definition. This led to schema validation failures where Alembic thought the table should be removed. Fix: Add agents models import to alembic/env.py alongside other feature model imports.
The models import is now exported via __all__, so it's considered used and doesn't need the noqa: F401 directive.
Add comprehensive Google Gemini model support to PydanticAI agents: - Add google_api_key and agent_thinking_budget to Settings - Add model identifier validation (provider:model-name format) - Add fail-fast API key validation with clear error messages - Update agent creation to validate API keys before initialization - Support Gemini extended reasoning (thinking mode) for complex tasks Supported providers: - anthropic: Claude models (default) - openai: GPT models (fallback) - google-gla: Gemini via AI Studio (new) - google-vertex: Gemini via Vertex AI (new) Testing: - Add 9 configuration validation tests - All 101 agent tests pass - Type checking (mypy + pyright) green - Linting (ruff) green Documentation: - Update .env.example with Gemini configuration guide - Update Phase 9 docs with multi-provider table and reasoning guide - Zero breaking changes (backward compatible) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Apply ruff formatter to config and base agent files to fix CI lint check. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- .env.example: rename env vars to match Settings fields (AGENT_MAX_TOOL_CALLS, AGENT_REQUIRE_APPROVAL with JSON array format), update defaults to match config.py - config.py: validate model name is non-empty in model identifier - service.py: implement real action execution in approve_action instead of placeholder, add _execute_pending_action helper - backtesting_tools.py: fix docstring model types, add zero division guards in compare_backtest_results - forecasting_tools.py: fix docstring, add date range and horizon validation guards - registry_tools.py: add RunStatus validation before enum conversion - websocket.py: change to session-per-message pattern to prevent stale data and memory growth - docs/PHASE/9-AGENTIC_LAYER.md: update PR reference from #55 to #56 - README.md: update Agentic Layer config to match config.py Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary
Changes
agent_sessiontable with PostgreSQL JSONB storage/agents/sessions/*) and WebSocket endpoint (/agents/stream)Test plan
pytest app/features/agents/tests/ -m "not integration")docker-compose up -d)🤖 Generated with Claude Code