Letting the Agent Pick Its Own SQL: A Snowflake Cortex Code Case Study
We ran the same Snowflake + AmpUp MCP workflow through two architectures. Cortex Code's autonomous agent loop, and a hand-coded Python orchestrator. The output specificity differed by 4×. The reason matters for any team building agents on a warehouse.
Last week we wrote up wiring our sales agent into Snowflake via Cortex Code . The MCP server, the live CRM-to-warehouse coordination, the agent loop that drafts AE briefings from public-company earnings transcripts. One question we left open: how much of that output quality came from coco’s autonomous tool use specifically, vs. just having an LLM in the loop?
So we ran the same workflow twice. Same Snowflake account, same warehouse data, same AmpUp MCP server, same prompt, same underlying frontier model. We swapped only the orchestration architecture:
- Run A: a hand-coded Python loop. We pre-fetch the data, feed the LLM one prepared excerpt per deal, then call one MCP tool per row. Same shape you’d build with frameworks like Deep Agents , the Claude Agent SDK , or OpenCode . The orchestration logic is yours to write and maintain.
- Run B: Snowflake Cortex Code (coco), running autonomously. The agent picks its own SQL queries, then follows up with MCP calls when it needs to.
The architectures differ only in who picks the tool calls. We expected a wash. We got a 4× delta in output specificity.
Setup (Identical for Both Runs)
| Layer | Where it came from |
|---|---|
| Live CRM data | AmpUp via MCP. Open opportunities, account names, deal owners, fetched live each run. No hydration into Snowflake. |
| Earnings transcripts | 247K speaker-annotated public-company transcripts, sitting inside Snowflake. |
| Ticker resolution | A live SQL query to map AmpUp account names to public-company tickers. |
| Action layer | AmpUp MCP, the email-draft tool. |
| Goal | ”For each deal, read transcript → write sales angle → draft Slack” |
The Only Thing That Changed
- Run A: 80 lines of Python orchestration. A frontier model is called via API, and we decide which tool runs when.
- Run B: Cortex Code, single prompt. The agent picks every tool call, all running inside the warehouse security boundary.
What’s Different
| Dimension | Run A: Hand-rolled loop | Run B: Cortex Code (autonomous) |
|---|---|---|
| Where the agent runs | Outside the warehouse, calling a frontier-model API | Inside Snowflake, with same governance plane as SQL workload |
| Tool selection | Hard-coded. The script always calls the same MCP tool for each row. | Autonomous. Coco picks SQL queries, then MCP lookups, then the draft tool, in whatever order it decides. |
| Data access | One pre-built JSON excerpt per deal, about 700 characters from the transcript | Repeated SQL calls to pull deeper transcript chunks, around 3,500+ characters examined |
| Glue code | About 80 lines (Python: Snowflake connector + an HTTP client) | Zero (single prompt) |
| End-to-end time | ~21s for 5 MCP calls (data prep separate) | ~34s including agent tool selection + multiple SQL passes |
| Cost | Per-token API charges plus Snowflake compute | $0.10 in Cortex Code inference credits, single bill |
| Output | 5 drafts, all created | 5 drafts, all created |
Same MCP outcome in both: 5 drafts in the AmpUp Tasks inbox. The interesting differences are in how the agent got there and what showed up in the angles.
What the LLM Extracted from Each Earnings Call
Same data in. Different agent. Look at the angle quality.
Helios Motors, AI and Autonomy Day, Dec 2025
Hand-rolled loop:
AI as accessible as running water. They are scaling sensor data ‘orders of magnitude’ for AV. (0 specific numbers)
Cortex Code:
Building in-house AI silicon (Atlas-1) for autonomous driving. Gen 3 platform launching late 2026 with 1,600 TOPS. Point-to-point self-driving rolling out 2026. (14 specific numbers/program names)
Coco went deeper. Read past the CEO’s poetic open and into the technical announcements. It surfaced the specific program names an AE could reference by name.
Threadworks, AGM Jan 2026
Hand-rolled loop:
AGM is procedural, low signal. Pull from the most recent quarterly earnings call separately. (deferred. Gave up on this transcript.)
Cortex Code:
Company nearly 4בd from $5B to $20B. Doubled growth rate to 16%. Declared AI/data as core capital allocation 7 years ago. $300B TAM with only 6% penetration. (11 specific numbers)
This is the headline finding. The hand-rolled loop (one pre-built excerpt) saw the procedural opening of the AGM and quit. Coco (issuing its own SQL queries) found the CEO’s vision section deeper in the transcript and pulled out the most quotable strategic frame in the deck.
Avionix, Q3 2025, Oct 2025
Hand-rolled loop: “4 new product lines plus a Westport University Health Institute health study. Multiple buying centers, expanding TAM.” Cortex Code: “Aviation +18% YoY. Certified auto-land on a twin-engine turboprop. Raising aviation guidance to 10%. Certified retrofit cockpit on a light business jet.”
Both found real signals. Coco’s are more specific to the AE’s segment (aviation, the actual deal context).
Ridepoint, Q4 2025, Feb 2026
Hand-rolled loop: “CFO Devon stepping down Feb 16. Mira takes over. Six-week procurement freeze risk.” Cortex Code: “CFO transition (Devon, Mira). Accelerating core business. Large and growing cash flows.”
The interesting case. The hand-rolled loop explicitly named the procurement-freeze risk as a sales tactic; coco stayed at the news-summary level. Both saw the same fact in the transcript. The difference came from how heavily we prompt-engineered the hand-rolled loop. We’d written a custom system prompt that knew about SaaS sales motions, while coco’s prompt was the same three sentences we used for every other deal. Lesson: prompt-craft can lift any host’s output. The autonomous loop wins when you don’t want to tune a system prompt for each scenario.
Lumagate, Q2 FY26, Jan 2026
Hand-rolled loop: “NSE op margin 15.6% vs 8.7% YoY. Expansion budget.” Cortex Code: “NSE rev +46% YoY. Data center 45% of mix. 5% workforce restructuring, $30M annual savings redirected.”
Different numbers, both correct, both useful. Coco pulled restructuring detail the hand-rolled loop didn’t surface.
Specificity Delta, Counted
| Deal | Hand-rolled (digits in angle) | Cortex Code (digits in angle) |
|---|---|---|
| Helios Motors | 0 | 14 |
| Avionix | 1 | 7 |
| Ridepoint | 2 | 0 |
| Lumagate | 6 | 7 |
| Threadworks | 0 | 11 |
| Average | 1.8 | 7.8 |
Coco’s numbers-per-angle is 4× higher. We didn’t optimize for this; it fell out of the autonomous tool-use pattern.
What This Tells Us About the Architecture
The bottleneck is data depth, not LLM smarts. Both runs use the same underlying frontier model. What changed the output quality was how much transcript the agent could pull. When tool use is autonomous, the agent re-queries until it has enough context. When it’s hard-coded, it gets one shot.
Agent-driven SQL is the value prop. The single biggest difference between the two runs was that coco issued multiple SQL queries to inspect transcript chunks on its own. We could have built the same behavior into our Python loop. It just would have been one more orchestration layer to design, ship, and maintain. Cortex Code does it for free as a side effect of “figure out the right tools.”
The MCP layer is invariant. Both runs called the same tool with the same arguments. The drafts produced look stylistically identical because the MCP server runs the prompt that produces the draft text. The agent just provides the steering. This is exactly the kind of separation MCP is designed for, and it’s what makes “the warehouse takes action” stop being a lock-in story.
The action surface is large, and safe. The email-draft tool we used above is one of about 100 AmpUp MCP actions: CRM writes, notetaker updates, deal-stage changes, task creation, calendar invites, Slack messages. Every action lands as a draft with audit trail and one-click undo. Whichever agent host the team picks, they get the same surface area and the same safety guarantees, because the action layer never moves.
AmpUp works inside or outside Snowflake. The CRM and meeting transcripts live in AmpUp by default, queried live via MCP. For teams that want everything consolidated, AmpUp can cache CRM and notetaker data into Snowflake on request. The architecture supports both: warehouse-as-system-of-record, or warehouse-as-analytical-companion. The agent loop doesn’t change.
Cortex Code keeps the loop inside the warehouse boundary. The hand-rolled loop calls a frontier model API from outside Snowflake. That means a second vendor on the contract, a second SOC 2 review, a separate audit log, and transcript text leaving the customer’s Snowflake account. With Cortex Code, every step is in the same security boundary the data team already trusts. For regulated industries this isn’t a nice-to-have; it’s the difference between a procurement cycle that takes a week and one that takes a quarter.
Pick the architecture to match the surface area. Then keep MCP constant so the choice doesn’t become a lock-in.
What You Should Pick
Heuristic from this experiment.
For most workflows (live demos, scheduled briefings, exploratory analytics, anything customer-facing), use an autonomous agent host. Cortex Code’s TUI is a real product surface, the depth-of-search payoff is real, the loop runs inside the warehouse, and you don’t have to write orchestration code that becomes obsolete the next time the schema changes. For deterministic batch use, run coco via its stream-json output mode. You get the same auditability as a Python loop with none of the glue code, and the work stays inside Snowflake.
For one-off scripts, ad-hoc data backfills, or prototypes that won’t ship, a hand-rolled Python loop is fine. Don’t pretend it’s strategic infrastructure. It’s a script.
In all three cases, keep the action layer (MCP) constant. That’s how you stop the agent host choice from becoming a lock-in decision. Today MCP is the only protocol that cleanly separates these concerns.
Our take: Cortex Code earned its place in our stack for every customer-facing surface. The Python loop stays in the prototyping drawer.
Try It on Your Own Data
The full demo is on GitHub. Schema, hydration script, agent loop, captured CLI output for both runs.
If you’re a Snowflake customer, the AmpUp MCP server installs in one click against your existing account. Coco talks to your CRM through MCP, your warehouse through SQL, and never leaves your security boundary. Ping us at rahulb@ampup.ai and we’ll wire it up against your pipeline data.
If you’re at Snowflake, we’d like a conversation about Snowflake Native App distribution and pulling Cortex Analyst and Cortex Search into this loop. We think agent-driven warehouse queries hitting an open-protocol action layer is the next thing every B2B SaaS company will want, and Snowflake is the most credible substrate to ship it on.
Written by

Rahul Balakavi
Co-Founder, AmpUp
Rahul is the co-founder of AmpUp. He leads engineering and product, bringing deep expertise in building AI-powered platforms that turn sales data into actionable intelligence.
Stay up to date with AmpUp
Follow AmpUp on LinkedInFollow us on LinkedIn for the latest on AI-powered revenue intelligence.