mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-19 06:45:15 +00:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf83a03ce9 |
@@ -819,6 +819,9 @@ function buildImportedTimelineRows(entries: readonly ImportedTimelineEntry[]): A
|
||||
seq: rows.length + 1,
|
||||
timestamp: entry.timestamp ?? new Date().toISOString(),
|
||||
item: limitAgentTimelineItemContent(item),
|
||||
...(item.type === "user_message" && item.clientMessageId && item.messageId
|
||||
? { providerMessageId: item.messageId }
|
||||
: {}),
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -4676,6 +4679,7 @@ export class AgentManager {
|
||||
buildImportedTimelineRows(session.initialTimeline).map((row) => ({
|
||||
item: row.item,
|
||||
timestamp: row.timestamp,
|
||||
providerMessageId: row.providerMessageId,
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1211,6 +1211,28 @@ describe.each(TIMELINE_CONTRACT_BACKENDS)("provider history over a $name backend
|
||||
expect(tail).toMatchObject({ epoch: first.head.epoch, startSeq: 1, endSeq: 4 });
|
||||
});
|
||||
|
||||
it("acknowledges provider prompts that replay with a client ID", async () => {
|
||||
const timeline = new AgentTimeline(new DeferredTimelineBackend(create()));
|
||||
const steer = (id: string): TimelineEntry => ({
|
||||
item: { type: "user_message", messageId: id, clientMessageId: `client-${id}`, text: id },
|
||||
});
|
||||
const history = [prompt("a"), reply("A"), steer("b"), reply("B")];
|
||||
await timeline.importHistory(scope, history);
|
||||
|
||||
expect(await timeline.reconcileProviderHistory(scope, history)).toEqual({ kind: "unchanged" });
|
||||
const continued = [...history, steer("c"), reply("C")];
|
||||
expect(await timeline.reconcileProviderHistory(scope, continued)).toMatchObject({
|
||||
kind: "appended",
|
||||
});
|
||||
expect(await timeline.reconcileProviderHistory(scope, continued)).toEqual({
|
||||
kind: "unchanged",
|
||||
});
|
||||
expect((await timeline.readRows(scope))[4]).toMatchObject({
|
||||
item: { messageId: "c", clientMessageId: "client-c" },
|
||||
providerMessageId: "c",
|
||||
});
|
||||
});
|
||||
|
||||
it("leaves existing history alone when asked to import", async () => {
|
||||
const { timeline } = await owned([prompt("a"), reply("A")]);
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ export class AgentTimeline {
|
||||
const existing = await this.backend.head(scope);
|
||||
if (existing) return { kind: "present", head: existing };
|
||||
const head = await this.backend.create(scope, {
|
||||
entries: entries.map(boundEntry),
|
||||
entries: entries.map(providerHistoryEntry),
|
||||
timestamp: options.timestamp,
|
||||
});
|
||||
return { kind: "imported", head: this.track(scope, head) };
|
||||
@@ -205,7 +205,7 @@ export class AgentTimeline {
|
||||
const plan = planProviderHistory({
|
||||
rows: await this.backend.readRows(scope),
|
||||
prompts: await this.backend.prompts(scope),
|
||||
provider: entries.map(boundEntry),
|
||||
provider: entries.map(providerHistoryEntry),
|
||||
});
|
||||
if (plan.kind !== "append") return plan;
|
||||
const commits = await this.commit(scope, plan.entries);
|
||||
@@ -511,6 +511,15 @@ function boundEntry(entry: TimelineEntry): TimelineEntry {
|
||||
return { ...entry, item: limitAgentTimelineItemContent(entry.item) };
|
||||
}
|
||||
|
||||
/** Replay proves delivery even when the provider includes Paseo's original client ID. */
|
||||
function providerHistoryEntry(entry: TimelineEntry): TimelineEntry {
|
||||
const { item } = entry;
|
||||
const providerMessageId =
|
||||
entry.providerMessageId ??
|
||||
(item.type === "user_message" && item.clientMessageId ? item.messageId : undefined);
|
||||
return boundEntry({ ...entry, ...(providerMessageId ? { providerMessageId } : {}) });
|
||||
}
|
||||
|
||||
interface PublishFailure {
|
||||
error: unknown;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user