mirror of
https://gitee.com/mateos/mateclaw.git
synced 2026-09-15 11:58:34 +08:00
feat(agent): append static About You identity block to system prompt
This commit is contained in:
parent
2e1ef6b4b1
commit
cd3ae0c001
@ -1320,6 +1320,23 @@ public class AgentGraphBuilder {
|
|||||||
|
|
||||||
// ==================== Prompt 构建 ====================
|
// ==================== Prompt 构建 ====================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cache-stable platform identity, appended to every agent's system
|
||||||
|
* prompt. Answers "who are you / what are you based on". The volatile
|
||||||
|
* "which model right now" fact is injected per-turn by
|
||||||
|
* {@link vip.mate.agent.context.RuntimeContextInjector} instead, to
|
||||||
|
* keep this prefix's prompt-cache hash stable.
|
||||||
|
*/
|
||||||
|
static final String ABOUT_YOU_BLOCK = """
|
||||||
|
|
||||||
|
## About You
|
||||||
|
You are powered by MateClaw — a multi-user AI Agent platform built on
|
||||||
|
Spring Boot 3.5 and Spring AI Alibaba Graph. You are reachable through
|
||||||
|
WebChat and 8+ IM channels (DingTalk, Feishu, WeCom, WeChat, Telegram,
|
||||||
|
Discord, QQ, Slack). If asked who you are or what you are based on,
|
||||||
|
answer with MateClaw and the technology stack above.
|
||||||
|
""";
|
||||||
|
|
||||||
private String buildEnhancedPrompt(AgentEntity entity, boolean builtinSearchEnabled) {
|
private String buildEnhancedPrompt(AgentEntity entity, boolean builtinSearchEnabled) {
|
||||||
// The agent's own systemPrompt encodes its identity (role / goal /
|
// The agent's own systemPrompt encodes its identity (role / goal /
|
||||||
// backstory). The memory block from workspace files (AGENTS.md, SOUL.md,
|
// backstory). The memory block from workspace files (AGENTS.md, SOUL.md,
|
||||||
@ -1475,7 +1492,7 @@ public class AgentGraphBuilder {
|
|||||||
// Wiki 知识库上下文注入
|
// Wiki 知识库上下文注入
|
||||||
String wikiContext = wikiContextService.buildWikiContext(entity.getId());
|
String wikiContext = wikiContextService.buildWikiContext(entity.getId());
|
||||||
|
|
||||||
return basePrompt + toolGuidance + searchGuidance + wikiContext;
|
return basePrompt + ABOUT_YOU_BLOCK + toolGuidance + searchGuidance + wikiContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -0,0 +1,25 @@
|
|||||||
|
package vip.mate.agent;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.DisplayName;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pin the static "## About You" identity block appended to every agent's
|
||||||
|
* system prompt. This is the cache-stable half of the self-introspection
|
||||||
|
* feature — it answers "who are you / what are you based on", while the
|
||||||
|
* volatile model line lives in RuntimeContextInjector.
|
||||||
|
*/
|
||||||
|
class AgentGraphBuilderIdentityBlockTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("identity block names MateClaw and the core tech stack")
|
||||||
|
void identityBlockMentionsPlatformAndStack() {
|
||||||
|
String block = AgentGraphBuilder.ABOUT_YOU_BLOCK;
|
||||||
|
|
||||||
|
assertTrue(block.contains("## About You"), "missing heading: " + block);
|
||||||
|
assertTrue(block.contains("MateClaw"), "must name the platform: " + block);
|
||||||
|
assertTrue(block.contains("Spring AI Alibaba Graph"), "must name the graph runtime: " + block);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user