Skip to content

fix(langgraph): regenerate via as_node='__start__' (0.0.29)#209

Merged
blove merged 3 commits into
mainfrom
claude/fix-regenerate-as-node-0.0.29
May 8, 2026
Merged

fix(langgraph): regenerate via as_node='__start__' (0.0.29)#209
blove merged 3 commits into
mainfrom
claude/fix-regenerate-as-node-0.0.29

Conversation

@blove
Copy link
Copy Markdown
Contributor

@blove blove commented May 7, 2026

Summary

Live ~/tmp/ngaf smoke against the freshly-published 0.0.28 reproduced the 1u/1a → 1u/0a regression: regenerate truncated the assistant message but a new one never streamed in.

Root cause confirmed via direct LangGraph API probe:

  • After the original run, the thread is at __end__ with next: []
  • 0.0.28's updateState({messages: [removeInstr]}) correctly applied the rollback (server state → just the user message)
  • But submit(null) is a no-op against a terminal thread — there's nothing pending to execute, so generate never re-ran
  • Manual POST /threads/$ID/state with as_node: '__start__' flipped next to ['generate']; subsequent runs/wait with input: null produced a fresh assistant — confirming the fix

Code change:

  • Extend transport.updateState + StreamManagerBridge.updateState with an optional asNode parameter
  • agent.fn.ts regenerate() passes asNode: '__start__' so the next pull resumes at the entry node
  • New unit test verifies the wire-shape: mock transport captures updateCalls[0].options.asNode === '__start__'

Also broadens @ngaf/chat's @cacheplane/partial-json dep range to >=0.1.1 <0.3.0 so consumers can pull the recently-published 0.2.x (StreamStatus rename — non-breaking for the surface @ngaf/chat actually uses).

Bumped all 16 @Ngaf packages 0.0.28 → 0.0.29.

Test plan

  • nx run langgraph:test green (new asNode spec covers the wire-shape)
  • nx run-many -t test --projects=langgraph,chat,ag-ui,a2ui,render,licensing green
  • nx run-many -t lint --projects=langgraph,chat,ag-ui green
  • CI green
  • After publish: bump ~/tmp/ngaf to 0.0.29, live smoke regenerate produces 1u/1a (NOT 1u/0a)

…nerate re-run (0.0.29)

After the original run, the LangGraph thread is at `__end__` with
`next: []`. The 0.0.28 regenerate flow called `updateState` to apply the
RemoveMessage rollback and then `submit(null)` — but submit-with-null is
a no-op against a terminal thread, so the new generation never fired.
The visible regression in the live cockpit smoke (and `~/tmp/ngaf`) was
1u/1a → 1u/0a: the assistant disappeared and never came back.

Fix: extend `transport.updateState` and the stream-manager bridge with
an optional `asNode` parameter, and have `regenerate()` pass
`asNode: '__start__'`. LangGraph treats the update as if the start node
had just produced the values, so `next` flips to `['generate']` and the
subsequent `submit(null)` resumes at the entry node and produces a fresh
assistant message against the rolled-back state.

Also broadens `@ngaf/chat`'s `@cacheplane/partial-json` dep range to
`>=0.1.1 <0.3.0` so consumers can pull the recently-published 0.2.x
(StreamStatus rename — non-breaking for the surface @ngaf/chat actually
uses).

Bumped all 16 @Ngaf packages to 0.0.29.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cacheplane Ready Ready Preview, Comment May 7, 2026 11:45pm

Request Review

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The api-docs gate failed because libs/langgraph/src/lib/agent.types.ts
still carried the older "Truncate the thread..." description while the
canonical version in libs/chat/src/lib/agent/agent.ts reads "Discards
the assistant message...". Aligning both keeps the generator output
deterministic.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@blove blove merged commit 701dba1 into main May 8, 2026
14 checks passed
blove added a commit that referenced this pull request May 8, 2026
Documents the fix landed in #209 (regenerate via as_node='__start__'),
the public-surface addition from #207/#208 (LangGraphAgent.regenerate
declared + canonical JSDoc), and the new optional asNode option on
AgentTransport.updateState.

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
@blove blove deleted the claude/fix-regenerate-as-node-0.0.29 branch May 8, 2026 17:45
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