Skip to content

fix(adk): copy-on-write SetMessageID to avoid concurrent map panic - #1085

Merged
hi-pender merged 1 commit into
mainfrom
fix/adk-msgid-cow
Jun 17, 2026
Merged

fix(adk): copy-on-write SetMessageID to avoid concurrent map panic#1085
hi-pender merged 1 commit into
mainfrom
fix/adk-msgid-cow

Conversation

@hi-pender

Copy link
Copy Markdown
Contributor

Summary

  • ChatModel streaming fans out the same *schema.Message pointers to multiple consumers inside the model body. Stamping the eino message ID into Extra via an in-place map write then races with concurrent reads of that shared map, triggering a fatal concurrent map read and map write panic.
  • Make internal.SetMessageID copy-on-write: allocate a fresh map, copy existing entries, then set the ID. All callers already reassign the returned map (v.Extra = SetMessageID(...)), so the change is transparent and fixes every path at once.
  • This removes the map-level panic. The field-level race on the exported Extra field cannot be eliminated by the framework while Extra is public, and is documented as a known limit in the function doc.

Test plan

  • go build ./...
  • go test -race ./adk/... (all green, incl. 30s race run on the adk root package)

🤖 Generated with Claude Code

ChatModel streaming fans out the same *schema.Message pointers to multiple
consumers inside the model body. Stamping the eino message ID into Extra via
an in-place map write then races with concurrent reads of that shared map,
triggering a fatal "concurrent map read and map write" panic.

Make SetMessageID copy-on-write: allocate a fresh map, copy existing entries,
then set the ID. All callers already reassign the returned map, so the change
is transparent. This removes the map-level panic; the field-level race on the
exported Extra field is documented as a known, unfixable-by-framework limit.

Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
@hi-pender
hi-pender merged commit e8832e2 into main Jun 17, 2026
17 checks passed
@hi-pender
hi-pender deleted the fix/adk-msgid-cow branch June 17, 2026 02:54
@codecov

codecov Bot commented Jun 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.16%. Comparing base (f683210) to head (b9279a6).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1085   +/-   ##
=======================================
  Coverage   83.15%   83.16%           
=======================================
  Files         162      162           
  Lines       23133    23134    +1     
=======================================
+ Hits        19237    19239    +2     
+ Misses       2632     2631    -1     
  Partials     1264     1264           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants