Back to Prompt Library
implementation
Add Web Scraping and Compliance Reasoning
Inspect the original prompt language first, then copy or adapt it once you know how it fits your workflow.
Linked challenge: Global Compliance Intelligence Agent
Format
Code-aware
Lines
16
Sections
5
Linked challenge
Global Compliance Intelligence Agent
Prompt source
Original prompt text with formatting preserved for inspection.
16 lines
5 sections
No variables
1 code block
Enhance your `PolicyExtractorAgent` to include a tool that performs web scraping using `BeautifulSoup` and `requests` (or `Playwright` for dynamic content) to fetch policy documents from specified URLs. Create a new agent method or a separate agent responsible for `ComplianceReport` generation. This agent should take a `TaxExemptionPolicy` and a `business_scenario` as input, use `Gemini 2.5 Pro` to reason about compliance, and output a validated `ComplianceReport`.
```python
from bs4 import BeautifulSoup
import requests
class WebScraperTool:
def scrape_url(self, url: str) -> str:
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
return soup.get_text()
class ComplianceAgent(PydanticAI):
def generate_report(self, policy: TaxExemptionPolicy, scenario: str) -> ComplianceReport:
# LLM call with prompt for compliance reasoning
pass
# Integrate WebScraperTool into PolicyExtractorAgent or orchestrate externally
# agent_with_scraper = PolicyExtractorAgent(llm_model=model, tools=[WebScraperTool()])
```Adaptation plan
Keep the source stable, then change the prompt in a predictable order so the next run is easier to evaluate.
Keep stable
Hold the task contract and output shape stable so generated implementations remain comparable.
Tune next
Update libraries, interfaces, and environment assumptions to match the stack you actually run.
Verify after
Test failure handling, edge cases, and any code paths that depend on hidden context or secrets.