LLM agent that analyzes astronomical spectra using the desi-fm foundation model as a tool
Five tools with strong, domain-specific descriptions (150 - 280 chars each) that explain WHAT, WHEN, and HOW to use them. All tools have explicit input schemas with typed parameters and descriptions. Tool names follow verb_noun pattern (predict_*, identify_*, reconstruct_*, find_*, lookup_*). Output schemas are documented in code (e.g., _z_summary returns z_pred_map, z_confidence, z_pred). However, no error handling guidance in descriptions (e.g., what to do if npz_path is invalid or model download fails), no parameter constraints (e.g., k bounds for find_similar_spectra), and no explicit output schema documentation in tool definitions themselves. Descriptions are LLM-optimized but lack recovery hints.
Find the k most similar spectra in a 15k-spectrum DESI reference index. Use it as a second, line-independent check on a candidate redshift: the spectrum is embedded with the foundation model's encoder and matched by cosine similarity against 15k DESI training spectra, each neighbor reporting its catalog z. Neighbors whose redshifts cluster tightly around a candidate z support it; scattered neighbor redshifts add doubt. The signal comes from the embedding space, not the classification head — it complements identify_spectral_lines, never replaces it. The first call may download the index (~30 MB) from the Hub.
Physically test a redshift hypothesis against the spectrum's peaks. Use it to validate any z — the model's, the user's or your own: known rest-frame lines shifted by (1+z) are matched to detected emission peaks, giving `match_fraction` and a verdict ('consistent' at >= 0.4). It also reports `n_peaks_detected` and `strongest_peaks_angstrom` (top 5 by prominence), so when a z fails you can derive alternative hypotheses by assuming the strongest peak is Hα, [OII] or Lyα and re-test each one. Needs no model. Caveat: a weak verdict is lack of confirmation, not refutation — absorption-dominated spectra match poorly even at the true z.
Consult the spectral-line catalog and DESI reference notes (BM25). Use it to sanity-check target-type vs redshift priors (BGS/LRG/ELG/QSO expected ranges), line visibility windows, and to explain classic line degeneracies (e.g. Halpha vs [OII] in single-line spectra). Returns up to k documents, strongest match first, each with an `id` to cite in square brackets, its public `source`, and a text snippet. The corpus is ~30 short committed documents; queries with no term overlap return an empty list. Needs no model and runs offline.
No parameter constraints (min/max, enums) in schemas. E.g., find_similar_spectra.k has no bounds; mask_ratio in reconstruct_spectrum lacks range (0.0 - 1.0). LLMs may pass invalid values.
Descriptions lack error recovery guidance. E.g., predict_redshift says 'first call loads model checkpoint and can take extra seconds' but does not say what to do if download fails or file is missing. No actionable error messages.
Output schemas not formally documented in tool definitions. Code shows _z_summary() and other return structures, but tool descriptions do not explicitly state output field names, types, or ranges (e.g., z_confidence in [0,1]).
| Scored | Grade | Overall | Spec posture | Rubric |
|---|---|---|---|---|
| 2026-09-23 | D | 58 | 2026-07-28+ | v2 |
Predict a galaxy/QSO redshift from a DESI spectrum in a .npz file. Use this first on any spectrum. `z_pred_map` is the official prediction (v2.1 classification head); `z_confidence` in [0, 1] flags likely catastrophic outliers below ~0.3 — verify those with identify_spectral_lines before trusting them. Deterministic; the first call loads the model checkpoint and can take extra seconds.
Probe prediction stability by masking part of the spectrum. Use it as a robustness check once you have a candidate z: a random `mask_ratio` fraction of the model's 273 tokens is hidden and the redshift re-predicted. If `z_pred_under_masking` stays close to the full-spectrum z, the prediction does not hinge on a single feature; large swings mean fragile evidence.
No idempotency or dry-run support documented. predict_redshift is deterministic (stated), but reconstruct_spectrum uses random masking, repeated calls yield different results. No guidance on retry safety.
lookup_reference accepts free-form 'query' string with no format guidance. Description says 'short keyword query' but does not specify max length, character restrictions, or what happens if query has no term overlap (returns empty list, but not stated in description).