Skip to content

fix(graph): apply updateState routing deltas exactly once - #157

Merged
Aias00 merged 1 commit into
agentic-ai-java:mainfrom
logicwu0:fix/155-update-state-append
Oct 13, 2026
Merged

Aias00 merged 1 commit into
agentic-ai-java:mainfrom
logicwu0:fix/155-update-state-append

Conversation

@logicwu0

Copy link
Copy Markdown
Contributor

Describe what this PR does / why we need it

Fix duplicate state updates when calling CompiledGraph.updateState(config, values, asNode). Existing APPEND values and other non-idempotent state were being merged again because routing returned the full state instead of a delta.

Does this pull request fix one issue?

Fixes #155

Describe how you did it

  • Return empty deltas for direct and deferred parallel routes, and only the edge action's delta for conditional routes.
  • Apply that delta once in both legacy and versioned checkpoint paths.
  • Persist the resolved next node together with the updated checkpoint. Resume reads this field; leaving the old route would evaluate a conditional edge again and reapply its update.
  • Add 14 parameterized regression cases covering both MemorySaver and VersionedMemoryCheckpointSaver: two-argument controls, direct and conditional routing, legitimate repeated list elements, an additive strategy, deferred parallel dispatch, and a real interruption -> updateState -> resume sequence.

Describe how to verify it

Validated on main e10f9ab2c836ab6a9d5e722fbc243a323c9ef878, using JDK 21 with the project's Java 17 target, without model credentials or external services.

Before the production fix: 12 regression cases failed, with the two no-asNode controls passing. After the fix: all 14 pass.

mvn -o -B -ntp -pl :argi-agent-framework -am \
  -Dtest=CompiledGraphUpdateStateTest,ReactAgentVersionedCheckpointTest,ReactAgentCheckpointExecutionQueueTest,AbstractInterruptableModelHookTest \
  -Dsurefire.failIfNoSpecifiedTests=false -Dspotless.skip=true test

Result: 14 graph regression cases and 12 related Agent tests passed.

mvn -o -B -ntp -pl :argi-graph-core -am -Dpg.local.test.enabled=false \
  '-Dtest=*,!MysqlSaverTest,!OracleSaverTest,!PostgresSaverTest,!RedisSaverTest,!DatabaseStorePostgreSqlIntegrationTest,!DatabaseStorePostgreSqlLocalIntegrationTest' \
  -Dsurefire.failIfNoSpecifiedTests=false -Dspotless.skip=true test

Result: 561 tests, 0 failures, 0 errors, 13 skipped (548 passed). The six external database/Docker test classes listed above were excluded.

Checkstyle reported no violations during the test build. Targeted Spotless validation passed for both changed Java files:

mvn -o -B -ntp -pl :argi-graph-core \
  '-DspotlessFiles=.*(CompiledGraph|CompiledGraphUpdateStateTest)\.java' spotless:check

Special notes for reviews

Only one production file and one regression test file are changed. No public API or dependency changes. Parallel conditional dispatch remains deferred until resume. External database integration tests and the full multi-module suite were not run.

@Aias00

Aias00 commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

thx for your contributation, pls add my wechat: aias00

@Aias00 Aias00 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.

No blocking findings. The delta-only route handling and persisted nextNodeId match the resume contract and prevent non-idempotent key strategies from reapplying the full checkpoint state.

Non-blocking follow-ups:

  • The new regression matrix covers MemorySaver and VersionedMemoryCheckpointSaver, but not MemoryLeasedCheckpointSaver directly. The leased path shares VersionedCheckpointScope.put, so this is low risk; a small leased-saver case would close the remaining coverage gap.
  • GraphRunnerContext.nextNodeId mutates in-memory state, while CompiledGraph.nextNodeId now returns a delta for checkpoint updates. The current comments explain the new contract, but keeping these two semantics explicit in future refactors is important.

Verified locally:

  • 14 new CompiledGraphUpdateStateTest cases
  • related interruption, state-history, versioned-scope, and subgraph tests
  • git diff --check

All GitHub checks are green and the PR is cleanly mergeable.

@Aias00
Aias00 merged commit c4d0874 into agentic-ai-java:main Oct 13, 2026
7 checks passed
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.

[BUG] updateState(..., asNode) duplicates APPEND state before resume

2 participants