---
title: "Aggregation Pipeline"
description: "1 posts about Aggregation Pipeline, summarised, each linking to the original."
---

# Aggregation Pipeline
> 1 posts about Aggregation Pipeline, summarised, each linking to the original.

## Articles

### [Code Mode Without the Interpreter: Agents That Write Aggregation Pipelines](https://yomu.fyi/post/code-mode-without-the-interpreter-agents-that-write-aggregation-pipeli.md)
- Company: [MongoDB](https://yomu.fyi/company/mongodb.md)
- Published: Oct 7, 2026
- Type: Problem & solution

Fixed-tool document agents suffer multiple round trips and context window bloat because each call returns raw data, and cross-document relationships require pulling all files into the context. The author’s solution lets the agent write a MongoDB aggregation pipeline instead of arbitrary code, avoiding the security risks of a code interpreter. A handler validates the pipeline, prepends a tenancy filter, and executes it server-side, returning only the reshaped result. The agent uses a two-pass approach, often computing booleans or concatenating fields with $addFields so comparisons happen in the database. Limitations include regex not being semantic search and $limit silently truncating results, but the bounded language of nine permitted stages improves both safety and accuracy.
