Skip to content

Source the agent's withdrawal findings and widen its tools - #12

Merged
aymanazeem merged 4 commits into
mainfrom
fix/agent-findings-and-query-limits
Dec 1, 2026
Merged

aymanazeem merged 4 commits into
mainfrom
fix/agent-findings-and-query-limits

Conversation

@aymanazeem

@aymanazeem aymanazeem commented Dec 1, 2026 •

Copy link
Copy Markdown
Owner

Problem. The agent's instructions stated findings their sources don't support. They put network upgrades at about 70% of withdrawn projects' costs, where Berkeley Lab's PJM brief says 94%, and called cost "the dominant driver" of withdrawal, where the brief says "likely a key driver". They gave no source for cascading withdrawals, and told the agent to treat a quoted cost as an upper bound, which no source supports. The agent also couldn't write a query in steps with WITH, could hang on a runaway join, and couldn't search one project's report.

What changes.

  • The four findings follow Berkeley Lab's Queued Up 2026, its PJM cost brief and FERC Order No. 2023 (paragraphs 47, 49, 793, 798 and 799), and each ends with its source. The PJM costs are the network upgrade averages, the part closest to cost_per_kw, with the medians of total cost to show how uneven costs are.
  • The instructions say the research costs are in 2022 dollars per kW of nameplate capacity, while cost_per_kw is likely in its own study's dollars and per kW of the megawatts the study assessed, or of the panel's capacity when the study gives none, so a comparison between them is a rough guide. A quoted cost is a preliminary estimate that a later study can change. The upper-bound instruction is gone.
  • search_studies takes an optional queue_id and then searches only that project's report.
  • query_queue accepts a query that starts with WITH. A query still running after 10 seconds (QUERY_TIMEOUT_SECONDS) is stopped with a plain message. The tool reads at most 51 rows, shows the agent 50 and says if there were more, and refuses a result with two columns of the same name.
  • docs/decisions.md records the findings, the query limits and the one-project search. The README drops the limitation this fixes and describes the new limits, and future work drops the three items this PR does.

Verification.

  • make test: 210 passed offline, with the current main merged in. Six planted bugs each fail a test.
  • I checked each finding against its source on 30 November 2026: Berkeley Lab's brief (summary, section 3.2, footnotes 1, 3 and 4) and FERC's order (paragraphs 47, 49, 793, 798 and 799).
  • DuckDB refused every file and web read I tried, alone and inside a WITH.
  • Typical queries on the full panel of 7,666 projects took 7 to 38 milliseconds in four timed runs, far inside the 10-second limit.
  • Dry runs, on the full panel and the default 25 reports, none calling OpenAI:
    • make check finds the panel of 7,666 projects and the 25 reports.
    • make embed estimates 5,499 passages, 1,980,104 tokens and $0.0396, as on main.
    • make extract finds nothing to extract, because a dry run embeds nothing.
    • make eval wires all six questions and says 4 checks would be skipped.
    • python -m src.cli ask gives the dry-run reply, naming both tools.
  • CI: run 46558390847 passed on Python 3.11 and 3.14, 210 tests each, with 0 billable milliseconds.

Not checked against OpenAI's live API. This PR changes the agent's instructions and tools, which would normally need a paid make eval. The OpenAI account has no credits, so under the owner's waiver it merges on the offline tests, dry runs, free CI and review. Nothing has yet checked that the real model passes a queue_id when a question is about one project, weighs the findings sensibly or writes WITH queries that run. The paid evaluation comes first once credits arrive.

Review. Separate agents reviewed this work three times before this PR: two rounds on the first version, then the branch on 30 November, whose findings 22a3731 fixes. A further separate review, of 22a3731, was stopped before it reported. Before it stopped, it had confirmed that the other callers of query_projects still work with the new limits, and questioned how the docs described AG1-462's megawatts. My own final review of the whole diff after merging main found that the instructions and docs/decisions.md didn't say cost_per_kw divides by the panel's capacity when a study gives no megawatts. 619201b fixes both points. These last fixes had my review only.

The agent's instructions stated findings its sources don't support.
They put network upgrades at about 70 percent of withdrawn projects'
costs, where Berkeley Lab's PJM brief says 94 percent, and called cost
the dominant driver of withdrawal, where the brief says likely a key
driver. They gave no source for cascading withdrawals, and told the
agent to treat a quoted cost as an upper bound, which no source
supports. The agent also couldn't write a query in steps with WITH,
could hang on a runaway join, and couldn't search one project's report.

- The four findings follow Berkeley Lab's Queued Up 2026, its PJM cost
  brief and FERC Order No. 2023 (paragraphs 47, 49, 793, 798 and 799),
  and each ends with its source. The PJM costs are the network upgrade
  averages, the part closest to cost_per_kw, with the medians of total
  cost to show how uneven costs are.
- The instructions say the research costs are in 2022 dollars, while
  cost_per_kw is in its own study's dollars, and that a quoted cost is
  a preliminary estimate that a later study can change.
- search_studies takes an optional queue_id to search only that
  project's report.
- The agent's SQL may start with WITH. A query still running after 10
  seconds is stopped with a plain message.
- docs/decisions.md records the findings, the query limits and the
  one-project search. The README drops the limitation this fixes,
  describes the new limits, and cites FERC paragraph 49.

make test: 170 passed offline. A WITH that reads a file is refused, as
are the other file and web reads, alone and inside a WITH.
…kDB reports it

A review found gaps in the query limits and in the agent's findings.
A stop that lands while DuckDB streams a result back can surface as an
invalid input error, which passed through as a raw DuckDB error. The
tool read every row before keeping 50, so a huge result was loaded in
full. A result with two columns of the same name silently lost one.
The select guard let words like "selection" through. The findings
called 94 percent a share of total cost rather than of the average,
and the caveat didn't say the study's megawatts can differ from the
nameplate capacity Berkeley Lab divides by.

- query_projects turns any DuckDB error raised after the timer fired
  into the plain "was stopped" message, reads at most max_rows rows,
  and refuses repeated column names. query_queue asks for 51 rows, so
  it can say there were more than 50. MAX_QUERY_ROWS moves to config.
- The guard needs SELECT or WITH as a whole word.
- The findings say 94 percent of the average total cost, "their high
  costs", and that projects studied with a withdrawn one, not only
  those behind it, can be restudied and take on its shared costs. The
  caveat says the study's dollar year is Berkeley Lab's assumption.
- docs/decisions.md says why WITH adds no new risk, that only a join
  with no condition makes 450 billion combinations, why the row limit
  complements the time limit, and that nothing yet checks whether the
  live model passes a queue_id.

make test: 175 passed offline. Six planted bugs each fail a test,
including the stop reported as another error, which a stand-in for
the connection now raises every time.
cost_per_kw divides by the panel's capacity_mw when a study gives no
megawatts, as the README says, but the agent's instructions and
docs/decisions.md didn't say so. Both now do, and a test checks the
instructions.

docs/decisions.md also says that AG1-462's report studied 300 MW of
output, of which PJM counts 180 MW as capacity, and puts typical panel
queries under 50 milliseconds: four timed runs took 7 to 38.

make test: 210 passed offline.
@aymanazeem

Copy link
Copy Markdown
Owner Author

Evidence for 619201b, the head to be merged.

  • The checks job passed on Python 3.11 and 3.14 in run 46558390847, 210 tests each, with 0 billable milliseconds (from gh api repos/aymanazeem/Interconnection-Queue-Agent/actions/runs/46558390847/timing).
  • Locally, make test passed 210 tests, with the current main merged in.
  • The dry runs listed in the description ran on the full panel and the default 25 reports, and none called OpenAI.
  • Review: three separate reviews before this PR, and a fourth that was stopped before it reported. 619201b comes from my own final review, and had my review only.
  • Not checked against OpenAI's live API: whether the real model passes a queue_id, weighs the findings sensibly or writes WITH queries that run. The paid evaluation comes first once credits arrive.

@aymanazeem
aymanazeem merged commit 9223311 into main Dec 1, 2026
2 checks passed
@aymanazeem
aymanazeem deleted the fix/agent-findings-and-query-limits branch December 1, 2026 02:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant