Skip to content

Commit ecbbc4b

Browse files
author
linyuan.yang
committed
静态 动态 prompt
1 parent eb91457 commit ecbbc4b

19 files changed

Lines changed: 160 additions & 130 deletions

File tree

docs/pwa/assets/index-3-T26HR3.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/pwa/assets/index-D9yBY05W.css

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 54 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/pwa/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
<link rel="icon" href="/sbot/pwa/logo.svg" type="image/svg+xml">
1010
<link rel="apple-touch-icon" href="/sbot/pwa/pwa-192x192.png">
1111
<title>sbot</title>
12-
<script type="module" crossorigin src="/sbot/pwa/assets/index-DcYbSzXY.js"></script>
13-
<link rel="stylesheet" crossorigin href="/sbot/pwa/assets/index-D9yBY05W.css">
12+
<script type="module" crossorigin src="/sbot/pwa/assets/index-DBymB6-_.js"></script>
13+
<link rel="stylesheet" crossorigin href="/sbot/pwa/assets/index-3-T26HR3.css">
1414
<link rel="manifest" href="/sbot/pwa/manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="/sbot/pwa/registerSW.js"></script></head>
1515
<body>
1616
<div id="app"></div>

docs/pwa/sw.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/channel.xiaoai/tsconfig.tsbuildinfo

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
0 Bytes
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
vars:
3+
currentTime: 当前时间 (如 2026/1/1 12:00:00)
4+
extraInfo: 渠道注入的额外信息 (XML 片段,可为空)
5+
---
6+
<current-time>{currentTime}</current-time>
7+
{extraInfo}
Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,18 @@
11
---
22
vars:
3-
currentTime: 当前时间 (如 2026/1/1 12:00:00)
43
timezone: 时区 (如 Asia/Shanghai)
54
os: 操作系统 (如 Linux 5.15.0 linux)
65
assetsDir: 资源文件目录绝对路径
76
httpUrl: HTTP 服务基础 URL
8-
scriptsDir: 临时脚本目录绝对路径
97
workPath: Agent 工作目录绝对路径
10-
agentSkillsPath: Agent 专属技能目录路径
11-
globalSkillsPath: 全局共享技能目录路径
12-
extraInfo: 渠道注入的额外信息 (XML 片段,可为空)
8+
139
---
1410
<environment>
15-
<current-time>{currentTime}</current-time>
1611
<timezone>{timezone}</timezone>
1712
<os>{os}</os>
1813
<paths>
1914
<assets dir="{assetsDir}" url="{httpUrl}/assets/&lt;filename&gt;">IMPORTANT: This is the ONLY way to deliver files to users. Whenever you generate, export, or produce any file intended for the user (images, documents, archives, reports, etc.), you MUST save it to this directory and share the URL above. Never send raw file content inline, never use any other path or method.</assets>
20-
<scripts dir="{scriptsDir}">Store temporary scripts here</scripts>
2115
<working-directory dir="{workPath}">This is your primary workspace. By default, scope all file operations — both read and write — to this directory. Accessing or modifying files outside this directory is permitted only when the user explicitly requests it or the task cannot be completed otherwise. Always prefer operating within this directory first.</working-directory>
22-
<skills>
23-
<agent-skills dir="{agentSkillsPath}">Your dedicated skills directory. When using tools to install or create skills, always use this directory as the default target.</agent-skills>
24-
<global-skills dir="{globalSkillsPath}">Shared skills directory available to all agents. Only install here when the user explicitly requests installing to global skills.</global-skills>
25-
</skills>
16+
2617
</paths>
27-
{extraInfo}
2818
</environment>

packages/sbot/src/Agent/AgentFactory.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
import {
99
IAgentToolService, AgentToolService,
1010
ISkillService, SkillService,
11-
ServiceContainer, T_SystemPrompts,
11+
ServiceContainer, T_StaticSystemPrompts, T_DynamicSystemPrompts,
1212
ReActAgentService, T_AgentSubNodes, T_CreateAgent, T_ThinkModelService,
1313
T_ReactSystemPromptTemplate, T_ReactSubNodePrompt, T_ReactTaskToolDesc,
1414
T_SkillSystemPromptTemplate, T_SkillToolReadDesc, T_SkillToolListDesc, T_SkillToolExecDesc,
@@ -30,8 +30,10 @@ export interface AgentCreateOptions {
3030
agentId: string;
3131
/** 当前请求的 DI 容器 */
3232
container: ServiceContainer;
33-
/** 注入到 system prompt 的额外上下文片段 */
33+
/** 注入到 system prompt 的额外上下文片段(静态,可缓存) */
3434
extraPrompts: string[];
35+
/** 每次请求变化的动态 system prompt(如 currentTime),不可缓存 */
36+
dynamicPrompts?: string[];
3537
/** 归属会话 DB 主键(channel_session.id),用于绑定 scheduler/todo 工具 */
3638
dbSessionId: string;
3739
/** 动态注册到 Agent 的工具列表 */
@@ -47,7 +49,7 @@ export interface AgentCreateOptions {
4749
export class AgentFactory {
4850

4951
static async create(options: AgentCreateOptions): Promise<AgentServiceBase> {
50-
const { agentId, container, extraPrompts, agentTools } = options;
52+
const { agentId, container, extraPrompts, dynamicPrompts, agentTools } = options;
5153
const agentEntry = config.getAgent(agentId);
5254

5355
if (!container.isRegistered(IAgentSaverService)) container.registerSingleton(IAgentSaverService, AgentMemorySaver);
@@ -63,8 +65,12 @@ export class AgentFactory {
6365
if (agentEntry.systemPrompt)
6466
systemPrompts.push(agentEntry.systemPrompt);
6567

68+
if (dynamicPrompts && dynamicPrompts.length > 0) {
69+
container.registerInstance(T_DynamicSystemPrompts, dynamicPrompts);
70+
}
71+
6672
const createAgentFn: CreateAgentFn = (name, subContainer) =>
67-
AgentFactory.create({ agentId: name, container: subContainer, extraPrompts, agentTools, dbSessionId: options.dbSessionId });
73+
AgentFactory.create({ agentId: name, container: subContainer, extraPrompts, dynamicPrompts, agentTools, dbSessionId: options.dbSessionId });
6874

6975
switch (agentType) {
7076
case AgentMode.ReAct:
@@ -153,7 +159,7 @@ export class AgentFactory {
153159

154160
container.registerWithArgs(SingleAgentService, {
155161
[IModelService]: await config.getModelService(entry.model, true),
156-
[T_SystemPrompts]: systemPrompts,
162+
[T_StaticSystemPrompts]: systemPrompts,
157163
...(entry.modelCallTimeout != null && { [T_ModelCallTimeout]: entry.modelCallTimeout * 1000 }),
158164
});
159165
return container.resolve(SingleAgentService);
@@ -169,7 +175,7 @@ export class AgentFactory {
169175
): Promise<AgentServiceBase> {
170176
container.registerWithArgs(GenerativeAgentService, {
171177
[IModelService]: await config.getModelService(entry.model, true),
172-
[T_SystemPrompts]: systemPrompts,
178+
[T_StaticSystemPrompts]: systemPrompts,
173179
});
174180
return container.resolve(GenerativeAgentService);
175181
}
@@ -195,7 +201,7 @@ export class AgentFactory {
195201
[T_AgentSubNodes]: agentSubNodes,
196202
[T_CreateAgent]: createAgentFn,
197203
[T_ThinkModelService]: await config.getModelService(entry.model, true),
198-
[T_SystemPrompts]: systemPrompts,
204+
[T_StaticSystemPrompts]: systemPrompts,
199205
[T_ReactSystemPromptTemplate]: loadPrompt('agent/react_system.txt'),
200206
[T_ReactSubNodePrompt]: loadPrompt('agent/react_subnode.txt'),
201207
[T_ReactTaskToolDesc]: loadPrompt('agent/react_task.txt'),

0 commit comments

Comments
 (0)