Skip to content

[ST-6] Harden framework instrumentation lifecycle and safety handling - #21

Merged
manas-fortifyroot merged 2 commits into
fr-v0.52.6.xfrom
feat/st6-framework-instrumentation-followups
Apr 20, 2026
Merged

[ST-6] Harden framework instrumentation lifecycle and safety handling#21
manas-fortifyroot merged 2 commits into
fr-v0.52.6.xfrom
feat/st6-framework-instrumentation-followups

Conversation

@manas-fortifyroot

Copy link
Copy Markdown

Summary

This PR lands the framework-instrumentation follow-ups discovered while finishing ST-6.

It tightens LiteLLM completion-safety behavior, preserves LangChain compatibility with the installed wrapt API, improves LlamaIndex delegated-provider attribution, and fixes OpenAI uninstrument cleanup so wrappers are actually removed during re-init/test isolation.

What changed

  • LiteLLM
    • make completion safety deterministic during wrapper finalization
    • add once-only completion-safety markers so late async logger callbacks become no-ops
    • preserve native OTel dedupe signaling on the FR safety wrapper span
    • improve async streaming detection coverage
  • LangChain
    • switch wrap_function_wrapper(...) calls back to positional form for compatibility with the installed wrapt version
  • LlamaIndex
    • stamp delegated-provider wrapper spans with gen_ai.request.model and gen_ai.system
    • tag delegated wrapper spans with fortifyroot.span.role="llm_wrapper" so backend extraction can skip them for LLMUsageEvent dedupe
    • improve Anthropic-style usage/provider attribution
  • OpenAI
    • guard late streaming finalization paths from mutating already-ended spans
    • add proper dotted-method unwrapping so uninstrument() really removes Class.method wrappers in v0/v1/beta surfaces
    • add regression coverage for ended-span and uninstrument lifecycle behavior

Why

These changes came out of ST-6 framework telemetry validation and post-gate warning review:

  • prevent ended-span warnings during OpenAI streaming teardown
  • prevent LiteLLM async worker races from making completion safety non-deterministic
  • preserve correct backend-side dedupe for LiteLLM native OTel child spans
  • ensure LlamaIndex safety findings retain model/provider attribution without double counting
  • keep the fork diff focused on fixes required for ST-6 validation

Verification

  • LiteLLM instrumentation tests passing
  • LlamaIndex safety-hook tests passing
  • OpenAI regression tests for late finalization and uninstrument cleanup passing
  • vendored SDK smoke/tests green after re-vendor

@manas-fortifyroot
manas-fortifyroot merged commit 06162fc into fr-v0.52.6.x Apr 20, 2026
9 checks passed
@manas-fortifyroot
manas-fortifyroot deleted the feat/st6-framework-instrumentation-followups branch April 20, 2026 15:26
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