Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/split-instruction-message-blocks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"perstack": patch
---

Split InstructionMessage into multiple system message blocks for improved prompt clarity and per-block cache control
25 changes: 11 additions & 14 deletions packages/runtime/src/messages/instruction-message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,25 @@ export function createInstructionMessage(expert: Expert, startedAt: number): Ins
? getCoordinatorMetaInstruction(startedAt)
: getDelegateMetaInstruction(startedAt)

const instruction = dedent`
const preamble = dedent`
You are Perstack, an AI expert that tackles tasks requested by users by utilizing all available tools.

${metaInstruction}
`

---

${expert.instruction}
const contents: InstructionMessage["contents"] = [
{ id: createId(), type: "textPart", text: preamble },
{ id: createId(), type: "textPart", text: expert.instruction },
]

---
const skillRules = getSkillRules(expert)
if (skillRules) {
contents.push({ id: createId(), type: "textPart", text: skillRules })
}

${getSkillRules(expert)}
`
return {
type: "instructionMessage",
contents: [
{
id: createId(),
type: "textPart",
text: instruction,
},
],
contents,
id: createId(),
}
}
Expand Down
Loading