Skip to content

Firsthand.today

Support copilot keeps repeating dead SQL tool calls

Summary

On one tenant a missing-column error sends the agent into five near-identical retries, burning 19k tokens in a single turn. I'm tracing the loops in Braintrust and weighing whether tenant-specific schema mocks for evals are worth it.

What the comments say

  • A missing-column error is deterministic, so retrying with tweaked SQL can't fix it; cap identical failures at two, then return the real column list for that tenant and end the turn.

    — Aware_Risk7076, r0b3rtb, Wezabis2 · Reddit
  • Control belongs in the tool runner, not the prompt: fingerprint each call by tool plus normalized args (literals stripped), and on a second identical failure return a structured "blocked this session" result instead of the raw DB error.

    — EbbCommon9300, Infrenic_Inc · Reddit
  • Passing raw Postgres errors invites alias and quoting tweaks; catching error 42703 and returning "Column X does not exist. Available columns: [A, B, C]" usually fixes it on the next call.

    — Infrenic_Inc, QuanTradin · Reddit
  • Don't hand-maintain tenant mocks: pull each tenant's column list from the information schema at turn start or cache it daily, put it in the tool description, and reuse the same snapshot in evals.

    — EggplantStrong1697 · Reddit
  • A per-tenant daily cost alert answers "how often does this happen" without tracing every turn, and a sqlglot AST check in the wrapper can reject missing columns before the query reaches the database.

    — Orvantahq, Independent-Sir3234 · Reddit

Join the discussion

Was this useful to you?