Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions bench/accuracy/codex_mcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ async def run(args):
raise ValueError("--exclude-passed-from requires --failures-from; never use exclusions for full accuracy")
repo = Path(__file__).resolve().parents[2]
manifest = json.loads(args.manifest.read_text())
input_case_count = len(manifest["cases"])
validate_inputs(manifest, args.db_dir)
if manifest["suite"] == "spider2":
validate_manifest(manifest, args.root, args.db_dir)
Expand All @@ -181,9 +182,19 @@ async def run(args):
db_sha256=manifest["db_sha256"],
)
logger.info("Failed-case selection source=%s selected=%d", args.failures_from, len(manifest["cases"]))
if not manifest["cases"]:
logger.info("No failed cases remain in the source run; no model calls made")
return
selected_case_count = len(manifest["cases"])
logger.info("Case selection split=%s input=%d selected=%d expected=%s",
args.split, input_case_count, selected_case_count, args.expected_cases)
if args.expected_cases is not None and (
args.expected_cases < 0 or selected_case_count != args.expected_cases
):
raise ValueError(
f"Selected {selected_case_count} cases, expected {args.expected_cases}; "
"check --split and failure/pass exclusions before starting inference"
)
if not manifest["cases"]:
logger.info("No cases remain after selection; no model calls made")
return
if args.output.exists():
raise ValueError("Use a fresh output directory; never overwrite attempts")
args.output.mkdir(parents=True)
Expand Down Expand Up @@ -223,6 +234,12 @@ async def run(args):
]
},
"schema_document_sha256": digest(args.schema_docs),
"case_selection": {
"split": args.split,
"input_cases": input_case_count,
"selected_cases": selected_case_count,
"expected_cases": args.expected_cases,
},
"review_source": str(args.review_source) if args.review_source else None,
"failure_selection": {
"source": str(args.failures_from),
Expand Down Expand Up @@ -425,6 +442,8 @@ def main():
parser.add_argument(
"--split", choices=["development", "all"], default="development"
)
parser.add_argument("--expected-cases", type=int,
help="Require this final selected count before any model call; includes split and failure/pass filtering")
parser.add_argument("--review-source", type=Path, help="Prior run directory; pass only prior model answer/tool observations, never scores")
parser.add_argument("--failures-from", type=Path, help="Run only score=0 cases from this completed run; grades select cases but never enter model prompts")
parser.add_argument("--exclude-passed-from", type=Path, action="append", default=[],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"partial_selection": {
"requested": 31,
"actual": 1,
"official_correct": 0,
"id": "bird146",
"cause": "Operator omitted --splitall; defaultdevelopment selectedonlyoneof31cases. Thisrunwasnotrestarted."
},
"guarded_run": {
"requested": 2,
"actual": 2,
"official_correct": 1,
"passed": [
"bird495"
],
"failed": [
"bird467"
],
"change": "Selectioncountassertion only relative tosameproduct/metadata candidate. Notacausalaccuracyimprovementclaimforguard."
},
"remaining30": "SeparatefreshliverunwithactualmanifestIDsverified30/30; notpartofthisarchive.",
"limits": [
"Failure-only probes,notfullaccuracy.",
"Officialdenominators/resultsretained; no overwrittenattempts.",
"No alreadyexecutedcaserepeated."
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"source_record_sha256": "ace676de777f7445298264e69be127e09c0485364387d43d2e98713f4a83a788",
"questions_sha256": "926af2a0d1b47e5d0d15a7aa8a34d4721007f4550a881555b6a89496b54a2606",
"db_sha256": "87583183c3dc472fba04de702965560a9d7c0a548836613f242317e0eeb83f00",
"sql_variants": {
"model": "SELECT COUNT(DISTINCT l.ID) AS patient_count\nFROM main.Laboratory AS l\nJOIN main.Patient AS p ON p.ID = l.ID\nWHERE l.\"Date\" BETWEEN '1981-01-01' AND '1986-12-31'\n AND l.\"Date\" >= p.Birthday\n AND l.\"Date\" < date(p.Birthday, '+50 years')\n AND l.PLT BETWEEN 100 AND 400\n AND (CAST(l.\"U-PRO\" AS REAL) > 0 OR l.\"U-PRO\" IN ('TR', '%%'))\nLIMIT 1",
"protein_predicate_only": "SELECT COUNT(DISTINCT l.ID) AS patient_count\nFROM main.Laboratory AS l\nJOIN main.Patient AS p ON p.ID = l.ID\nWHERE l.\"Date\" BETWEEN '1981-01-01' AND '1986-12-31'\n AND l.\"Date\" >= p.Birthday\n AND l.\"Date\" < date(p.Birthday, '+50 years')\n AND l.PLT BETWEEN 100 AND 400\n AND l.\"U-PRO\" IS NOT NULL AND l.\"U-PRO\" NOT IN ('-', '0')\nLIMIT 1",
"remove_unrequested_nonnegative_age_only": "SELECT COUNT(DISTINCT l.ID) AS patient_count\nFROM main.Laboratory AS l\nJOIN main.Patient AS p ON p.ID = l.ID\nWHERE l.\"Date\" BETWEEN '1981-01-01' AND '1986-12-31'\n AND l.\"Date\" < date(p.Birthday, '+50 years')\n AND l.PLT BETWEEN 100 AND 400\n AND (CAST(l.\"U-PRO\" AS REAL) > 0 OR l.\"U-PRO\" IN ('TR', '%%'))\nLIMIT 1",
"reference": "SELECT COUNT(DISTINCT p.ID) AS patient_count FROM Patient AS p JOIN Laboratory AS l ON l.ID = p.ID WHERE SUBSTR(l.Date, 1, 4) BETWEEN '1981' AND '1986' AND l.PLT BETWEEN 100 AND 400 AND p.Birthday IS NOT NULL AND (CAST(SUBSTR(l.Date, 1, 4) AS INTEGER) - CAST(SUBSTR(p.Birthday, 1, 4) AS INTEGER) - CASE WHEN SUBSTR(l.Date, 6, 5) < SUBSTR(p.Birthday, 6, 5) THEN 1 ELSE 0 END) < 50 AND l.\"U-PRO\" IS NOT NULL AND l.\"U-PRO\" NOT IN ('-', '0')"
},
"results": {
"model": [
[
71
]
],
"protein_predicate_only": [
[
71
]
],
"remove_unrequested_nonnegative_age_only": [
[
73
]
],
"reference": [
[
73
]
]
},
"added_patient_ids_without_chronology_filter": [
2047892,
3385021
],
"finding": "Changingonlyproteinpredicate doesnotfixcount. Removingmodel-addedtest-date>=birthdateconditionalone changes71to73matchingreference. The2addedpatientsqualifythroughpre-birthdatetestrecords.",
"limits": [
"Offlinecounterfactualonly;notmodelrepairorinput.",
"Originalofficialgrade0retained.",
"Do notsilentlyremovechronologyvalidationasgeneralproductpolicyjusttomatchreference."
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
patient_count
71
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bond_type,bond_count,element_pair_count,carcinogenicity_label
-,12,3,-
=,4,1,-
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
```sql
SELECT COUNT(DISTINCT l.ID) AS patient_count
FROM main.Laboratory AS l
JOIN main.Patient AS p ON p.ID = l.ID
WHERE l."Date" BETWEEN '1981-01-01' AND '1986-12-31'
AND l."Date" >= p.Birthday
AND l."Date" < date(p.Birthday, '+50 years')
AND l.PLT BETWEEN 100 AND 400
AND (CAST(l."U-PRO" AS REAL) > 0 OR l."U-PRO" IN ('TR', '%%'))
LIMIT 1
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{"type":"thread.started","thread_id":"01a21a1e-21a8-7731-87c9-fdc8fd1c6086"}
{"type":"turn.started"}
{"type":"item.completed","item":{"id":"item_0","type":"agent_message","text":"I’ll check the schema and stored dipstick readings, then run the distinct-patient count using your criteria."}}
{"type":"item.started","item":{"id":"item_1","type":"mcp_tool_call","server":"lang2sql","tool":"explore_schema","arguments":{"table":"Laboratory"},"result":null,"error":null,"status":"in_progress"}}
{"type":"item.completed","item":{"id":"item_1","type":"mcp_tool_call","server":"lang2sql","tool":"explore_schema","arguments":{"table":"Laboratory"},"result":{"content":[{"type":"text","text":"Laboratory (table)\n- ID: INTEGER NOT NULL\n- Date: DATE NOT NULL\n- GOT: INTEGER\n- GPT: INTEGER\n- LDH: INTEGER\n- ALP: INTEGER\n- TP: REAL\n- ALB: REAL\n- UA: REAL\n- UN: INTEGER\n- CRE: REAL\n- T-BIL: REAL\n- T-CHO: INTEGER\n- TG: INTEGER\n- CPK: INTEGER\n- GLU: INTEGER\n- WBC: REAL\n- RBC: REAL\n- HGB: REAL\n- HCT: REAL\n- PLT: INTEGER\n- PT: REAL\n- APTT: INTEGER\n- FG: REAL\n- PIC: INTEGER\n- TAT: INTEGER\n- TAT2: INTEGER\n- U-PRO: TEXT\n- IGG: INTEGER\n- IGA: INTEGER\n- IGM: INTEGER\n- CRP: TEXT\n- RA: TEXT\n- RF: TEXT\n- C3: INTEGER\n- C4: INTEGER\n- RNP: TEXT\n- SM: TEXT\n- SC170: TEXT\n- SSA: TEXT\n- SSB: TEXT\n- CENTROMEA: TEXT\n- DNA: TEXT\n- DNA-II: INTEGER\nPRIMARY KEY (ID, Date)\nFOREIGN KEY (ID) REFERENCES Patient (ID)"}],"structured_content":null},"error":null,"status":"completed"}}
{"type":"item.started","item":{"id":"item_2","type":"mcp_tool_call","server":"lang2sql","tool":"resolve_business_terms","arguments":{"terms":[]},"result":null,"error":null,"status":"in_progress"}}
{"type":"item.completed","item":{"id":"item_2","type":"mcp_tool_call","server":"lang2sql","tool":"resolve_business_terms","arguments":{"terms":[]},"result":{"content":[{"type":"text","text":"{\"definition_check_id\": \"GBFt8p4hba4Qw9YVnOYVTN7-sGepqWwpPzXRFgsqN80\", \"definitions\": [], \"instruction\": \"For oracle_view the operator has confirmed the contract: call run_sql with this definition_check_id, period_start and exclusive period_end, without sql. An explicit calendar year/month is sufficient to derive these dates. Ask only if the period or business meaning is actually unclear. For text definitions use SQL. Discover schema and use qualified table names before run_sql. A receipt is not proof of SQL semantic correctness.\"}"}],"structured_content":null},"error":null,"status":"completed"}}
{"type":"item.started","item":{"id":"item_3","type":"mcp_tool_call","server":"lang2sql","tool":"explore_schema","arguments":{"table":"Patient"},"result":null,"error":null,"status":"in_progress"}}
{"type":"item.completed","item":{"id":"item_3","type":"mcp_tool_call","server":"lang2sql","tool":"explore_schema","arguments":{"table":"Patient"},"result":{"content":[{"type":"text","text":"Patient (table)\n- ID: INTEGER NOT NULL\n- SEX: TEXT\n- Birthday: DATE\n- Description: DATE\n- First Date: DATE\n- Admission: TEXT\n- Diagnosis: TEXT\nPRIMARY KEY (ID)"}],"structured_content":null},"error":null,"status":"completed"}}
{"type":"item.started","item":{"id":"item_4","type":"mcp_tool_call","server":"lang2sql","tool":"run_sql","arguments":{"definition_check_id":"GBFt8p4hba4Qw9YVnOYVTN7-sGepqWwpPzXRFgsqN80","sql":"SELECT l.\"U-PRO\" AS reading, COUNT(*) AS tests, MIN(l.\"Date\") AS first_test, MIN(p.Birthday) AS first_birthday\nFROM main.Laboratory AS l\nJOIN main.Patient AS p ON p.ID = l.ID\nWHERE l.\"Date\" BETWEEN '1981-01-01' AND '1986-12-31'\nGROUP BY l.\"U-PRO\""},"result":null,"error":null,"status":"in_progress"}}
{"type":"item.completed","item":{"id":"item_4","type":"mcp_tool_call","server":"lang2sql","tool":"run_sql","arguments":{"definition_check_id":"GBFt8p4hba4Qw9YVnOYVTN7-sGepqWwpPzXRFgsqN80","sql":"SELECT l.\"U-PRO\" AS reading, COUNT(*) AS tests, MIN(l.\"Date\") AS first_test, MIN(p.Birthday) AS first_birthday\nFROM main.Laboratory AS l\nJOIN main.Patient AS p ON p.ID = l.ID\nWHERE l.\"Date\" BETWEEN '1981-01-01' AND '1986-12-31'\nGROUP BY l.\"U-PRO\""},"result":{"content":[{"type":"text","text":"8 row(s):\nResult coverage: fetched_rows=8; displayed_rows=8; fetch_truncated=false; display_truncated=false; sql_rewritten=true; query_timeout_enforced=true; query_timeout_scope=sqlite_vm. Counts refer to the executed SQL, not the source table size.\nObserved value types (displayed rows): reading=NoneType,str; tests=int; first_test=str; first_birthday=str\nreading | tests | first_test | first_birthday\n--- | --- | --- | ---\nNone | 1920 | 1981-01-27 | 1917-04-18\n%% | 4 | 1982-09-06 | 1929-07-05\n0 | 2729 | 1981-01-27 | 1917-04-18\n1 | 318 | 1981-04-06 | 1926-08-01\n2 | 313 | 1981-03-30 | 1926-08-01\n3 | 147 | 1981-03-16 | 1935-04-19\n4 | 21 | 1981-03-23 | 1943-05-19\nTR | 499 | 1981-02-19 | 1919-12-30\nSQL: SELECT l.\"U-PRO\" AS reading, COUNT(*) AS tests, MIN(l.\"Date\") AS first_test, MIN(p.Birthday) AS first_birthday\nFROM main.Laboratory AS l\nJOIN main.Patient AS p ON p.ID = l.ID\nWHERE l.\"Date\" BETWEEN '1981-01-01' AND '1986-12-31'\nGROUP BY l.\"U-PRO\"\nLIMIT 1000"}],"structured_content":null},"error":null,"status":"completed"}}
{"type":"item.started","item":{"id":"item_5","type":"mcp_tool_call","server":"lang2sql","tool":"resolve_business_terms","arguments":{"terms":[]},"result":null,"error":null,"status":"in_progress"}}
{"type":"item.completed","item":{"id":"item_5","type":"mcp_tool_call","server":"lang2sql","tool":"resolve_business_terms","arguments":{"terms":[]},"result":{"content":[{"type":"text","text":"{\"definition_check_id\": \"ApYlbKxYtGKFx_rIgV3aQGXw0AT7SasD22mU_rP7f-M\", \"definitions\": [], \"instruction\": \"For oracle_view the operator has confirmed the contract: call run_sql with this definition_check_id, period_start and exclusive period_end, without sql. An explicit calendar year/month is sufficient to derive these dates. Ask only if the period or business meaning is actually unclear. For text definitions use SQL. Discover schema and use qualified table names before run_sql. A receipt is not proof of SQL semantic correctness.\"}"}],"structured_content":null},"error":null,"status":"completed"}}
{"type":"item.started","item":{"id":"item_6","type":"mcp_tool_call","server":"lang2sql","tool":"run_sql","arguments":{"definition_check_id":"ApYlbKxYtGKFx_rIgV3aQGXw0AT7SasD22mU_rP7f-M","expected_columns":["patient_count"],"expected_rows":1,"sql":"SELECT COUNT(DISTINCT l.ID) AS patient_count\nFROM main.Laboratory AS l\nJOIN main.Patient AS p ON p.ID = l.ID\nWHERE l.\"Date\" BETWEEN '1981-01-01' AND '1986-12-31'\n AND l.\"Date\" >= p.Birthday\n AND l.\"Date\" < date(p.Birthday, '+50 years')\n AND l.PLT BETWEEN 100 AND 400\n AND (CAST(l.\"U-PRO\" AS REAL) > 0 OR l.\"U-PRO\" IN ('TR', '%%'))\nLIMIT 1"},"result":null,"error":null,"status":"in_progress"}}
{"type":"item.completed","item":{"id":"item_6","type":"mcp_tool_call","server":"lang2sql","tool":"run_sql","arguments":{"definition_check_id":"ApYlbKxYtGKFx_rIgV3aQGXw0AT7SasD22mU_rP7f-M","expected_columns":["patient_count"],"expected_rows":1,"sql":"SELECT COUNT(DISTINCT l.ID) AS patient_count\nFROM main.Laboratory AS l\nJOIN main.Patient AS p ON p.ID = l.ID\nWHERE l.\"Date\" BETWEEN '1981-01-01' AND '1986-12-31'\n AND l.\"Date\" >= p.Birthday\n AND l.\"Date\" < date(p.Birthday, '+50 years')\n AND l.PLT BETWEEN 100 AND 400\n AND (CAST(l.\"U-PRO\" AS REAL) > 0 OR l.\"U-PRO\" IN ('TR', '%%'))\nLIMIT 1"},"result":{"content":[{"type":"text","text":"1 row(s):\nOutput columns validated (projection only).\nOutput row count validated (executed SQL only).\nResult coverage: fetched_rows=1; displayed_rows=1; fetch_truncated=false; display_truncated=false; sql_rewritten=false; query_timeout_enforced=true; query_timeout_scope=sqlite_vm. Counts refer to the executed SQL, not the source table size.\nObserved value types (displayed rows): patient_count=int\npatient_count\n---\n71\nSQL: SELECT COUNT(DISTINCT l.ID) AS patient_count\nFROM main.Laboratory AS l\nJOIN main.Patient AS p ON p.ID = l.ID\nWHERE l.\"Date\" BETWEEN '1981-01-01' AND '1986-12-31'\n AND l.\"Date\" >= p.Birthday\n AND l.\"Date\" < date(p.Birthday, '+50 years')\n AND l.PLT BETWEEN 100 AND 400\n AND (CAST(l.\"U-PRO\" AS REAL) > 0 OR l.\"U-PRO\" IN ('TR', '%%'))\nLIMIT 1"}],"structured_content":null},"error":null,"status":"completed"}}
{"type":"item.completed","item":{"id":"item_7","type":"agent_message","text":"```sql\nSELECT COUNT(DISTINCT l.ID) AS patient_count\nFROM main.Laboratory AS l\nJOIN main.Patient AS p ON p.ID = l.ID\nWHERE l.\"Date\" BETWEEN '1981-01-01' AND '1986-12-31'\n AND l.\"Date\" >= p.Birthday\n AND l.\"Date\" < date(p.Birthday, '+50 years')\n AND l.PLT BETWEEN 100 AND 400\n AND (CAST(l.\"U-PRO\" AS REAL) > 0 OR l.\"U-PRO\" IN ('TR', '%%'))\nLIMIT 1\n```"}}
{"type":"turn.completed","usage":{"input_tokens":195033,"cached_input_tokens":179456,"cache_write_input_tokens":0,"output_tokens":741,"reasoning_output_tokens":31}}
Loading