Agent-built designs: stop redoing whole-design work on every command (#1148)
A design built over MCP is many small commands, and each one did work over the whole design, so building or showing a 1,300-body design took minutes: - moved components were transformed and meshed again after every change; world_state now reuses each placed body whose definition and placement are unchanged - next_d_name searched the design once per candidate number - Document::eval evaluated every parameter for every expression; now only when the expression names one - param_rows' used_by was quadratic; the desktop no longer gathers completions on every change while no text box has focus solidcraft-cli bench-agent builds a generated ~1,300-body bicycle command by command and times it (241 s -> 16 s here). Eval output is unchanged apart from timings. Co-authored-by: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
37547f8eba
commit
6de8f6db95
11 files changed
+439
-21
No files matched your search
@@ -2358,8 +2358,14 @@ impl Document {
|
||||
|
||||
/// Evaluate an expression against the document's parameters.
|
||||
pub fn eval(&self, e: &str, kind: Kind) -> Result<f64> {
|
||||
let (vals, _) = self.param_values();
|
||||
Self::eval_in(&vals, e, kind)
|
||||
// The parameters are evaluated only when the expression names one: most expressions an
|
||||
// agent sends are plain values, and evaluating every parameter of a large design for
|
||||
// each of them made every new feature cost more than the last.
|
||||
let vals: std::cell::OnceCell<std::collections::BTreeMap<String, expr::Value>> = std::cell::OnceCell::new();
|
||||
expr::eval_with(e, &|n| {
|
||||
vals.get_or_init(|| self.param_values().0).get(n).copied().ok_or_else(|| DocError::Expr(format!("unknown parameter `{n}`")))
|
||||
})?
|
||||
.to_kind(kind)
|
||||
}
|
||||
|
||||
pub fn eval_in(vals: &std::collections::BTreeMap<String, expr::Value>, e: &str, kind: Kind) -> Result<f64> {
|
||||
|
||||
Reference in new issue
Block a user