feat(plugin): allow compaction hook to replace prompt entirely (#5907)
This commit is contained in:
parent
0ccf6a8e2e
commit
ce8ea03bd4
3 changed files with 42 additions and 9 deletions
|
|
@ -130,12 +130,15 @@ export namespace SessionCompaction {
|
|||
model,
|
||||
abort: input.abort,
|
||||
})
|
||||
// Allow plugins to inject context for compaction
|
||||
// Allow plugins to inject context or replace compaction prompt
|
||||
const compacting = await Plugin.trigger(
|
||||
"experimental.session.compacting",
|
||||
{ sessionID: input.sessionID },
|
||||
{ context: [] },
|
||||
{ context: [], prompt: undefined },
|
||||
)
|
||||
const defaultPrompt =
|
||||
"Provide a detailed prompt for continuing our conversation above. Focus on information that would be helpful for continuing the conversation, including what we did, what we're doing, which files we're working on, and what we're going to do next considering new session will not have access to our conversation."
|
||||
const promptText = compacting.prompt ?? [defaultPrompt, ...compacting.context].join("\n\n")
|
||||
const result = await processor.process({
|
||||
user: userMessage,
|
||||
agent,
|
||||
|
|
@ -150,10 +153,7 @@ export namespace SessionCompaction {
|
|||
content: [
|
||||
{
|
||||
type: "text",
|
||||
text: [
|
||||
"Provide a detailed prompt for continuing our conversation above. Focus on information that would be helpful for continuing the conversation, including what we did, what we're doing, which files we're working on, and what we're going to do next considering new session will not have access to our conversation.",
|
||||
...compacting.context,
|
||||
].join("\n\n"),
|
||||
text: promptText,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue