-
Notifications
You must be signed in to change notification settings - Fork 0
fix(opencode): carry the in-flight request through auto-compaction #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -921,11 +921,29 @@ describe("session.compaction.process", () => { | |||||||||||
| metadata: { compaction_continue: true }, | ||||||||||||
| }) | ||||||||||||
| if (last?.parts[0]?.type === "text") { | ||||||||||||
| expect(last.parts[0].text).toContain("Continue if you have next steps") | ||||||||||||
| expect(last.parts[0].text).toContain("<user_request>\nhello\n</user_request>") | ||||||||||||
| expect(last.parts[0].text).toContain("Continue the work from Next Move") | ||||||||||||
| } | ||||||||||||
| }), | ||||||||||||
| ) | ||||||||||||
|
|
||||||||||||
| it.instance( | ||||||||||||
| "quotes the original request, not a prior continue prompt, on a second compaction", | ||||||||||||
| Effect.gen(function* () { | ||||||||||||
| const ssn = yield* SessionNs.Service | ||||||||||||
| const session = yield* ssn.create({}) | ||||||||||||
| const msg = yield* createUserMessage(session.id, "hello") | ||||||||||||
| const first = yield* ssn.messages({ sessionID: session.id }) | ||||||||||||
| yield* SessionCompaction.use.process({ parentID: msg.id, messages: first, sessionID: session.id, auto: true }) | ||||||||||||
|
|
||||||||||||
| const second = yield* ssn.messages({ sessionID: session.id }) | ||||||||||||
| yield* SessionCompaction.use.process({ parentID: msg.id, messages: second, sessionID: session.id, auto: true }) | ||||||||||||
|
|
||||||||||||
| const last = (yield* ssn.messages({ sessionID: session.id })).at(-1) | ||||||||||||
| expect(last?.parts[0]?.type === "text" && last.parts[0].text).toContain("<user_request>\nhello\n</user_request>") | ||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P3: The new test "quotes the original request, not a prior continue prompt, on a second compaction" does not actually verify its stated intent. In the buggy scenario it guards against (currentRequest picking up the prior synthetic nudge as the request), the second nudge would wrap the first nudge's text, which itself already contains the Prompt for AI agents
Suggested change
|
||||||||||||
| }), | ||||||||||||
| ) | ||||||||||||
|
|
||||||||||||
| itCompaction.instance( | ||||||||||||
| "persists tail_start_id for retained recent turns", | ||||||||||||
| Effect.gen(function* () { | ||||||||||||
|
|
@@ -1118,7 +1136,7 @@ describe("session.compaction.process", () => { | |||||||||||
| (msg) => | ||||||||||||
| msg.info.role === "user" && | ||||||||||||
| msg.parts.some( | ||||||||||||
| (part) => part.type === "text" && part.synthetic && part.text.includes("Continue if you have next steps"), | ||||||||||||
| (part) => part.type === "text" && part.synthetic && part.metadata?.compaction_continue === true, | ||||||||||||
| ), | ||||||||||||
| ), | ||||||||||||
| ).toBe(false) | ||||||||||||
|
|
||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: When a later user message contains only whitespace,
currentRequesttreats it as the in-flight request and omits the actual request from the continuation prompt. Require a non-whitespace text part in thefindLastpredicate so the helper matches the stated substantive-request behavior.Prompt for AI agents