Skip to content

feat(plugin): expose session forks with history filters - #48005

Open
rekram1-node wants to merge 3 commits into
v2from
plugin-fork
Open

feat(plugin): expose session forks with history filters#48005
rekram1-node wants to merge 3 commits into
v2from
plugin-fork

Conversation

@rekram1-node

Copy link
Copy Markdown
Collaborator

Summary

Expose ctx.session.fork in both Effect and Promise plugins, retaining the existing fork inputs and result while adding an optional synchronous history callback:

const fork = await ctx.session.fork({
  sessionID,
  boundary: { type: "through" },
  filter: (messages) => messages.filter((message) => message.type !== "synthetic"),
})
  • The callback receives decoded, settled Session messages in chronological order within the requested boundary. It can select or transform the messages and return an empty list.
  • Core runs the callback once and records its resulting history in the durable fork event. Projection assigns new message identities and reserves ordering; replay uses the recorded result without invoking plugin code.
  • Promise plugins retain normal client input/output conversion; their callback receives decoded Session messages, consistent with session hooks.
  • Omitting the callback retains the existing fork path. This creates an ordinary independent fork with the existing fork lineage and instruction inheritance.
  • Regenerate client/OpenAPI artifacts for the optional fork-event history payload.

Verification

  • packages/core: bun test test/session-create.test.ts — 45 passing, including filtered history, boundary selection, replay, empty selection, subsequent prompt ordering, and Promise plugin integration
  • packages/schema: bun test test/event-manifest.test.ts — 7 passing
  • bun typecheck in packages/core, packages/plugin, packages/schema, and packages/client
  • bun run generate in packages/client and packages/protocol
  • git diff --check

@rekram1-node

Copy link
Copy Markdown
Collaborator Author

Split the generator fix and its tests into standalone PR #48024 against v2. This PR no longer changes httpapi-codegen; its generated client output matches the current v2 generator. After #48024 merges, regenerating this branch will preserve the named ProviderState references.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant