---
title: "How Pinterest Improved Analytics Agent Compliance with Loop Engineering"
description: "Pinterest replaced trial-and-error prompt editing of its Analytics Agent with \"loop engineering\": an automated cycle that proposes small edits to the system prompt, skills, context layer or tools, then tests them against labeled real chats."
url: "https://swe.quest/articles/how-pinterest-improved-analytics-agent-compliance-with-loop-engineering-31a8cf0d84dd3d2b"
canonical: "https://medium.com/pinterest-engineering/how-pinterest-improved-analytics-agent-compliance-with-loop-engineering-d3c52d0abaa2"
source: "Pinterest Engineering"
published: "2026-11-12"
difficulty: "medium"
kind: "Case study"
reading_minutes: 11
tags: ["ai-agents","evals","llms","testing"]
---

# How Pinterest Improved Analytics Agent Compliance with Loop Engineering

A post on [Pinterest Engineering](https://swe.quest/sources/pinterest.md), published 2026-11-12, 11 min read, Case study. Original: [https://medium.com/pinterest-engineering/how-pinterest-improved-analytics-agent-compliance-with-loop-engineering-d3c52d0abaa2](https://medium.com/pinterest-engineering/how-pinterest-improved-analytics-agent-compliance-with-loop-engineering-d3c52d0abaa2)

## Summary

Pinterest replaced trial-and-error prompt editing of its Analytics Agent with "loop engineering": an automated cycle that proposes small edits to the system prompt, skills, context layer or tools, then tests them against labeled real chats. Each compliance rule gets paired required and skip suites, which reward following a step when it is needed and penalize unnecessary actions, plus a larger regression suite and a final holdout set. Iterations start from a fresh context but read a structured handoff recording scores, failing cases, the best change so far and approaches not to repeat. Up to four candidate edits are raced on a small sample, and the winner must pass repair/break, anti-overfitting critic and regression gates. A 10.3% run-to-run verdict flip rate showed that aggregate scores hide noise, so the loop tracks per-case flips instead of trusting small score gains.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [AI agents](https://swe.quest/tags/ai-agents.md) (AI & ML)
- [Evaluation](https://swe.quest/tags/evals.md) (AI & ML)
- [LLMs](https://swe.quest/tags/llms.md) (AI & ML)
- [Testing](https://swe.quest/tags/testing.md) (Engineering practices)

## Prerequisites

- LLM agents and tool use ([easy posts on LLMs](https://swe.quest/tags/llms.md?difficulty=easy))
- prompt engineering
- train/validation/holdout splits

## Keywords

Pinterest Analytics Agent, loop engineering, Ralph Wiggum loop, Claude, Promptimus, LLM-as-judge

## Related posts

- [The Art of Loop Engineering](https://swe.quest/articles/the-art-of-loop-engineering-1c4cd354dba11ffe.md): LangChain · 2026-10-29 · Easy · 6 min read · AI agents, LLMs, Evaluation
  Agent systems can be structured as four stacked loops: the basic agent loop (model calls tools until done), a verification loop where a deterministic or LLM grader checks output against a rubric and retries with feedback, an event-driven loop where crons, webhooks or Slack channels trigger background runs, and a hill-climbing loop where an analysis agent mines production traces to rewrite prompts, tools or graders.
- [Your Agent Aced the Task. Will It Do It Again?](https://swe.quest/articles/your-agent-aced-the-task-will-it-do-it-again-9e1e6a898bac9ad8.md): Hugging Face · 2026-09-15 · Medium · 11 min read · AI agents, Evaluation, LLMs
  LLM agents that score well on average often fail to repeat their successes: a GPT-4.1 ReAct agent on AppWorld reaches 77.4% Mean@5 but only 53.0% Pass^5 (success on all five runs), a 24.4-point consistency gap, even at temperature 0.
- [How we used DSPy to turn AI evaluations into better responses in Dash chat](https://swe.quest/articles/how-we-used-dspy-to-turn-ai-evaluations-into-better-responses-in-dash-chat-742eadaf5e0748b5.md): Dropbox Tech · 2026-06-25 · Medium · 9 min read · Evaluation, LLMs, AI agents
  Dropbox improved its Dash chat agent with a two-stage DSPy loop.
- [Building production-ready agentic systems: Lessons from Shopify Sidekick](https://swe.quest/articles/building-production-ready-agentic-systems-lessons-from-shopify-sidekick-338be221de1210c1.md): Shopify Engineering · 2025-08-26 · Medium · 6 min read · AI agents, Evaluation, Model training, LLMs
  Shopify's Sidekick merchant assistant outgrew a monolithic system prompt once its tool count passed ~50, so the team moved to just-in-time instructions returned alongside tool results, which kept prompt caches intact and improved maintainability and metrics.
- [Improving the academic workflow: Introducing two AI agents for better figures and peer review](https://swe.quest/articles/improving-the-academic-workflow-introducing-two-ai-agents-for-better-figures-a376517a1cd034df.md): Google Research · 2026-04-08 · Easy · 6 min read · AI agents, LLMs, Evaluation
  Google Research presents two multi-agent research prototypes for academic workflows.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
