Skip to content

loongsuite-python-agent 0.2.0

Choose a tag to compare

@Cirilla-zmh Cirilla-zmh released this 12 Mar 09:41
· 102 commits to main since this release
33fb2d6

loongsuite-python-agent 0.2.0

Installation

pip install loongsuite-distro==0.2.0
loongsuite-bootstrap -a install --version 0.2.0

Package Versions

  • loongsuite-* packages: 0.2.0
  • opentelemetry-* packages: 0.61b0

loongsuite-util-genai

Added

  • Add RetrievalDocument dataclass for typed retrieval document representation (id, score, content, metadata). (#145)
  • Control RetrievalDocument serialization: when content capturing is NO_CONTENT, only serialize id and score; when SPAN_ONLY/SPAN_AND_EVENT, serialize full (id, score, content, metadata) (#145)
  • Add Entry span (gen_ai.span.kind=ENTRY) and ReAct Step span (gen_ai.span.kind=STEP) support in ExtendedTelemetryHandler with types, utilities, and context-manager APIs (#135)
  • Propagate gen_ai.session.id and gen_ai.user.id into Baggage during start_entry, enabling traffic coloring via BaggageSpanProcessor for all child spans within the entry block (#135)

Changed

  • Retrieval semantic convention: Align retrieval spans with LoongSuite spec (#145)
    • gen_ai.operation.name: retrieve_documentsretrieval
    • gen_ai.retrieval.querygen_ai.retrieval.query.text for query text
    • Span name: retrieval {gen_ai.data_source.id} when data_source_id is set
    • Add RetrievalInvocation fields: data_source_id, provider, request_model, top_k
  • Add optional context parameter to all start_* methods in TelemetryHandler and ExtendedTelemetryHandler for explicit parent-child span linking (#135)
  • Unify attach/detach strategy in ExtendedTelemetryHandler: always attach regardless of whether context is provided; stop_*/fail_* guards restored to context_token is None or span is None (#135)

Fixed

  • Fix gen_ai.retrieval.query to respect content capturing mode: when OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT is NO_CONTENT, both query and documents are now omitted from retrieve spans (previously only documents were gated) (#139)
  • Fix _safe_detach to use _RUNTIME_CONTEXT.detach directly, avoiding noisy ERROR log from OTel SDK's context_api.detach wrapper (#135)
  • Fix undefined otel_context reference in _multimodal_processing.py process_multimodal_fail, replaced with _safe_detach (#135)

loongsuite-instrumentation-langchain

Added

  • ReAct Step instrumentation for AgentExecutor (#139)

    • Monkey-patch AgentExecutor._iter_next_step and _aiter_next_step to instrument each ReAct iteration
    • Dual patch: patch both langchain.agents (0.x) and langchain_classic.agents (1.x) when available, so either import path works
    • Covers invoke, ainvoke, stream, astream, batch, abatch
    • ReAct Step spans: gen_ai.span.kind=STEP, gen_ai.operation.name=react, gen_ai.react.round, gen_ai.react.finish_reason
    • Span hierarchy: Agent > ReAct Step > LLM/Tool
  • LangGraph ReAct agent support (requires loongsuite-instrumentation-langgraph) (#139)

    • Detect LangGraph agents via Run.metadata["_loongsuite_react_agent"]
      (metadata injected by the LangGraph instrumentation)
    • Disambiguate the top-level graph (Agent span) from child nodes (chain
      spans) using inside_langgraph_react propagation
    • Agent name resolution: when the ReAct agent is invoked inside an outer
      graph node, inherit the node's name (e.g. invoke_agent product_agent)
      instead of the generic default (invoke_agent LangGraph)
    • Track ReAct step boundaries via callback-based detection of the
      "agent" node within the graph
    • Span hierarchy: Agent > ReAct Step > LLM/Tool (same as AgentExecutor)

Breaking Changes

  • Rewrite the instrumentation for LangChain with genai-util (#139)
    • Replaced the legacy wrapt-based function wrapping with BaseTracer callback mechanism
    • Migrated to ExtendedTelemetryHandler from opentelemetry-util-genai for standardized GenAI semantic conventions
    • Added Agent detection by run.name, TTFT tracking, content capture gating, and RLock thread safety
    • Added new test suite with oldest/latest dependency matrices

loongsuite-instrumentation-langgraph

Added

  • Initial instrumentation framework for LangGraph (#143)
    • Patch create_react_agent to set _loongsuite_react_agent = True flag
      on CompiledStateGraph
    • Patch Pregel.stream / Pregel.astream to inject
      metadata["_loongsuite_react_agent"] into RunnableConfig, enabling
      LangChain instrumentation to detect ReAct agents via callback metadata
    • All patches use wrapt.wrap_function_wrapper /
      opentelemetry.instrumentation.utils.unwrap (consistent with
      loongsuite-instrumentation-langchain)

loongsuite-instrumentation-litellm

Added

  • Initialize the instrumentation for Litellm (#88)