Code Sandbox
Run programmatic calculations on your GSC data — sums, averages, groupings, and filtered breakdowns with zero hallucinated numbers.
Why It Exists
LLMs fabricate numbers. Ask a chatbot “what's my total clicks?” and it will produce a plausible figure that may be completely wrong. The Code Sandbox solves this — when the agent needs a numerical result, it calls the code_sandbox tool to run a real computation against your synced GSC data and return the exact answer.
Every number the agent reports from your GSC data comes from the Code Sandbox, not from the language model. The LLM handles reasoning and strategy; the sandbox handles arithmetic.
Available Operations
Six operations run against your synced GSC data for the current project:
| Operation | What it does | Example use |
|---|---|---|
| sum | Adds up values for a numeric field | Total clicks across a keyword set |
| avg | Arithmetic mean of a numeric field | Average position for filtered keywords |
| min | Smallest value in the field | Best ranking position in a set |
| max | Largest value in the field | Highest impression count for a single keyword |
| count | Number of matching rows | Keywords matching a filter condition |
| group | Segments by a field, returns sum/avg/count per group (top 20) | Clicks broken down by page URL |
Fields and Filters
Operations run on these fields: clicks, impressions, ctr (decimal, e.g. 0.05 = 5%), position, query, and page. Scope any operation to a subset using filters — a filter combines a field, operator, and value, and multiple filters can be applied together.
| Operator | Meaning | Example |
|---|---|---|
| eq | Exact match | page eq /blog/seo-guide |
| gt / lt | Greater / less than | position gt 10 |
| gte / lte | Greater / less than or equal | clicks gte 100 |
| contains | String contains (query/page fields) | query contains seo |
You don't need to know filter syntax. Describe what you want in plain English and the agent translates it into the correct operation, fields, and filters.
Grouping
The group operation segments your data by a field and returns sum, average, and count per segment (top 20). Group by page to see which URLs drive the most traffic, or by query to find keyword clusters.
“Group my keywords by page and show which page gets the most impressions”
Runs a group operation on the page field, returning total impressions, avg CTR, and keyword count per URL.
Example Prompts
“What's my total clicks across all keywords this month? I need the exact number”
Triggers a sum operation on the clicks field with no filter — returns the precise total.
“Calculate the average position for keywords containing 'seo' vs all other keywords”
Runs two avg operations with opposite contains filters and presents a side-by-side comparison.
“How many keywords have a CTR below 1% but more than 500 impressions?”
A count operation with two filters: ctr lte 0.01 and impressions gte 500.
Tips
- Ask for exact numbers — saying “exact number” signals the agent to use the Code Sandbox rather than estimate.
- Segment by position ranges — grouping by 1-3, 4-10, 11-20 gives an instant picture of your ranking distribution.
- Combine filters with grouping — e.g. “group by page but only for branded keywords” isolates branded traffic per URL.
- Pair with GSC Query — after pulling keywords with
gsc_query, ask aggregate follow-ups. The agent runs sandbox calculations on the same data context.
Try these prompts
© 2026 Agentic SEO. All rights reserved.