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.

Computed, not generated

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:

OperationWhat it doesExample use
sumAdds up values for a numeric fieldTotal clicks across a keyword set
avgArithmetic mean of a numeric fieldAverage position for filtered keywords
minSmallest value in the fieldBest ranking position in a set
maxLargest value in the fieldHighest impression count for a single keyword
countNumber of matching rowsKeywords matching a filter condition
groupSegments 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.

OperatorMeaningExample
eqExact matchpage eq /blog/seo-guide
gt / ltGreater / less thanposition gt 10
gte / lteGreater / less than or equalclicks gte 100
containsString contains (query/page fields)query contains seo
Tip

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

What's my total clicks across all keywords this month? I need the exact number
Group my keywords by page and show which page gets the most impressions
Calculate the average position for keywords containing 'seo' vs all other keywords

© 2026 Agentic SEO. All rights reserved.