Skip to content

fix: populate prefix_cache_info in OpenAI/session rollout path#960

Open
guapisolo wants to merge 1 commit intomainfrom
fix/openai-prefix-cache-info
Open

fix: populate prefix_cache_info in OpenAI/session rollout path#960
guapisolo wants to merge 1 commit intomainfrom
fix/openai-prefix-cache-info

Conversation

@guapisolo
Copy link
Copy Markdown
Collaborator

The /generate path already collects prefix cache stats via update_from_meta_info, but the OpenAI endpoint path skipped it, causing rollout/prefix_cache_hit_rate to always report 0 for session-based rollouts.

The /generate path already collects prefix cache stats via
update_from_meta_info, but the OpenAI endpoint path skipped it,
causing rollout/prefix_cache_hit_rate to always report 0 for
session-based rollouts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements prefix cache tracking by extracting metadata from OpenAI responses and populating the sample's cache information. It includes new tests for single-turn and multi-turn scenarios, as well as handling for missing fields. A review comment suggests refactoring the metadata extraction for consistency and safety.

case "abort":
sample.status = Sample.Status.ABORTED

sample.prefix_cache_info.add(choice.get("meta_info", {}))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While this correctly populates the prefix cache information, it is inconsistent with the rest of the function which accesses meta_info directly (e.g., lines 159-160). If meta_info is missing, the function will have already raised a KeyError before reaching this line. For better consistency and safety, consider extracting meta_info once at the beginning of the function and using it throughout.

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.

1 participant