Skip to content

[Core] Add Factory Pause Checkpoints - #2537

Open
MRayermannMSFT wants to merge 3 commits into
mainfrom
mrayermannmsft-factory-pause-sdk
Open

[Core] Add Factory Pause Checkpoints#2537
MRayermannMSFT wants to merge 3 commits into
mainfrom
mrayermannmsft-factory-pause-sdk

Conversation

@MRayermannMSFT

Copy link
Copy Markdown
Contributor

What

Adds token-scoped factory pause and durable checkpoint APIs to the Node.js SDK after the runtime contract lands. A paused attempt settles its waiter while resume preserves invocation limit overrides and execution identity.

Why

Factory authors need a safe checkpoint that stops spend without losing completed work. Token-scoped aborts stop an old attempt from cancelling a resumed attempt with the same run ID.

@github-actions

This comment has been minimized.

@MRayermannMSFT
MRayermannMSFT force-pushed the mrayermannmsft-factory-pause-sdk branch from 2dc7880 to 71666ea Compare September 9, 2026 16:09
@github-actions

This comment has been minimized.

MRayermannMSFT and others added 3 commits September 11, 2026 13:59
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@MRayermannMSFT
MRayermannMSFT force-pushed the mrayermannmsft-factory-pause-sdk branch from 71666ea to 295bd38 Compare September 11, 2026 21:02
@github-actions

Copy link
Copy Markdown
Contributor

Cross-SDK Consistency Review — PR #2537

Scope of changes: This PR touches only nodejs/src/factory.ts, nodejs/src/index.ts, nodejs/src/session.ts, and nodejs/test/factory.test.ts. It:

  • Adds a new context.pause(key) / session.factory.pause(runId) checkpoint API to the experimental Agent Factories surface.
  • Renames the public FactoryLimits type to FactoryLimitOverrides for RunOptions/ResumeOptions.limits.
  • Adds a "paused" terminal run status and threads executionToken through abort().

Findings:

  • No new cross-SDK inconsistency introduced. The "Agent Factories" feature (session.factory, defineFactory, context.pause, etc.) is currently implemented only in the Node.js/TypeScript SDK and is explicitly marked @experimental. There is no equivalent factory module/API surface in python/copilot/, go/, dotnet/src/, java/sdk/src/main/java/ (only Java's generated RPC types exist, no hand-written client wrapper), or rust/src/. Since this PR only extends an already Node-only experimental feature, it does not create a new divergence — the divergence (Node-only factory support) predates this PR.
  • i️ FYI for future parity work: if/when Agent Factories graduates out of experimental status or is ported to other languages, this pause/checkpoint capability (and the FactoryLimitOverrides rename) should be included in that port for consistency (naming per language convention: pause/context.pause in Python, Pause/ctx.Pause in Go/.NET, pause in Java, pause in Rust).
  • No API naming or behavior inconsistency was found relative to existing conventions within the Node.js SDK itself.

Conclusion: No inline comments needed — this PR maintains consistency with the current (Node-only) state of the experimental Agent Factories feature. No action required for other SDKs at this time.

Generated by SDK Consistency Review Agent for #2537 · copilot · sonnet50 · 40.7 AIC · ⌖ 12.2 AIC · ⊞ 8.3K ·

@MRayermannMSFT
MRayermannMSFT marked this pull request as ready for review September 12, 2026 00:13
Copilot AI balanced review requested due to automatic review settings September 12, 2026 00:13
@MRayermannMSFT
MRayermannMSFT requested a review from a team as a code owner September 12, 2026 00:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Public factory documentation remains inconsistent with resumable paused runs, and one new error message is malformed.

Get a fresh assessment by requesting another Copilot review.

Review tier: Balanced
Findings: 2 Low severity

Open findings (2)
What changed in this PR

Adds Node.js factory pause checkpoints, resumable pause semantics, token-scoped cancellation, and nullable invocation-limit overrides.

Changes:

  • Adds public and contextual pause APIs.
  • Scopes aborts to execution tokens.
  • Adds pause, resume-limit, and cancellation tests.
File Description
nodejs/​src/​session.ts Implements pause checkpoints and token-scoped aborts.
nodejs/​src/​factory.ts Defines pause and limit-override APIs.
nodejs/​src/​index.ts Exports the limit-override type.
nodejs/​test/​factory.test.ts Tests pause, resume, and abort behavior.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread nodejs/src/factory.ts
Comment on lines +403 to +404
/** Pause a running factory and return its settled envelope. */
pause(runId: string): Promise<FactoryRunResult>;
Comment thread nodejs/src/session.ts
if (factoryExecutionStore.getStore()?.active) {
throw new Error(
"factory.run and factory.resume are not allowed while a factory body is running on this call path."
"factory.run and factory.resume, and factory.pause are not allowed while a factory body is running on this call path."
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.

2 participants