Skip to content

fix(autogen-ext): include tool_choice in ChatCompletionCache cache key (#7968) - #8006

Open
MOHAMMED WASIM KHAN (wasim-builds) wants to merge 1 commit into
microsoft:mainfrom
wasim-builds:fix/7968-chat-completion-cache-tool-choice
Open

fix(autogen-ext): include tool_choice in ChatCompletionCache cache key (#7968)#8006
MOHAMMED WASIM KHAN (wasim-builds) wants to merge 1 commit into
microsoft:mainfrom
wasim-builds:fix/7968-chat-completion-cache-tool-choice

Conversation

@wasim-builds

@wasim-builds MOHAMMED WASIM KHAN (wasim-builds) commented Jul 29, 2026

Copy link
Copy Markdown

Fixes #7968

Problem

ChatCompletionCache._check_cache() computed the SHA-256 cache key from messages and tools only. Calls with identical messages/tools but different tool_choice values (e.g., auto vs none) incorrectly returned stale cached results.

Fix

Include tool_choice in the cache key computation.

Changes

  • python/packages/autogen-ext/src/autogen_ext/models/cache/_chat_completion_cache.py: include tool_choice in key
  • python/packages/autogen-ext/tests/models/test_chat_completion_cache.py: add test_cache_key_includes_tool_choice

Verification

Cache miss now correctly occurs when tool_choice changes.

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.

ChatCompletionCache cache key ignores tool_choice, serves stale cached response when only tool_choice differs

1 participant