# How Pinterest Improved Analytics Agent Compliance with Loop Engineering

DevFeed: [How Pinterest Improved Analytics Agent Compliance with Loop Engineering](<https://devfeed.tech/articles/how-pinterest-improved-analytics-agent-compliance-with-loop-engineering-131438.md>)

Original publisher: [Read original article](<https://medium.com/pinterest-engineering/how-pinterest-improved-analytics-agent-compliance-with-loop-engineering-d3c52d0abaa2?source=rss----4c5a5f6279b6---4>)

Author: Pinterest Engineering

Published: 2026-11-12T16:01:06Z

Content type: article

Language: en

Sources: [Pinterest](<https://devfeed.tech/sources/pinterest-engineering-blog-medium.md>)

Topics: [Loop Engineering](<https://devfeed.tech/topics/loop-engineering.md>), [AI Agent](<https://devfeed.tech/topics/ai-agent.md>), [Test-driven development](<https://devfeed.tech/topics/tdd.md>), [reproducibility](<https://devfeed.tech/topics/reproducibility.md>)

Tags: [ads](<https://devfeed.tech/tags/ads.md>), [agent](<https://devfeed.tech/tags/agent.md>), [agent-evaluation](<https://devfeed.tech/tags/agent-evaluation.md>), [agentic-ai](<https://devfeed.tech/tags/agentic-ai.md>), [analytics](<https://devfeed.tech/tags/analytics.md>), [compliance](<https://devfeed.tech/tags/compliance.md>), [dashboards](<https://devfeed.tech/tags/dashboards.md>), [data-discovery](<https://devfeed.tech/tags/data-discovery.md>), [engineering](<https://devfeed.tech/tags/engineering.md>), [latency](<https://devfeed.tech/tags/latency.md>), [loop-engineering](<https://devfeed.tech/tags/loop-engineering.md>), [metadata](<https://devfeed.tech/tags/metadata.md>), [metrics](<https://devfeed.tech/tags/metrics.md>), [pinterest](<https://devfeed.tech/tags/pinterest.md>), [pipeline](<https://devfeed.tech/tags/pipeline.md>), [query](<https://devfeed.tech/tags/query.md>), [question](<https://devfeed.tech/tags/question.md>), [search](<https://devfeed.tech/tags/search.md>), [skill](<https://devfeed.tech/tags/skill.md>)

## AI overview

Pinterest's loop engineering process tunes its Analytics Agent through repeated, measured changes: people define compliance rules and safety boundaries, while the loop proposes and evaluates small edits to prompts, skills, context, or tools. For each rule, paired test suites check both whether the agent follows the rule when needed and skips it when unnecessary; validation, holdout, and broader regression suites help catch overfitting and collateral damage. Each fresh iteration receives a structured handoff of scores, failures, prior changes, and constraints. A change is kept only if it fixes more cases than it breaks, addresses a general pattern, and preserves protected performance. In Pinterest's internal evaluation, the process improved compliance without reducing performance on skip and regression suites; one source-search improvement required a backend change, labeled datasets, 12 loop iterations, and two verification runs. Results are limited: the reported 89.3% pooled pass rate was mostly gained in the first change, and 10.3% of cases changed verdict between runs. The evaluation used one base model and reasoning setting, and answer quality was not directly measured.

## Source excerpt

Skyler Zheng | Software Engineer II; Chris Moradi | Staff Data Scientist; Lu Liu | Staff Software Engineer; Aman Gairola | Manager II; Michael Chau | Manager II The Compliance ProblemCompliance means following the right steps at the right time Pinterest's Analytics Agent helps teams answer questions such as "How did query latency for the ads reporting pipeline change last week?" It searches the company's data ecosystem, analyzes the relevant information, and recommends an answer or course of action. Not every question requires the same steps. We call the agent compliant when it identifies and follows the steps that apply. Improving compliance is intended to make answers more consistent and reduce the risk of incomplete or inaccurate results. Examples include: Read the data-discovery skill when it needs help finding the right tools or sources. Inspect table metadata before writing SQL to learn what the columns mean, which filters are required, and whether the table has important usage notes. Search every relevant source type, including tables, dashboards, and metrics, rather than stopping at the first useful result. These are three examples from a broader set of compliance rules, and whether they apply depends on the question. If a user provides the appropriate table, the agent may not need the data-discovery skill, while an open-ended question may require a broader search. The agent must decide which rules apply and follow them when needed. That flexibility also makes compliance difficult. When the agent skips a required step, it may stop at the first table it finds, miss an important filter in the metadata, or overlook a certified metric with a more authoritative definition. It could then confidently report that "latency is down 4.2%."[1] The answer may sound reasonable while using the wrong definition, pipeline stage, or reporting window. Why manually revising the agent's instructions was not enough Measuring noncompliance showed us where the agent failed, but not