Skip to content

fix: flag negative and out-of-order timestamps in check_latency (#15) - #18

Closed
Dheerajvarma1 wants to merge 1 commit into
AgentPostmortem:mainfrom
Dheerajvarma1:fix/check-latency-negative-timestamps
Closed

fix: flag negative and out-of-order timestamps in check_latency (#15)#18
Dheerajvarma1 wants to merge 1 commit into
AgentPostmortem:mainfrom
Dheerajvarma1:fix/check-latency-negative-timestamps

Conversation

@Dheerajvarma1

Copy link
Copy Markdown

What & why

Fixes #15.

Root Cause

check_latency() computes response latency as
gap = agent_turn.start_s - user_turn.end_s and previously only checked
if gap > budget_s:.

As a result, materially negative gaps caused by excessive overlap or
out-of-order timing data were silently ignored because negative values
could never exceed the latency budget. This allowed malformed timing data
to pass without any finding.

Fix

Added an elif gap < -0.3: check to check_latency() that emits a
high-severity invalid_timing finding pointing to the offending agent
turn.

Overlap Policy

The existing repository behavior allows small conversational overlap.
Therefore, gaps between -0.3s and 0.0s remain valid and are not flagged.

Tests

Added regression tests covering:

  • Negative response latency beyond the normal overlap threshold
  • Out-of-order/backwards timestamps
  • Legitimate ~200ms conversational overlap

Verification

  • pytest -v — 22 passed
  • ruff check . — all checks passed

@Dheerajvarma1

Copy link
Copy Markdown
Author

I found that upstream PR #17 already addressed issue #15, so I'm closing this PR to avoid duplicating the fix. Thanks!

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.

Negative/out-of-order clocks silently pass check_latency

1 participant