fix(sdk): support clearing cron end_time via update({ endTime: null }) (#2602)
## What & why
`CronsClient.update` could not clear a cron's `end_time`. The field was
typed `endTime?: string`, so a type-checked caller had no way to express
"remove the end time" — even though, unlike the Python SDK, the JS
request builder was already correct at runtime: it uses per-field `if
(payload?.endTime !== undefined)` guards (not a `None`-strip), and `null
!== undefined`, so a `null` would already be forwarded and
`JSON.stringify` preserves it.
So the defect was purely a **type imprecision**, and the fix is at the
source — the model — rather than a workaround in the request logic:
- `CronsUpdatePayload.endTime`: `string` → `string | null`. PATCH
semantics are now the standard tri-state:
- **omit `endTime`** → keep the existing value
- **`endTime: null`** → clear it
- **`endTime: "<iso>"`** → set it
- `CronsCreatePayload.endTime` is intentionally left `string` — create
never needs to clear.
This mirrors the Python SDK change in langchain-ai/langgraph#8334
(`update(end_time=None)`), and requires an Agent Server that supports
clearing `end_time` via `PATCH /runs/crons/{id}` (`end_time: null`).
Against an older server, `update(id, { endTime: null })` is a harmless
no-op for clearing (the server coalesces `null` back to the stored
value), and a clear-only patch may 400.
## Also in this PR (unify `update()`)
While here, `update()`'s payload construction is unified with the
existing `create()` / `createForThread()` style: the 16 repetitive `if
(payload?.X !== undefined) json.Y = payload.X` guards become a single
declarative object literal. `JSON.stringify` drops `undefined` keys and
keeps `null`, so the wire output is **identical** — this is a
behaviour-preserving refactor, pinned by the pre-existing "only sends
defined fields" / "sends all updatable fields" tests. Net −44 lines in
the method.
## Test plan
- [x] `vitest run` on `libs/sdk/src/client/crons/index.test.ts` — **9
passed** (8 existing + 1 new: `update(id, { endTime: null })` sends body
`{ end_time: null }`), no type errors.
- [x] `pnpm build` (tsc compile + `attw` + `publint`) — clean.
- [x] `oxlint` — 0 warnings / 0 errors; `oxfmt --check` — clean.
- [x] Changeset added (`@langchain/langgraph-sdk`: patch). H
Hugo DURAND committed
c201256b27d55c9aa333d3d15f6ec16c2fd7de9b
Parent: a34543a
Committed by GitHub <noreply@github.com>
on 7/14/2026, 5:05:05 PM