feat(engine): executor uses prompt layers for cross-session caching
This commit is contained in:
@@ -53,6 +53,7 @@ import {
|
|||||||
buildSystemPromptWithInstructions,
|
buildSystemPromptWithInstructions,
|
||||||
buildPluginPromptSection,
|
buildPluginPromptSection,
|
||||||
} from "./agent-instructions.js";
|
} from "./agent-instructions.js";
|
||||||
|
import { buildPromptLayers, collapsePromptLayers } from "./prompt-layers.js";
|
||||||
import type { AgentReflectionService } from "./agent-reflection.js";
|
import type { AgentReflectionService } from "./agent-reflection.js";
|
||||||
import { createRunAuditor, generateSyntheticRunId, type EngineRunContext } from "./run-audit.js";
|
import { createRunAuditor, generateSyntheticRunId, type EngineRunContext } from "./run-audit.js";
|
||||||
import { evaluateSpecStaleness, getPromptPath } from "./spec-staleness.js";
|
import { evaluateSpecStaleness, getPromptPath } from "./spec-staleness.js";
|
||||||
@@ -3077,21 +3078,23 @@ export class TaskExecutor {
|
|||||||
|
|
||||||
// Resolve per-agent custom instructions for the executor role
|
// Resolve per-agent custom instructions for the executor role
|
||||||
const executorInstructions = await this.resolveInstructionsForRole("executor");
|
const executorInstructions = await this.resolveInstructionsForRole("executor");
|
||||||
const executorSystemPrompt = buildSystemPromptWithInstructions(
|
|
||||||
getExecutorSystemPrompt(settings),
|
// Build structured layers for cross-session prompt caching.
|
||||||
executorInstructions,
|
|
||||||
);
|
|
||||||
const executorSystemContributions = this.options.pluginRunner?.getPromptContributionsForSurface("executor-system") ?? [];
|
|
||||||
if (executorSystemContributions.length > 0) {
|
|
||||||
executorLog.log(`${task.id}: applied ${executorSystemContributions.length} plugin prompt contributions for executor-system surface`);
|
|
||||||
}
|
|
||||||
const executorPluginContributions = buildPluginPromptSection(
|
const executorPluginContributions = buildPluginPromptSection(
|
||||||
"executor-system",
|
"executor-system",
|
||||||
this.options.pluginRunner,
|
this.options.pluginRunner,
|
||||||
);
|
);
|
||||||
const executorSystemPromptFinal = executorPluginContributions
|
if (executorPluginContributions) {
|
||||||
? `${executorSystemPrompt}\n\n${executorPluginContributions}`
|
executorLog.log(`${task.id}: applied plugin prompt contributions for executor-system surface`);
|
||||||
: executorSystemPrompt;
|
}
|
||||||
|
|
||||||
|
const executorLayers = buildPromptLayers({
|
||||||
|
basePrompt: getExecutorSystemPrompt(settings),
|
||||||
|
agentInstructions: executorInstructions,
|
||||||
|
pluginContributions: executorPluginContributions,
|
||||||
|
});
|
||||||
|
|
||||||
|
const executorSystemPromptFinal = collapsePromptLayers(executorLayers);
|
||||||
|
|
||||||
// sessionFile must be let because it's destructured alongside session which is reassigned
|
// sessionFile must be let because it's destructured alongside session which is reassigned
|
||||||
// eslint-disable-next-line prefer-const
|
// eslint-disable-next-line prefer-const
|
||||||
@@ -3101,6 +3104,7 @@ export class TaskExecutor {
|
|||||||
pluginRunner: this.options.pluginRunner,
|
pluginRunner: this.options.pluginRunner,
|
||||||
cwd: worktreePath,
|
cwd: worktreePath,
|
||||||
systemPrompt: executorSystemPromptFinal,
|
systemPrompt: executorSystemPromptFinal,
|
||||||
|
systemPromptLayers: executorLayers,
|
||||||
tools: "coding",
|
tools: "coding",
|
||||||
customTools,
|
customTools,
|
||||||
onText: agentLogger.onText,
|
onText: agentLogger.onText,
|
||||||
@@ -3430,6 +3434,7 @@ export class TaskExecutor {
|
|||||||
pluginRunner: this.options.pluginRunner,
|
pluginRunner: this.options.pluginRunner,
|
||||||
cwd: worktreePath,
|
cwd: worktreePath,
|
||||||
systemPrompt: executorSystemPromptFinal,
|
systemPrompt: executorSystemPromptFinal,
|
||||||
|
systemPromptLayers: executorLayers,
|
||||||
tools: "coding",
|
tools: "coding",
|
||||||
customTools,
|
customTools,
|
||||||
onText: agentLogger.onText,
|
onText: agentLogger.onText,
|
||||||
|
|||||||
Reference in New Issue
Block a user