Skip to content

feat(examples): add LangGraph tracing example with AgentOps - #542

Open
REISEN2330 wants to merge 2 commits into
microsoft:mainfrom
REISEN2330:feat/langgraph-tracing-example
Open

feat(examples): add LangGraph tracing example with AgentOps#542
REISEN2330 wants to merge 2 commits into
microsoft:mainfrom
REISEN2330:feat/langgraph-tracing-example

Conversation

@REISEN2330

Copy link
Copy Markdown

Fixes #535

What

Adds a self-contained examples/langgraph/ example that traces a small
LangGraph workflow through Agent Lightning's AgentOps tracer.

  • Two-node graph: a deterministic FakeMessagesListChatModel node plus
    a plain Python node — no API keys, no GPU, no network calls required.
  • Runs under AgentOpsTracer inside a rollout and reads the captured
    spans back from the in-memory store, asserting the workflow execution
    and the model call were both captured.
  • Follows the repo example conventions (README with Included Files), and
    wires a CPU-only smoke-test job into the CPU Test workflow so the
    example is exercised on every PR.

Why

#535 asked for LangChain/LangGraph usage examples. The repo already
ships the AgentOps LangChain instrumentation (get_langchain_handler),
so this example demonstrates the supported integration path for
LangGraph agents.

Verification

  • uv sync --frozen --no-default-groups --group dev --group langchain
  • python examples/langgraph/trace_langgraph.py — exits 0, prints the
    captured spans (langgraph.workflow.execute + model call present)
  • pre-commit run --files examples/langgraph/trace_langgraph.py examples/langgraph/README.md .github/workflows/tests.yml — clean

Copilot AI lite review requested due to automatic review settings August 16, 2026 13:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds an offline LangGraph tracing example that runs under Agent Lightning’s AgentOps tracer, documents how to run it, and wires it into CI to ensure the example stays working.

Changes:

  • Added a two-node LangGraph workflow example that traces spans into an in-memory store and asserts expected tracing behavior.
  • Added README documentation for running and understanding the LangGraph example.
  • Added a GitHub Actions job to execute the example in CI.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
examples/langgraph/trace_langgraph.py New runnable example that builds a LangGraph workflow, runs it under tracing, and validates stored spans.
examples/langgraph/README.md Documents how to run the example and what output/behavior to expect.
.github/workflows/tests.yml Adds CI job to run the LangGraph example to prevent regressions.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

enable-cache: true
python-version: '3.12'
- name: Sync dependencies
run: uv sync --frozen --no-default-groups --group langchain
Comment thread examples/langgraph/trace_langgraph.py Outdated
def reverse_text(state: MessagesState) -> Dict[str, Any]:
"""Reverse the last message's content without any model."""
last = state["messages"][-1]
return {"messages": [AIMessage(content=last.content[::-1])]} # type: ignore
Comment thread examples/langgraph/trace_langgraph.py Outdated
# The exact span names are owned by the AgentOps instrumentation, so
# assert on the structural guarantees instead: the workflow execution
# is captured and at least one model call was traced.
assert "langgraph.workflow.execute" in span_names, span_names
@REISEN2330

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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.

inquiry

2 participants