Add bounded size limit to _pending_tool_calls dictionary#125
Merged
nikhilNava merged 3 commits intonikhilc/OpenAIAutoInstrumentation-fixattributesfrom Jan 21, 2026
Merged
Conversation
Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
nikhilNava
approved these changes
Jan 21, 2026
Copilot
AI
changed the title
[WIP] Address feedback on OpenAI auto instrumentation PR
Add bounded size limit to _pending_tool_calls dictionary
Jan 21, 2026
52f6cb1
into
nikhilc/OpenAIAutoInstrumentation-fixattributes
1 check passed
nikhilNava
added a commit
that referenced
this pull request
Jan 21, 2026
* fix input and output messages for invoke span and fix tool call messages * add test for invoke agent auto instrumented * Add bounded size limit to _pending_tool_calls dictionary (#125) * Initial plan * Implement bounded size for _pending_tool_calls to prevent memory growth Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com> * Fix trailing empty line in test file Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com> * Fix code formatting with ruff (#126) * Initial plan * Fix formatting with ruff format Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com> --------- Co-authored-by: Nikhil Chitlur Navakiran (from Dev Box) <nikhilc@microsoft.com> Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com> Co-authored-by: nikhilNava <211831449+nikhilNava@users.noreply.github.com>
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.
The
_pending_tool_callsdictionary accumulates tool call IDs without bounds when tool calls are captured but never consumed by matching FunctionSpans. In long-running applications, this causes unbounded memory growth.Changes
_MAX_PENDING_TOOL_CALLS = 1000constant, matching the pattern used for_MAX_HANDOFFS_IN_FLIGHT_pending_tool_callsfromdicttoOrderedDictto enable FIFO evictioncapture_tool_call_ids()to enforce max size by removing oldest entries when limit is exceededThis mirrors the existing bounded approach used for
_reverse_handoffs_dict, ensuring consistent memory safety across the trace processor.✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.