You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- NetLogo case: "Loaded NetLogo model: <filename> (cached)" or "(downloaded)"
337
-
- Non-NetLogo case: structured JSON, see below.
335
+
Returns structured JSON in both NetLogo and non-NetLogo cases. See
336
+
shapes below. Always includes `resolved_version` so the caller can
337
+
pass it back into `read_comses_files` and guarantee it inspects the
338
+
same cache slot that was just opened.
338
339
"""
339
340
```
340
341
341
342
This is the **single entry point** for "I want this model ready to use." It subsumes downloading. Users who want to download without opening can call `download_comses_model` directly; most AI flows will call this tool.
"message": "This model is in Python, not NetLogo. The source is saved locally. You can read it with the read_comses_files tool if you want to understand or adapt it. Translating it to NetLogo is possible but not automatic — ask explicitly if that's what you want."
1. Search COMSES for models matching the topic; prefer peer-reviewed + NetLogo-tagged.
491
515
2. Show the user the top match with title, authors, description, **citation text**.
492
-
3. Call `open_comses_model`.
516
+
3. Call `open_comses_model`. **Capture `resolved_version` from the JSON
517
+
response** and reuse it for every subsequent `read_comses_files` call in
518
+
this flow. Never pass `"latest"` again after this point — doing so risks
519
+
re-resolving to a newer version than the one just loaded.
493
520
4. If the model is NetLogo (happy path):
494
-
a. Call `read_comses_files` with `extensions=[".nlogo", ".nlogox"]` to
495
-
get the source content of whichever variant was loaded. Always include
521
+
a. Call `read_comses_files(version=resolved_version, extensions=[".nlogo", ".nlogox"])`
522
+
to get the source content of whichever variant was loaded. Always include
496
523
both extensions — Section 4.4 may have selected an `.nlogox` file.
497
524
b. Scan the source for `to <name>` procedure names and `to-report <name>` reporters (treat the latter as candidates for plausible state metrics; the AI cannot reliably classify utility reporters every time, and that's accepted for v1).
498
525
c. **Fallback if nothing useful is found:** if no procedure with a name resembling `setup` / `initialize` / `start` exists, OR no candidate reporters are found, **stop after loading.** Do not force-run commands the model doesn't define. Report the discovered procedures/reporters (if any) and ask the user which to run.
@@ -501,7 +528,9 @@ The prompt instructs the AI to:
501
528
f. Summarize results, referencing the ODD doc content obtained via `read_comses_files`.
502
529
5. If not NetLogo:
503
530
a. The `open_comses_model` call already downloaded and extracted the archive.
504
-
b. Call `read_comses_files` to get the ODD doc and a summary of what the model does.
531
+
b. Call `read_comses_files(version=resolved_version, ...)` — using the
532
+
`resolved_version` captured in step 3 — to get the ODD doc and a
533
+
summary of what the model does.
505
534
c. State the language clearly, show citation, summarize the ODD findings, and stop.
506
535
d. Do not auto-translate. If the user later explicitly asks to translate, see "On Translation" below.
507
536
@@ -689,18 +718,18 @@ Server (happy path, NetLogo model):
689
718
1.`search_comses("rumor spreading")` → N matches.
690
719
2. AI picks a top peer-reviewed NetLogo match.
691
720
3.`get_comses_model(uuid)` → AI presents title, authors, **citation text**, license.
692
-
4.`open_comses_model(uuid)` → resolves `"latest"` to concrete version, downloads safely (or uses cache), extracts, picks the right `.nlogo` file per Section 4.4 rules, loads it into NetLogo.
693
-
5.`read_comses_files(uuid, extensions=[".nlogo", ".nlogox"])` → AI reads the actual source (whichever variant was loaded per Section 4.4) to **discover** real procedure names and reporters. **The AI does not fabricate commands.**
721
+
4.`open_comses_model(uuid)` → resolves `"latest"` to concrete version, downloads safely (or uses cache), extracts, picks the right `.nlogo` file per Section 4.4 rules, loads it into NetLogo. Returns JSON with `resolved_version` (e.g. `"1.2.0"`). **The AI pins this value and reuses it in every later call below.**
722
+
5.`read_comses_files(uuid, version=resolved_version, extensions=[".nlogo", ".nlogox"])` → AI reads the actual source (whichever variant was loaded per Section 4.4) to **discover** real procedure names and reporters. **The AI does not fabricate commands.**
694
723
6.**Branch based on discovery:**
695
724
-**Plausible setup + useful reporters found:**`command("<discovered setup>")`. If that call returns an error, **stop and ask the user** — do not guess alternates. Otherwise → `run_simulation(<N ticks>, [<discovered reporters>])` → `export_view()`.
696
725
-**No plausible setup OR no useful reporters found:** stop after loading. Report to the user what was found (maybe just `setup` with no reporters, or an unusual procedure name). Ask which procedure to run or whether they want to inspect the source first.
697
-
7.`read_comses_files(uuid, extensions=[".md", ".txt"], max_total_bytes=50000)` → AI reads the ODD doc and summarizes what the model demonstrates.
726
+
7.`read_comses_files(uuid, version=resolved_version, extensions=[".md", ".txt"], max_total_bytes=50000)` → AI reads the ODD doc and summarizes what the model demonstrates.
698
727
699
728
Non-NetLogo model flow:
700
729
1.`search_comses("rumor spreading")` → top match is Python.
701
730
2.`get_comses_model(uuid)` → citation text + metadata.
702
-
3.`open_comses_model(uuid)` → downloads + extracts (but does NOT load NetLogo). Returns the non-NetLogo JSON with language, code paths, ODD doc path.
703
-
4.`read_comses_files(uuid, extensions=[".md", ".txt"])` → AI reads the ODD doc.
731
+
3.`open_comses_model(uuid)` → downloads + extracts (but does NOT load NetLogo). Returns the non-NetLogo JSON with `resolved_version`, language, code paths, ODD doc path.**The AI pins `resolved_version` for reuse.**
732
+
4.`read_comses_files(uuid, version=resolved_version, extensions=[".md", ".txt"])` → AI reads the ODD doc.
704
733
5. AI reports: "This model is in Python (Mesa). It was downloaded to models/comses/... and I read the ODD documentation — here is a summary: [...]. I can explain the source code, or, if you explicitly ask, translate it to NetLogo (approximately). Otherwise we stop here."
0 commit comments