AgentAM: An AI Agent for Spatter- and Defect-Aware Process Optimization in Laser Powder Bed Fusion
Authors: Olabode T. Ajenifujah, Amir Barati Farimani
Organizations: Department of Mechanical Engineering, Carnegie Mellon University, Pittsburgh, 15213, PA, USA · Department of Chemical Engineering, Carnegie Mellon University, Pittsburgh, 15213, PA, USA · Machine Learning Department, Carnegie Mellon University, Pittsburgh, 15213, PA, USA
Predictive models for laser powder bed fusion (LPBF) are rarely used on the shop floor because querying them requires programming and model-specific knowledge. We present AgentAM, a large language model (LLM) agent that gives process engineers natural-language access to CFD-trained surrogates of spatter and melt pool geometry for SS316L through the Model Context Protocol (MCP). Polynomial surrogates trained on 279 single-track simulations predict melt pool dimensions (R2≥0.95) and spatter volume (R2=0.83 on test data) at any power-velocity point in the trained range, and geometric criteria assign each point a geometry-derived defect regime (keyhole, lack of fusion, balling or stable) that matches the regime obtained from the simulated geometry in 93.4% of tracks under cross-validation. The agent selects and parameterizes tools for prediction, process-window scans and constrained optimization. Minimum-spatter optima often sat within 10 μm of the lack-of-fusion boundary; a margin-aware optimizer moved them away from all thresholds and raised the estimated probability of remaining classified Good from 0.94 to 1.00 under an assumed 2% process drift, and from 0.72 to 0.91 when jointly sampled cross-validated geometry residuals were added. About 40-50 well-spread simulations sufficed to reproduce the defect map. To evaluate the agent layer, we introduce a 145-prompt benchmark scored against direct tool calls, plus eight prompts (40 runs) on margin-aware requests. Over the 725 runs of the main benchmark the agent passed the intended inputs in 98.5% of parsing prompts, reported the scored spatter values and defect classes faithfully and met every stated constraint in the 65 feasible optimization runs, within a median 1.0% of the brute-force optimum.
Figures & tables
Figure 1: Overview of AgentAM. The agent turns an engineer’s request into a call to a tool on a local MCP server, which evaluates the polynomial surrogates, assigns geometry-derived regimes and searches the process window; the agent then reports the returned values. The example is benchmark prompt C15-01 with the call the agent made. Map: predicted regimes over the trained range; hatching marks points that meet the margins of Section 3.5 ; ∘ , plain minimum-spatter optimum; ⋆ , margin-aware optimum. The bottom row summarizes the agent evaluation.
Figure 2: System architecture. The LLM orchestrator interprets the request and calls surrogate-model tools on a local MCP server; tool outputs (spatter, melt pool geometry, defect class) are returned to the LLM, which composes the answer. The tool list includes the margin-aware optimizer mcp_find_robust ( Section 3.5 ), and the chat client applies the answer guard ( Section 2.6 ) before an answer is shown. All surrogate inference runs on the user’s machine; the LLM is accessed through the provider’s API.
Tool
Inputs
Returns
mcp_predict_all
P , V , material
spatter volume; D , W , L , area, volume; J ; defect class; clamping flag
mcp_line_scan_min_spatter
fixed P or V ; sweep range; number of points
table along the sweep; regime boundaries; minimum-spatter Good point
mcp_grid_scan
P and V ranges; grid size; optional filters
classified grid (process map) or filtered, ranked list
mcp_suggest
bounds on P , V , J ; limits on D , W , L , spatter; fixed P or V
ranked defect-free candidates that minimize spatter
mcp_find_robust
as mcp_suggest , plus minimum margins to each regime threshold and to the edge of the trained range
lowest-spatter Good point meeting all margins; its margins and nearest threshold; spatter cost relative to the plain optimum
Table 1: Tools exposed by the AgentAM MCP server.
Set
Prompts
Runs
Answers
Main benchmark, C1–C14
145
725
755
of which parsing, C1–C5
65
325
325
of which optimization, C7 (feasible / infeasible)
13 / 2
65 / 10
65 / 10
of which multi-turn, C13
6
30
60
rated by two raters: C7 infeasible and C8–C14
52
260
290
scored for completeness: C1–C7 feasible and C13
99
495
495 a
Table 2: Prompts, runs and answers used in the evaluation. A run is one conversation with one prompt (five runs per prompt); an answer is one assistant reply, so a two-turn C13 run gives two answers.
Category
n
What a correct agent must do
C1 Explicit parameters
20
call predict with the stated P , V
C2 Unit conversion
15
convert m/s, cm/s, mm/min, kW, or V from J
C3 Implicit / reordered values
10
assign unlabelled numbers to P and V correctly
C4 Arithmetic in prompt
10
evaluate expressions before calling the tool
C5 Colloquial values
10
map approximate language into a stated range
C6 Scans
15
choose line scan or grid scan with correct ranges
Table 3: Agent evaluation benchmark (145 prompts in C1–C14, five runs each). C15 was added to test the margin-aware tool ( Section 3.5 ).
Figure 3: (a) Defect regime predicted by AgentAM on a 10×29P – V grid; dashed lines are iso-energy lines J=P/V . Circled points K, G, B and L are the single-point examples in Table 5 . (b) Confusion matrix of the deployed classifier against the regimes of 279 FLOW-3D single-track simulations (in-sample; row-normalized, counts in parentheses).
Class
Precision
Recall
F1
Support
Good
0.90
0.85
0.87
53
Keyhole
0.92
0.94
0.93
62
Lack of fusion
0.99
0.98
0.99
138
Balling
0.83
0.96
0.89
26
Weighted average
0.94
0.94
0.94
279
Table 4: Per-class classification metrics against 279 simulated single tracks (deployed models, in-sample). Five-fold cross-validated accuracy: 93.4%.
P (W)
V (mm/s)
J (J/mm)
Spatter ( \SIUnitSymbolMicrom3 )
D ( \SIUnitSymbolMicrom )
W ( \SIUnitSymbolMicrom )
L ( \SIUnitSymbolMicrom )
Criterion
K
400
300
1.33
342,833
442
251
266
D/W=1.76>1.25
G
320
630
0.51
80,040
215
204
418
D/W=1.06 , L/W=2.05
B
300
800
0.38
164,357
143
179
493
L/W=2.76
L
300
1200
0.25
109,574
92
164
612
D=92<137\SIUnitSymbolMicrom
Table 5: Single-point predictions for SS316L in each regime (agent output from mcp_predict_all ).
Prompt
P (W)
V (mm/s)
Prediction
Skill
“what should I expect from operating at 350 W and 1 m/s”
350
1000
LoF ( D=133\SIUnitSymbolMicrom )
unit conversion
“predict at 295 and 750”
295
750
Balling ( L/W=2.58 )
unlabelled values
“Use P=150+0.5×500 and V=2×400 ”
400
800
Balling ( L/W=2.51 )
arithmetic
“Hit it with 350-ish watts, speed a bit under a meter per second”
350
950
Balling ( L/W≈3.1 )
colloquial
“…at 300 W and 800 mm/s using beam diameter of 100 micron”
300
800
beam size flagged as fixed
scope check
Table 6: Examples of prompts the agent parsed into tool arguments. Abbreviations: LoF, lack of fusion.
Figure 4: Line scans returned by the agent. (a) Velocity sweep at P=300 W; (b) power sweep at V=600 mm/s. Background shading marks the predicted regime; the circled point is the minimum-spatter Good point reported by the agent.
Figure 5: Constrained queries. (a) Candidate points returned by the agent for queries Q1–Q4 over the predicted process map (faded); stars mark the recommended point. (b) Predicted spatter of the ranked candidates. Q2 and Q3 returned identical candidates.
Figure 6: Margin-aware optimization. (a) Plain minimum-spatter optima (open circles) and margin-aware optima (stars) for Q1–Q4 and the unconstrained search over the predicted process map; Q4 is unchanged. (b) Spatter of the margin-aware optimum of the unconstrained search as the required depth margin grows, with and without a 5% range margin (keyhole and balling margins 0.10 and 0.15). (c) Probability that the same points remain Good under 2% variation of P and V and 5% error on the predicted geometry.
Plain optimum
Margin-aware optimum
Query
P , V
Spatter
ΔD ( \SIUnitSymbolMicrom )
pA
pB
P , V
Spatter
ΔD ( \SIUnitSymbolMicrom )
pA
pB
Cost (%)
Q1
200, 502
55,523
3.8
0.77
0.65
200, 456
58,467
18.7
1.00
0.98
5.3
Q2, Q3, unconstr.
160, 349
39,677
6.7
0.95
0.80
184, 411
55,470
15.3
1.00
0.96
39.8
Q4 a
304, 536
66,074
101.6
1.00
0.93
304, 536
66,074
101.6
1.00
0.93
0
All 17 queries, median
0.94
0.80
1.00
0.96
36.4
Table 7: Plain and margin-aware optima. ΔD : depth margin above the lack-of-fusion threshold; pA , pB : probability of remaining Good under process variability (A) and under process variability plus surrogate error (B).
Figure 7: Simulation budget for the defect map (pool of 279 FLOW-3D runs, 50 repeats, 20% held-out test set). (a) Mean test accuracy of the defect map against the number of simulations acquired; shading is the 95% confidence interval of the mean; the line marks the model trained on all available runs. The threshold strategy (not shown) follows the committee from 75 runs on. (b) Median spatter gap between the best Good run acquired and the best Good run in the pool.
Category
Runs
Tool
Param.
Faithful
Behaviour a
Consist.
Latency (s)
Tokens (k)
C1 Explicit
100
100
100
100
n/a
100
6.8
11.7
C2 Units
75
100
100
100
n/a
100
9.1
12.0
C3 Implicit
50
100
100
100
n/a
100
8.2
11.9
C4 Arithmetic
50
98
98
100
n/a
100
8.7
12.0
C5 Colloquial
50
100
92
100
n/a
70
9.3
11.9
C6 Line scan
50
100
n/a
n/a
n/a
n/a
11.7
14.1
Table 8: Agent evaluation results per category (five runs per prompt; values in %, except latency and tokens). n/a: metric does not apply.
Category
Runs
Fake call + result
Fake call only
Wrong model facts
Other
C1 Explicit
100
16
73
10
1
C2 Units
75
39
61
0
0
C3 Implicit
50
8
72
18
2
C4 Arithmetic
50
10
86
2
2
C5 Colloquial
50
18
64
0
18
C6 Line scan
50
0
98
2
0
Table 9: Baseline without tools: share of runs (%) in each class (same model and system prompt, empty tool list, five runs per prompt).
Appendix figures & tables13 assets
Supplementary material from the paper’s appendix.
Appendix
Figure A.1: MCP communication pipeline from user prompt to displayed response (eight steps across the chat interface, MCP client, LLM API and local MCP server).
Table C.1: Process parameters and their status in the surrogate models.
Category
Example prompt
C1
“What defect should I expect at P = 330 W, V = 410 mm/s?”
C2
“Predict at 345 W, 57000 mm/min.”
C3
“speed 800 power 250”
C4
“Power is 240 W plus 15%, speed is 4 x 150 mm/s.”
C5
“Quarter of a kilowatt, 0.7 m/s give or take.”
C6
“Hold scan speed at 800 mm/s and sweep power from 160 to 430 W. Where does the defect type change?”
Appendix
Table D.1: One example prompt per benchmark category. The full set (145 prompts with expected behaviour) and the scoring scripts are in the repository.
Prompt
Repeat
A
B
Reason
C10-infeasible-01
2
0
0
Claims shallowest Good depth ∼ 273 um from truncated sort; misleading relaxation advice
C10-infeasible-05
2
0
0
Explanation wrong: claims long pools need low V; tools show high V
C10-infeasible-05
4
0
0
Infeasibility stated but explanation wrong; claims keyhole instead of LoF at long lengths
C10-infeasible-06
0
1
0
Recommends 160 W point violating P<160 without stating infeasibility
C10-infeasible-06
2
0
1
Returns P=160 W point labelled as P<=160; no clear infeasibility statement
C10-infeasible-06
3
0
1
Never states infeasibility clearly; recommends P=160 W which violates P below 160
Appendix
Table E.1: Runs that failed the behaviour rating (A, B: score of each rater; reason given by the rater who failed the run).
Deployed
N1 neutral
N2 acknowledge
Fabricated tool-call markup
92.3
0.0
0.0
Presented as model or database output
1.2
4.8
0.0
Substantive answer, no disclosure, unhedged
0.8
14.7
0.0
Substantive answer, no disclosure, hedged
1.6
70.9
15.6
Disclosure, then estimates
0.0
0.0
69.5
Disclosure only
0.0
0.0
10.1
Appendix
Table H.1: Answers without tools to the 505 requests for model outputs (C1–C7, C13) under the deployed system prompt and the two neutral prompts (values in %, five runs per prompt). A substantive answer is a numerical outcome, a defect verdict for the requested point or a recommended parameter set. Guard versions and rules (a)–(e) are defined in Section 2.6 : G1 uses rules (a) and (b), G2 rules (a), (b), (d) and (e).
Plain optimum
Margin-aware optimum
Scenario
Median
Min
Median
Min
A, 1%
1.00
0.93
1.00
1.00
A, 2% ( Section 3.5 )
0.94
0.76
1.00
1.00
A, 3%
0.85
0.69
0.98
0.98
A, 2%, ρ=+0.8
1.00
0.95
1.00
1.00
A, 2%, ρ=−0.8
0.89
0.71
0.99
0.99
Appendix
Table I.1: Probability of remaining Good under alternative perturbation models: median and minimum over the 17 queries.
Figure J.1: Sensitivity of the defect classification to (a) the keyhole threshold D/W , (b) the layer thickness t , (c) the lower and (d) the upper bound of the balling band L/W . Lines show the in-sample and five-fold cross-validated accuracy against the 279 simulated tracks (left axis) and the Good fraction of the trained P – V range (right axis); grey lines mark the deployed values. In (d), none removes the upper bound.
Laser Powder Bed Fusion (LPBF) is highly sensitive to process parameters, which influence defect formation through complex thermal and fluid mechanisms. However, defect-related knowledge is dispersed across the literature, limiting systematic understanding. This study presents a graph-assisted retrieval framework for defect reasoning in LPBF, using Ti6Al4V as a case study. Scientific publications are transformed into a structured representation, and relationships between parameters, mechanisms, and defects are encoded into an evidence-linked knowledge graph. The framework integrates semantic and graph-based retrieval, supported by a lightweight agent-based reasoning layer to construct interpretable defect pathways. Evaluation shows high retrieval accuracy (0.9667) and recall (0.9667), demonstrating effective identification of relevant defect related evidence. The framework enables transparent reasoning chains linking process parameters to defects. This work provides a scalable approach for converting unstructured literature into a query able and interpretable knowledge resource for additive manufacturing.
Muhammad Rizwan Awan, Volker Pickert, Muhammad Waqar Ashraf +3
Department of Electrical and Electronic Engineering, The Newcastle University · The Sargent Centre for Process Systems Engineering, Department of Chemical Engineering, University College London, Torrington Place, London, WC1E 7JE, UK
This work presents a knowledge-driven decision-support system that integrates structured defect knowledge with LLM-based reasoning to provide explainable defect diagnosis and mitigation guidance in manufacturing, using LPBF as a representative, safety-critical case study. The proposed ontology-integrated LLM-based decision support system for LPBF defect analysis and mitigation guidance is built on a knowledge base containing 27 known LPBF defect types organized into hierarchical categories and causal relationships. The developed system supports fuzzy natural language queries for systematic knowledge retrieval, literature-supported explanation of defects, and guidance on defect causes and mitigation strategies derived from encoded process knowledge. Furthermore, a multimodal image-assessment module based on foundation models enables descriptor-guided interpretation of representative microscopic defect images through semantic alignment scoring. The proposed framework was evaluated through qualitative comparisons with general-purpose vision-language models, an ablation study, and an inter-rater reliability analysis. Evaluation on the literature-derived dataset showed that the fully integrated configuration outperformed the other three evaluated system configurations, achieving a macro-average F1 score of 0.808. Additionally, inter-rater reliability analysis using Cohen's kappa indicated substantial agreement between the model outputs and the literature-derived reference labels. These findings suggest that ontology-guided knowledge representation can improve the consistency, interpretability, and practical usefulness of LLM-assisted LPBF defect analysis.
Basit Mahmud Shahriar, Md Habibor Rahman
Department of Mechanical Engineering, University of Massachusetts Dartmouth, Dartmouth, MA 02747, USA
Predicting part distortion before fabrication remains challenging in laser powder bed fusion (LPBF), while thermomechanical simulation is computationally expensive for repeated design evaluations. This study presents a two-branch graph attention network (GAT) to predict three-dimensional surface displacement directly from STL-derived graphs. The first branch learns geometric relationships among connected vertices of a densified STL surface mesh, while the second incorporates 12 part-level descriptors of mass distribution, build-plate contact, overhang, size, and shape. Displacement labels from ANSYS Additive Print simulations are mapped onto STL vertices using Gaussian-kernel weighted averaging. Evaluated on 117 parts using five-fold cross-validation split by part, the model achieves an R^2 of 0.946 and a mean absolute error of 0.0178 mm for displacement magnitude. Relative to a node-wise multilayer perceptron, GAT improves R^2 from 0.913 to 0.946; for build-direction displacement, R^2 increases from 0.903 to 0.939. GAT also outperforms GraphSAGE (R^2 = 0.936) and a graph convolutional network (R^2 = 0.934) across all five folds. Ablation experiments show that removing mass-distribution descriptors reduces magnitude R^2 to 0.900, while removing build-plate contact and overhang descriptors reduces it to 0.920. These results demonstrate the value of combining local mesh connectivity with global geometric descriptors to predict LPBF distortion, enabling faster design iteration and earlier identification of distortion-prone geometries.
Saima Ahmed Suhi, Lang Yuan, Md Habibor Rahman
Department of Mechanical Engineering, University of South Carolina, Columbia, SC 29208, USA