diff --git a/mateclaw-server/src/main/java/vip/mate/agent/service/TemplateService.java b/mateclaw-server/src/main/java/vip/mate/agent/service/TemplateService.java index 9d76fc30..a05b37c8 100644 --- a/mateclaw-server/src/main/java/vip/mate/agent/service/TemplateService.java +++ b/mateclaw-server/src/main/java/vip/mate/agent/service/TemplateService.java @@ -147,16 +147,16 @@ public class TemplateService { // 4. Pre-bind skills the template declares so a hired agent is // usable out of the box ("数据分析师" already knows SQL, "代码审查员" - // already has the test-driven-development playbook). Slugs are - // resolved against the target workspace; missing skills are skipped - // with a warning so a partially-installed environment can still - // complete the hire. - applyDefaultSkillBindings(template, created, workspaceId); + // already has the test-driven-development playbook). Resolution + // failures (slug missing in this workspace) are skipped with a + // warning; bind-service exceptions still propagate and roll back + // the @Transactional hire — see helper Javadoc. + applyDefaultSkillBindings(template, created); - // 5. Pre-bind any standalone tools the template wants. Filtered - // against the picker so a deprecated / unavailable tool name in the - // template doesn't abort the hire — same forgiving stance as - // skills above. + // 5. Pre-bind any standalone tools the template wants. Picker + // outage and unknown names are dropped with a warning; a + // setToolBindings exception still propagates (same contract as + // skills) — see helper Javadoc. applyDefaultToolBindings(template, created); return created; @@ -164,15 +164,39 @@ public class TemplateService { /** * Resolve {@link TemplateDTO#getDefaultSkillSlugs()} to skill ids inside - * {@code workspaceId} and pre-bind them on the freshly-created agent. - * Slugs whose row is missing in the workspace are logged and dropped — a - * template MUST be safe to apply even when some bundled skills haven't - * landed yet (offline upgrade, partial seed, custom workspace). + * the agent's own workspace and pre-bind them. + * + *
Failure contract — read carefully. + *
Reads the workspace off the just-persisted {@link AgentEntity}
+ * rather than a separate parameter so the lookup and the validator
+ * inside {@code AgentBindingService.requireSameWorkspace} can never
+ * disagree on which workspace they're talking about.
*/
- private void applyDefaultSkillBindings(TemplateDTO template, AgentEntity created, Long workspaceId) {
+ private void applyDefaultSkillBindings(TemplateDTO template, AgentEntity created) {
List Failure contract mirrors {@link #applyDefaultSkillBindings}:
+ * picker outage and unknown names are dropped with a warning; an
+ * exception from {@code setToolBindings} itself still propagates and
+ * rolls back the hire.
*/
private void applyDefaultToolBindings(TemplateDTO template, AgentEntity created) {
List