mirror of
https://github.com/openai/codex.git
synced 2026-11-09 00:39:32 +00:00
Use explicit histogram buckets for Guardian context metrics (#44181)
## Why Guardian request and section cost distributions need shared bucket boundaries across synchronous and asynchronous reviewers so their measurements align. ## What changed - Add `histogram_with_boundaries` to session telemetry and extension metrics while preserving session attribution. - Use shared request-token buckets up to 2,000,000 tokens and section-cost buckets up to 16,777,216 for both review paths. ## Testing Extend telemetry tests to verify explicit bucket boundaries and sample counts, and Guardian integration coverage to check exported request and section metric bounds for both synchronous and asynchronous reviews. GitOrigin-RevId: e34f6972b3418bac3b061939b62eeeccaec5a299
This commit is contained in:
1 parent
c77c34ed33
commit
2bba3a29a0
16 files changed
+202
-18
No files matched your search
@@ -14,6 +14,41 @@ use crate::composition::SectionOutput;
|
||||
|
||||
pub const SECTION_COST_METRIC: &str = "codex.guardian.context.section_cost";
|
||||
pub const REQUEST_TOKENS_METRIC: &str = "codex.guardian.context.request_tokens";
|
||||
/// Fixed across reviewers and models so complete-request distributions align.
|
||||
pub const REQUEST_TOKENS_BOUNDARIES: &[f64] = &[
|
||||
1_000.0,
|
||||
4_000.0,
|
||||
16_000.0,
|
||||
32_000.0,
|
||||
64_000.0,
|
||||
128_000.0,
|
||||
256_000.0,
|
||||
400_000.0,
|
||||
512_000.0,
|
||||
1_000_000.0,
|
||||
2_000_000.0,
|
||||
];
|
||||
/// One shared scale for the section metric's count, token and byte measurements.
|
||||
/// Buckets belong to the metric name, not its measurement tag.
|
||||
pub const SECTION_COST_BOUNDARIES: &[f64] = &[
|
||||
0.0,
|
||||
1.0,
|
||||
2.0,
|
||||
4.0,
|
||||
8.0,
|
||||
16.0,
|
||||
64.0,
|
||||
256.0,
|
||||
1_024.0,
|
||||
4_096.0,
|
||||
16_384.0,
|
||||
65_536.0,
|
||||
262_144.0,
|
||||
1_048_576.0,
|
||||
4_194_304.0,
|
||||
8_388_608.0,
|
||||
16_777_216.0,
|
||||
];
|
||||
// A conservative reservation matching the existing original-image patch ceiling.
|
||||
const IMAGE_TOKEN_RESERVATION: usize = 10_000;
|
||||
/// Conservative input ceiling when the model catalog has no authoritative window.
|
||||
|
||||
@@ -55,8 +55,10 @@ pub(crate) use enforcement::Retention;
|
||||
mod budget;
|
||||
mod composition;
|
||||
pub use budget::DEFAULT_MAX_INPUT_TOKENS;
|
||||
pub use budget::REQUEST_TOKENS_BOUNDARIES;
|
||||
pub use budget::REQUEST_TOKENS_METRIC;
|
||||
pub use budget::RequestBudget;
|
||||
pub use budget::SECTION_COST_BOUNDARIES;
|
||||
pub use budget::SECTION_COST_METRIC;
|
||||
pub use budget::SectionCost;
|
||||
pub use budget::effective_input_token_limit;
|
||||
|
||||
Reference in new issue
Block a user