Reorder play pipeline: gm first, auditor last.
Main world layer runs before narrator and deferred maintenance. Round-scoped settlement/maintain tags are archived at turn start so prior auditor table merges feed the next gm read. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -154,6 +154,14 @@ import type {
|
||||
} from "../types/runtime.js";
|
||||
import type { BlackboardItem } from "../types/blackboard.js";
|
||||
|
||||
/** 每轮开始前清掉的 transient tag(避免主世界层读到上一轮裁决/旁观包) */
|
||||
const PLAY_ROUND_TRANSIENT_TAGS = [
|
||||
SETTLEMENT_TAG,
|
||||
MAINTAIN_TAG,
|
||||
"运行.本轮.机遇",
|
||||
"运行.本轮.变量变更",
|
||||
] as const;
|
||||
|
||||
export type PhaseRuntimeOptions = {
|
||||
presetId?: string;
|
||||
flowId?: string;
|
||||
@@ -2072,6 +2080,7 @@ export class PhaseRuntime {
|
||||
/** 游玩:按 playWorkerIds 开一轮 */
|
||||
private async startPlayTurn(): Promise<void> {
|
||||
this.syncSlotsToBlackboard(this.session);
|
||||
this.clearPlayRoundTransientTags();
|
||||
const ids = this.getInstanceWorkerDeclaration().playWorkerIds;
|
||||
if (!ids.length) {
|
||||
this.onMessage(
|
||||
@@ -2118,6 +2127,29 @@ export class PhaseRuntime {
|
||||
};
|
||||
}
|
||||
|
||||
/** 新回合开始前归档上一轮 transient 产物(表合并结果保留在 变量.当前) */
|
||||
private clearPlayRoundTransientTags(): void {
|
||||
const slots = { ...this.session.slots };
|
||||
const archivedAt = new Date().toISOString();
|
||||
for (const tag of PLAY_ROUND_TRANSIENT_TAGS) {
|
||||
const hadBoard = this.blackboard.getLatestByTag(tag) != null;
|
||||
const hadSlot = tag in slots;
|
||||
if (!hadBoard && !hadSlot) continue;
|
||||
this.blackboard.write({
|
||||
tag,
|
||||
content: "",
|
||||
source: "runtime",
|
||||
metadata: {
|
||||
role: "archived",
|
||||
archivedAt,
|
||||
reason: "play_round_reset",
|
||||
},
|
||||
});
|
||||
delete slots[tag];
|
||||
}
|
||||
this.session = { ...this.session, slots };
|
||||
}
|
||||
|
||||
/** invoke_main_agent 副作用:running 时调用总管 LLM,链式推进直到需用户介入 */
|
||||
private async maybeRunMainAgent(effects: PhaseEffect[]): Promise<void> {
|
||||
if (inferLifecycleStage(this.session) === "play") return;
|
||||
|
||||
+14
-14
@@ -6,7 +6,7 @@
|
||||
import type { WorkerAcceptance, WorkerSetEntry } from "./worker-set-parse.js";
|
||||
|
||||
export type PlaySlotId = "auditor" | "gm" | "narrator" | "perspective";
|
||||
/** 按需槽(不进入 auditor→perspective→gm→narrator 管线) */
|
||||
/** 按需槽(不进入 gm→perspective?→narrator→auditor 管线) */
|
||||
export type OnDemandSlotId = "chance";
|
||||
|
||||
export type PlaySlotsConfig = {
|
||||
@@ -82,10 +82,10 @@ export const ON_DEMAND_SLOT_META: Record<
|
||||
|
||||
/** 推荐回合顺序(启用的槽按此排序;不含按需槽) */
|
||||
export const PLAY_SLOT_ORDER: PlaySlotId[] = [
|
||||
"auditor",
|
||||
"perspective",
|
||||
"gm",
|
||||
"perspective",
|
||||
"narrator",
|
||||
"auditor",
|
||||
];
|
||||
|
||||
/** 这些槽的默认上下文不注入「对话.历史」长聊 */
|
||||
@@ -194,21 +194,21 @@ export function workerEntryForSlot(
|
||||
role: id,
|
||||
duty: meta.purpose,
|
||||
when:
|
||||
id === "auditor"
|
||||
? "每轮用户输入后、主世界层之前"
|
||||
id === "gm"
|
||||
? "每轮用户输入后首先上场(主 LLM / 裁决权威)"
|
||||
: id === "perspective"
|
||||
? "强信息隔离且本轮需要该角色独立反应时"
|
||||
: id === "gm"
|
||||
? "每轮用户输入后(旁观维护与可选视角之后)"
|
||||
: "主世界层裁决包就绪后",
|
||||
? "强信息隔离且本轮需要该角色独立反应时(主世界层之后)"
|
||||
: id === "narrator"
|
||||
? "主世界层裁决包就绪后"
|
||||
: "转述完成后;表维护合并进变量.当前,供下一轮主世界层读取",
|
||||
rationale:
|
||||
id === "auditor"
|
||||
? "表与规则补充与主裁决分槽,避免挤占对话历史上下文"
|
||||
id === "gm"
|
||||
? "等同 SillyTavern 主 LLM:读设定与状态并产出裁决"
|
||||
: id === "perspective"
|
||||
? "知密内容不能进主世界层上下文"
|
||||
: id === "gm"
|
||||
? "裁决与真值变更需要独立推理槽"
|
||||
: "用户可见正文与裁决分离,避免文风与规则互相挤压",
|
||||
: id === "narrator"
|
||||
? "用户可见正文与裁决分离,避免文风与规则互相挤压"
|
||||
: "表与规则补充延后执行,改表结果作用于下一轮而非本轮重裁",
|
||||
acceptance: meta.defaultAcceptance,
|
||||
invocation: "turn",
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/**
|
||||
* 游玩回合:按运行规格 playWorkerIds 连跑(旁观 → 视角? → 主世界层 → 转述)。
|
||||
* 游玩回合:按运行规格 playWorkerIds 连跑(主世界层 → 视角? → 转述 → 旁观维护)。
|
||||
* 旁观维护在本轮末执行,表变更供下一轮主世界层读取。
|
||||
* 与创作总管无关;收口后的输入走这里。
|
||||
*/
|
||||
export const SLOT_PLAY_TURN_QUEUE = "playTurnQueue";
|
||||
|
||||
Reference in New Issue
Block a user