Add remove() method to ChatContext for flexible item removal#5131
Open
3eid wants to merge 1 commit intolivekit:mainfrom
Open
Add remove() method to ChatContext for flexible item removal#51313eid wants to merge 1 commit intolivekit:mainfrom
remove() method to ChatContext for flexible item removal#51313eid wants to merge 1 commit intolivekit:mainfrom
Conversation
Member
|
Hey, this is great, but can we have a similar API to list.remove? Like https://docs.python.org/3/tutorial/datastructures.html#more-on-lists |
Author
Good idea. To stay close to For the input, I’m leaning toward supporting both Internally it would just match by item.id in both cases. Let me know if you’d prefer restricting it to ChatItem only. |
ae844c3 to
26a6c9d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a public
remove()method toChatContextfor removing items by ID, byChatIteminstance, or a sequence of either. This avoids the need to access the private_itemslist directly.Problem
ChatContextalready provides helpers likeget_by_id()andindex_by_id(), but no public way exists to remove an item. Users currently must manipulate_itemsdirectly:Accessing
_itemsrelies on internal implementation details and can break if the structure changes.Fix
Adds a
remove()method that:ChatItem, an item ID (str), or a sequence of either.This follows the suggestion from @tinalenguyen to allow more flexible usage and aligns with existing helpers like
insert().Usage Examples
Testing
Added comprehensive unit tests covering:
ChatItemAgentConfigUpdateitemsCloses #5085