Skip to content

fix: #2776 keep private tool metadata out of persisted session items#2781

Merged
seratch merged 2 commits intomainfrom
fix/tool-call-replay-metadata
Mar 26, 2026
Merged

fix: #2776 keep private tool metadata out of persisted session items#2781
seratch merged 2 commits intomainfrom
fix/tool-call-replay-metadata

Conversation

@seratch
Copy link
Member

@seratch seratch commented Mar 26, 2026

This pull request fixes #2776 ToolCallItem metadata handling so private _agents_* fields are never written into persisted session history. Tool-call description and title still exist on in-memory run items and in RunState, but persisted session transcripts now remain valid TResponseInputItems that can be replayed directly or shared across SDK versions without introducing unsupported tool-call fields.

The change keeps defensive read-side sanitization in place for session replay and OpenAI responses compaction. That means stale or externally written _agents_* keys are stripped before model calls, fingerprinting, and responses.compact(input=...), while normal session persistence now stores only API-valid tool-call payloads. Additional regression coverage checks the direct to_input_item() surface, the run-item replay path, session persistence, session replay, and both uncached and cached compaction-input flows.

@seratch seratch changed the title fix: keep private tool metadata out of persisted session items fix: #2776 keep private tool metadata out of persisted session items Mar 26, 2026
@seratch seratch force-pushed the fix/tool-call-replay-metadata branch from c5b7c28 to cf69e10 Compare March 26, 2026 05:26
@seratch seratch added this to the 0.13.x milestone Mar 26, 2026
@seratch seratch force-pushed the fix/tool-call-replay-metadata branch from cf69e10 to ccf6e99 Compare March 26, 2026 10:29
@seratch seratch merged commit c2f6690 into main Mar 26, 2026
9 checks passed
@seratch seratch deleted the fix/tool-call-replay-metadata branch March 26, 2026 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working feature:sessions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ToolCallItem.to_input_item() drops title and description on session persistence

1 participant