Skip to content

fix(core): make default user span time explicit#5699

Merged
chenghao-mou merged 2 commits into
mainfrom
chenghao/fix/user_span_start_time
May 11, 2026
Merged

fix(core): make default user span time explicit#5699
chenghao-mou merged 2 commits into
mainfrom
chenghao/fix/user_span_start_time

Conversation

@chenghao-mou
Copy link
Copy Markdown
Member

tracer.start_span has a default value when start_time is None, so we need a default value for _user_turn_start as well to make sure they are consistent.

tracer.start_span has a default value when start_time is None, so we need a default value for _user_turn_start as well to make sure they are consistent.
@chenghao-mou chenghao-mou requested a review from a team May 10, 2026 12:49
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@chenghao-mou chenghao-mou merged commit ff7a393 into main May 11, 2026
24 checks passed
@chenghao-mou chenghao-mou deleted the chenghao/fix/user_span_start_time branch May 11, 2026 09:40
Copy link
Copy Markdown
Contributor

This is an automated Claude Code Routine created by @toubatbrian. Right now it is in experimentation stage. The automation reviewed this PR for an auto-port into agents-js.

Decision: skipping the port.

The Python fix targets a consistency issue specific to the Python implementation: previously, calling _ensure_user_turn_span(start_time=None) would let tracer.start_span(..., start_time=None) fall back to the OTel SDK default while self._user_turn_start stayed None, leaving the span's actual start time and the separately-tracked _user_turn_start field out of sync (the latter is what _bounce_eou_task consumes for EOU metrics). The fix materializes start_time = time.time() once and assigns both from it.

The equivalent code in agents-js (agents/src/voice/audio_recognition.ts, ensureUserTurnSpan) does not have a sibling userTurnStart field that needs to stay in sync with the span's start time:

  • The bounceEOUTask EOU metric path uses this.speechStartTime — which is populated exclusively by the VAD INFERENCE_DONE handler, backdated by ev.rawAccumulatedSpeech, and reset only on commit / clear. Its lifecycle is independent of ensureUserTurnSpan.
  • ensureUserTurnSpan(startTime?) forwards startTime directly to tracer.startSpan({ ..., startTime }). When undefined, the OTel JS SDK already substitutes hrtime() internally, matching the Python post-fix behavior at the span level.

So in agents-js the two-field inconsistency the Python PR fixes does not exist; mirroring the diff verbatim would be a no-op (an explicit Date.now() fallback that the SDK already does). No port action needed.

— Automated routine


Generated by Claude Code

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.

3 participants