Skip to content

fix(studio): keep thread metadata and state updates atomic - #220

Merged
yuluo-yx merged 1 commit into
agentic-ai-java:mainfrom
Duansg:fix/studio-thread-atomic
Oct 23, 2026
Merged

yuluo-yx merged 1 commit into
agentic-ai-java:mainfrom
Duansg:fix/studio-thread-atomic

Conversation

@Duansg

@Duansg Duansg commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Describe what this PR does / why we need it

Contributing to ARGI: Studio thread metadata and state are stored in one record per key, so create, update and delete can no longer leave orphaned or stale state.

Does this pull request fix one issue?

Fixes #193

Describe how you did it

  • Replaced the two maps in ThreadServiceImpl with a single ConcurrentHashMap<String, ThreadRecord>; every operation is one atomic map call.
  • Each created thread has a generation token. A delayed updateThreadState only applies to the instance it observed, so it is dropped after delete and cannot pollute a re-created thread with the same ID.
  • getThreadState returns a copy. HTTP endpoints, DTOs and the encoded key format are unchanged.

Describe how to verify it

./mvnw -pl :argi-studio -am test -Dtest=ThreadServiceImplTest. New latch-based tests cover update/delete, delete/recreate and create/delete interleavings; the first two fail on the previous implementation.

Special notes for reviews

Storage stays in memory; no database is introduced.

@yuluo-yx yuluo-yx left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed the atomic thread record and generation checks with the delete/recreate regression tests. The frontend dependency audit failure is tracked separately from this fix.

@yuluo-yx
yuluo-yx merged commit e0789fc into agentic-ai-java:main Oct 23, 2026
6 of 7 checks passed
@Duansg
Duansg deleted the fix/studio-thread-atomic branch October 23, 2026 01:34
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][OPT-09] 保证 Studio 会话元数据与状态的原子更新删除

2 participants