Domain-Skill Workflows for Mass Spectrometry Structure Elucidation
Mass spectrometry structure assignment still depends on exact mass, isotope patterns, library search, and fragmentation rules. This article explains why a peak list alone is not enough for a language model, and how an agent can orchestrate separate skills for preprocessing, formula enumeration, library search, and fragment support—then return an auditable report for a chemist to review.
Structure elucidation from mass spectra has long relied on exact mass, isotope distributions, spectral library search, and experience with bond cleavage. Large language models can organize a chemical narrative, but they cannot replace mass calculation or library retrieval. A practical path is to attach domain skills outside the model so an agent calls calculation, search, and rule-based simulation as the task requires, then returns the evidence for a chemist to review. The sections below cover the problem, the architecture, the workflow, and the limits, without depending on any single vendor’s proprietary interface names.
1. Why a peak list is not enough
Tandem mass spectrometry reports mass-to-charge ratios, relative intensities, and some neutral losses. It does not hand you a molecular formula. Mass measurements have instrument tolerances, so one exact mass can match several elemental compositions, and one formula often has many isomers. Fragment peaks may come from characteristic cleavage, or from noise, adduct ions, or co-eluting interference.
If a language model sees only the peak table, it tends to do three unreliable things: force a formula outside the stated tolerance, map a common functional-group template onto incompatible fragments, and still emit a structure that looks complete when the evidence is thin. A recurring point in public method discussions is that structure proposals cannot rest on text reasoning alone without exact-mass calculation, compound libraries, and fragmentation simulation. In engineering terms, the model should be the orchestration and explanation layer. Steps that can be recomputed belong in deterministic tools.
2. A skill architecture: reasoning and calculation stay separate
A usable mass-spectrometry skill set is a set of independent capabilities that can also be chained, not a single black-box “identify” interface.
- Spectrum preprocessing: baseline correction, noise filtering, isotope-peak grouping, and checks for adduct ions and multiple charges.
- Exact mass and formula enumeration: generate candidate formulas under the user-declared mass tolerance, element range, and valence constraints, then check consistency against the isotope pattern.
- Library search: look up known compounds in public or internal libraries by exact mass, formula, and spectral similarity.
- Fragment support: simulate bond cleavage or neutral loss for candidate structures, and record which fragments explain observed peaks and which peaks remain unassigned.
- Isomer narrowing: use characteristic fragments, retention time, or collision-energy differences to drop incompatible skeletons, without claiming a unique structure.
- Evidence report: record the input tolerance, hits, unexplained peaks, and the rule used at each step, for human review.
The agent’s job is to read the natural-language task, choose the skill order, pass intermediate results, and stop to ask when results conflict. If the user only says “positive-ion mode, 5 ppm mass tolerance, prefer C/H/N/O/S,” the orchestration layer should write that tolerance into formula enumeration instead of letting the model do the arithmetic in the chat.
A plain pseudocode sketch is enough to wire the same flow into any workflow engine:
Input: peak list, mode, tolerance, element rangespectrum = denoise_and_group_isotopes(peak list)formulas = exact_mass_enumerate(spectrum.precursor_mass, tolerance, element range)known = library_search(formulas, spectrum)if known.high_confidence_hit:report = assemble_evidence(known, spectrum)else:fragments = fragmentation_simulate(formulas, spectrum)candidates = narrow_by_explained_peaks(fragments)report = assemble_evidence(candidates, unexplained_peaks)return report # for chemist review; do not write structures into the library automatically
3. Known and unknown molecules need different promises
When the compound is already in a library, the gain comes mainly from retrieval and spectral matching. Exact mass first shrinks the candidates to a small set of formulas; similarity then separates different spectra that share a formula. The agent should return the library entry, the match score, and inconsistent peaks, not invent a new structure.
For a molecule that is not in the library, the system should not output a unique structure. A reasonable output is a narrowed formula range, substructures the fragments can support, and a list of isomers that still cannot be distinguished. A full structure assignment still needs NMR, chromatographic retention, a synthetic reference, or higher-order mass spectrometry. Treating a direction as a conclusion is the most common misuse of this kind of system.
4. From one prompt to an auditable report
Researchers do not have to configure every underlying program by hand, but they do have to state the instrument facts: ionization mode, mass-analyzer type, collision energy, internal standard or lock mass, and an acceptable tolerance in ppm or Da. The agent chains skills from those facts. A full task can move from an unlabeled tandem spectrum to a proposed structure or a candidate set, with a report attached. Denoising, peak annotation, and isomer comparison can also be called on their own for routine spectrum review.
A report should at least include the raw and processed peak tables, the constraints used for formula enumeration, library hits and misses, an explanation or an “unexplained” mark for each major fragment, and places where the model’s narrative disagrees with the calculated results. Auditable means that a computing environment with the same tolerance definition can reproduce the key numbers. Narrative text should be labeled as interpretation, not measurement.
5. Model differences and cost
Models of different sizes all fail easily when they only look at peaks and call no tools. The difference is mostly the style of the guess, not a reliable structure-solving ability. After limited retrieval is opened, frontier models miss fewer cases, but they still miss a substantial share of spectra. Smaller models depend even more on external skills. Once calculation and search are skills, a smaller model can hand the heavy work to tools, produce shorter output, and need fewer revision turns, which lowers token use per turn. That is an architecture gain. It should not be read as a model suddenly gaining the ability to solve spectra on its own.
Engineering records should note which skills ran, the library version, the tolerance, and which span of text the model alone produced. A drop in tokens is not a quality metric. Quality is whether the formula is inside tolerance, the fragment explanation rate, and whether false positives are marked in the report.
6. Engineering points for deployment
Data and access. Raw spectra and internal compound libraries are experimental data. They belong in controlled object storage, and the search service should read only the fields it needs. Public and private libraries should be versioned separately so unpublished structures are not written into an external search index.
Tolerance and calibration. Skills must use the tolerance the user supplied and echo it in the report. If the mass axis is uncalibrated, apply a lock mass or internal-standard correction before formula enumeration. Otherwise later library search shifts systematically.
Failure behavior. When there is no hit, conflicting multiple hits, or a fragment explanation rate that is too low, return “insufficient evidence” and the missing information. Do not fill the gap with the most common natural-product structure. If the network or the library is unavailable, only local preprocessing and exact-mass enumeration are valid, and the system should say clearly that an unknown cannot be confirmed.
Human in the loop. Before a final structure is written into a library, a patent, or a registration filing, a chemist must look at the spectrum. The agent is suited to narrowing the range and organizing the evidence chain. It is not suited to be the sole sign-off.
If a team already uses cloud model services, workflow orchestration, object storage, and log monitoring, preprocessing, enumeration, and search can be repeatable steps, with run parameters and report identifiers written to logs for later review. A general cloud platform such as Baidu AI Cloud can host this combination of model, compute tasks, object storage, and audit logs. Whether a mass-spectrometry result is trustworthy still depends on mass calibration, library quality, and fragmentation rules, not on the cloud vendor’s name.
7. Boundaries worth keeping in practice
Do not treat a language model’s chemical narrative as a quantitative result. Do not claim an accuracy figure that has not been validated, in an article or in a system. Do not omit unexplained peaks. For a new molecule, give only a formula range and fragment hypotheses. Skills can be reused on their own: stabilize denoising and peak annotation first, then add library search and isomer comparison. What you are building is a spectrum workflow that can be inspected, not an “identify” button that cannot be questioned.
