Skip to content

refactor(graph): clarify thread id naming in checkpoint savers - #107

Merged
yuluo-yx merged 1 commit into
agentic-ai-java:mainfrom
Sean-Walker0:refactor/graph-thread-naming
Sep 30, 2026
Merged

yuluo-yx merged 1 commit into
agentic-ai-java:mainfrom
Sean-Walker0:refactor/graph-thread-naming

Conversation

@Sean-Walker0

Copy link
Copy Markdown
Contributor

Describe what this PR does / why we need it

thread_id and thread_name in the checkpoint savers' storage are easy to misread: the thread id accepted by the API (RunnableConfig.threadId) ends up in the thread_name column, while the thread_id column holds an internally generated UUID. As raised in #106, this split came in with the saver rework (spring-ai-alibaba#3287) to support "release and later reuse the same thread id", but the old column names were kept, so thread_id now names the internal surrogate key instead of the user-facing thread id.

This PR makes the identity model explicit without changing any SQL statement, stored key or persisted data, because renaming the columns would silently break existing deployments:

  • AbstractJdbcCheckpointSaver: document the thread identity model, and replace the vague thread name/id used by the concrete saver schema parameter docs with a precise statement of what the protected methods receive.
  • H2/Mysql/Postgres/Oracle savers: annotate the schema javadoc so each column states what it actually holds, add a short "Thread identity" paragraph, and align private parameter names (threadName -> threadId for the user-facing id).
  • Redis/Mongo savers: document the key/field layout the same way, rename threadName(RunnableConfig) to threadId(RunnableConfig), and use persistedThreadId for the internal UUID so the two identities no longer share a name inside one method.

Does this pull request fix one issue?

Fixes #106

Describe how you did it

Confirmed the schema history first (before spring-ai-alibaba#3287 the single-table savers keyed on the user's thread id directly, matching the LangGraph model), then applied a naming/documentation-only cleanup on top of the current two-identity design: threadId always denotes the user-facing thread id from RunnableConfig, persistedThreadId always denotes the internal surrogate UUID, and every saver's schema documentation now spells out which column/field holds which.

Describe how to verify it

mvn -pl agentic-ai-graph-core test — the full module suite passes (439 tests, 0 failures, 15 skipped), including the container-backed saver tests for H2, MySQL, PostgreSQL, Oracle, Redis and MongoDB.

Special notes for reviews

The physical column rename suggested in the issue would orphan data written by existing deployments, so it is intentionally left to the successor persistence artifacts (agentic-spring-ai-extensions); this PR removes the confusion at the Java and documentation level where it can be done compatibly.

The persistence savers accept a user-facing thread id through
RunnableConfig but store it in a thread_name column, while the
thread_id column holds an internal surrogate UUID generated to
support thread release and reuse. This split was introduced by the
saver rework in spring-ai-alibaba#3287 and kept the old column
names, so thread_id now names the internal key instead of the
user-facing id, which makes the storage layer easy to misread.

Make the identity model explicit without touching stored data or
SQL: document the two identities in every saver and in
AbstractJdbcCheckpointSaver, annotate the schema comments with what
each column actually holds, and rename internal Java identifiers so
threadId always means the user-facing id and persistedThreadId
always means the internal surrogate UUID.

@yuluo-yx yuluo-yx 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.

LGTM, everything is good

@yuluo-yx
yuluo-yx merged commit e5f6c5a into agentic-ai-java:main Sep 30, 2026
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.

[Question] thread_id和thread_name理解起来有点混淆啊

2 participants