fix(continuation): mark resumes synthetic
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import {
|
||||
OMO_INTERNAL_INITIATOR_MARKER,
|
||||
createInternalAgentContinuationTextPart,
|
||||
createInternalAgentTextPart,
|
||||
stripInternalInitiatorMarkers,
|
||||
} from "./internal-initiator-marker"
|
||||
@@ -19,6 +20,18 @@ describe("internal-initiator-marker", () => {
|
||||
expect(part.text).toBe(`Hello world\n${OMO_INTERNAL_INITIATOR_MARKER}`)
|
||||
})
|
||||
|
||||
test("#given regular internal text #when creating a text part #then leaves it visible as a normal message part", () => {
|
||||
// given
|
||||
const text = "Visible notification"
|
||||
|
||||
// when
|
||||
const part = createInternalAgentTextPart(text)
|
||||
|
||||
// then
|
||||
expect("synthetic" in part).toBe(false)
|
||||
expect("metadata" in part).toBe(false)
|
||||
})
|
||||
|
||||
test("#given text already ending with the marker #when creating a text part #then does not duplicate the marker", () => {
|
||||
// given
|
||||
const text = `Already marked\n${OMO_INTERNAL_INITIATOR_MARKER}`
|
||||
@@ -71,6 +84,22 @@ describe("internal-initiator-marker", () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe("createInternalAgentContinuationTextPart", () => {
|
||||
test("#given continuation text #when creating a text part #then marks it as an agent continuation", () => {
|
||||
// given
|
||||
const text = "Continue the loop"
|
||||
|
||||
// when
|
||||
const part = createInternalAgentContinuationTextPart(text)
|
||||
|
||||
// then
|
||||
expect(part.type).toBe("text")
|
||||
expect(part.text).toBe(`Continue the loop\n${OMO_INTERNAL_INITIATOR_MARKER}`)
|
||||
expect(part.synthetic).toBe(true)
|
||||
expect(part.metadata.compaction_continue).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe("stripInternalInitiatorMarkers", () => {
|
||||
test("#given text with no markers #when stripping #then returns text trimmed at the end", () => {
|
||||
// given
|
||||
|
||||
@@ -16,3 +16,16 @@ export function createInternalAgentTextPart(text: string): {
|
||||
text: `${cleanText}\n${OMO_INTERNAL_INITIATOR_MARKER}`,
|
||||
}
|
||||
}
|
||||
|
||||
export function createInternalAgentContinuationTextPart(text: string): {
|
||||
type: "text"
|
||||
text: string
|
||||
synthetic: true
|
||||
metadata: { compaction_continue: true }
|
||||
} {
|
||||
return {
|
||||
...createInternalAgentTextPart(text),
|
||||
synthetic: true,
|
||||
metadata: { compaction_continue: true },
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user