--- title: Pr Webhook emoji: 📊 colorFrom: blue colorTo: gray sdk: docker pinned: false --- # PR Webhook with Code Review Agent A webhook service that integrates with a code review agent powered by Pydantic AI and enhanced with Logfire tracing. ## Features - **Code Review Agent**: Automated code review using Pydantic AI - **Logfire Tracing**: Comprehensive tracing and monitoring of agent runs - **Webhook Integration**: Handles pull request webhooks - **Structured Output**: Generates detailed code review reports ## Setup ### Environment Variables Create a `.env` file with the following variables: ```bash # Logfire Configuration LOGFIRE_API_KEY=your_logfire_api_key_here # Code Review Model CODE_REVIEW_MODEL=google-gla:gemini-2.5-pro ``` ### Installation ```bash pip install -r requirements.txt ``` ## Usage ### Running the Agent ```bash python agent/code_review.py ``` ### Using the Webhook The service will automatically trace all agent runs with detailed metrics including: - Execution time - Input/output sizes - Error tracking - Performance metrics ## Tracing Features The agent now includes comprehensive tracing with Logfire: - **Span Tracking**: Each major operation is wrapped in a tracing span - **Event Logging**: Key milestones are logged as events - **Error Handling**: Exceptions are automatically captured and traced - **Performance Metrics**: Input/output sizes and execution times are tracked - **Context Attributes**: Relevant metadata is attached to each span ## Architecture - `agent/code_review.py`: Main code review agent with Logfire tracing - `index.py`: Webhook endpoint handler - `tool.py`: Utility functions and webhook processing Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference