Skip to content

Conversation

@srilaasya
Copy link
Contributor

📥 Pull Request

📘 Description

  • Adds complete instrumentation for Xpander enterprise agent SDK with session tracking and 5-level span hierarchy

  • Creates persistent sessions across executions using memory_thread_id for conversation continuity

  • Captures tool calls, LLM interactions, and agent workflows with OpenAI-compatible message formatting

    Session Management

  • Implemented XpanderContext for thread-safe session tracking across agent executions

  • Sessions persist until conversation completion detected via xpfinish-agent-execution-finished tool

  • Handles concurrent sessions with proper span lifecycle management

Span Hierarchy

  • Session spans (root) → Agent/Workflow spans → LLM spans → Execution spans → Tool spans
  • Agent contexts propagate to LLM calls through session ID mapping
  • Tool execution maintains parent context from calling LLM interaction

Files Added/Modified

  • instrumentor.py - Main instrumentation class with method wrapping
  • context.py - Session context management separated from core logic
  • trace_probe.py - Auto-activation and backward compatibility functions
  • init.py - Updated imports for modular architecture

🧪 Testing

  • Pre-commit hooks pass (ruff + ruff-format)
  • Session persistence verified across multiple executions
  • Span nesting confirmed with proper parent-child relationships
  • Tool extraction tested with various call formats

Example

Screenshot 2025-07-21 at 12 59 25 PM

@codecov
Copy link

codecov bot commented Jul 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@areibman areibman merged commit b49c5d6 into main Jul 31, 2025
32 of 43 checks passed
@areibman areibman deleted the xpander-instrumentation branch July 31, 2025 17:21
@dudutwizer
Copy link

We released version 2 of the xpander-sdk to complete the transition to a backend platform. We will submit a pull request to your codebase with the necessary changes.

In the meantime, please lock the xpander-sdk to version 1.64.0

You can find the package here: https://pypi.org/project/xpander-sdk/

fenilfaldu pushed a commit that referenced this pull request Aug 4, 2025
* xpander instrumentation

* add xpander docs

* update graph view

* cleanup instrumentation, updated xpandercontext

* update instrumentor.py

* fix ruff import err

* Update Xpander documentation and example

---------

Co-authored-by: Dwij <96073160+Dwij1704@users.noreply.github.com>
Co-authored-by: Alex Reibman <areibman@gmail.com>
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.

5 participants