MCPcopy Create free account
hub / github.com/astercloud/aster / EnhanceSystemPrompt

Method EnhanceSystemPrompt

pkg/skills/injector.go:58–84  ·  view source on GitHub ↗

EnhanceSystemPrompt 增强系统提示词

(ctx context.Context, basePrompt string, skillContext SkillContext)

Source from the content-addressed store, hash-verified

56
57// EnhanceSystemPrompt 增强系统提示词
58func (i *Injector) EnhanceSystemPrompt(ctx context.Context, basePrompt string, skillContext SkillContext) string {
59 // 获取当前 Agent 已启用的技能集合。
60 // 而是将所有启用的技能以元数据形式暴露给模型,由模型根据描述自行判断何时使用。
61 activeSkills := i.getActiveSkills(skillContext)
62
63 skillsLog.Debug(ctx, "checking skills for message", map[string]any{"message": skillContext.UserMessage})
64 skillsLog.Debug(ctx, "enabled skills available to inject", map[string]any{"count": len(activeSkills)})
65 for _, skill := range activeSkills {
66 skillsLog.Debug(ctx, "enabled skill", map[string]any{"name": skill.Name, "description": skill.Description})
67 }
68
69 if len(activeSkills) == 0 {
70 skillsLog.Debug(ctx, "no skills activated, returning base prompt", nil)
71 return basePrompt
72 }
73
74 // 根据模型能力选择注入方式
75 if i.capabilities.SupportSystemPrompt {
76 enhanced := i.injectToSystemPrompt(basePrompt, activeSkills)
77 skillsLog.Debug(ctx, "enhanced system prompt", map[string]any{"before_len": len(basePrompt), "after_len": len(enhanced)})
78 return enhanced
79 }
80
81 // 不支持 system prompt,返回原始提示词
82 skillsLog.Debug(ctx, "provider doesn't support system prompt, returning base", nil)
83 return basePrompt
84}
85
86// ActivateSkills 根据上下文返回应当激活的 Skill 列表
87// 这是对内部 getActiveSkills 的公开包装,方便在自定义流程中手动控制注入。

Callers 2

StreamMethod · 0.80
SendMethod · 0.80

Calls 3

getActiveSkillsMethod · 0.95
injectToSystemPromptMethod · 0.95
DebugMethod · 0.65

Tested by

no test coverage detected