Skip to content

Comments

feat: Add LangGraph workflow auto-detection and agent tag parsing#132

Open
NikitaVoitov wants to merge 1 commit intosignalfx:mainfrom
NikitaVoitov:feat/langgraph-workflow-detection
Open

feat: Add LangGraph workflow auto-detection and agent tag parsing#132
NikitaVoitov wants to merge 1 commit intosignalfx:mainfrom
NikitaVoitov:feat/langgraph-workflow-detection

Conversation

@NikitaVoitov
Copy link

Summary

This PR adds automatic detection of LangGraph workflows and parsing of agent attributes from tags.

Problem

The current instrumentation lacks:

  1. LangGraph auto-detection: Workflows using LangGraph don't get workflow_type or framework attributes
  2. Agent tag parsing: Agent metadata passed via tags (common pattern) is ignored
  3. Workflow descriptions: No way to capture workflow/agent descriptions for better observability

Root Cause

  1. on_chain_start doesn't check for LangGraph-specific metadata keys (langgraph_version, graph_id)
  2. Agent attributes from tags (agent_type:, agent_description:, agent_tools:) aren't parsed
  3. description: tags and ls_description metadata aren't extracted

Solution

1. LangGraph Auto-Detection

# In on_chain_start - detect LangGraph from metadata
if metadata:
    if metadata.get("langgraph_version") or metadata.get("graph_id"):
        wf.workflow_type = "graph"
        wf.framework = "langgraph"
    # Extract description from metadata
    desc = metadata.get("ls_description") or metadata.get("description")
    if desc:
        wf.description = _safe_str(desc)

2. Agent Tag Parsing

# In _start_agent_invocation - parse agent attributes from tags
if tags:
    for tag in tags:
        if tag.startswith("agent_type:"):
            agent.agent_type = tag[11:]
        elif tag.startswith("agent_description:"):
            agent.description = tag[18:]
        elif tag.startswith("agent_tools:"):
            agent.tools = tag[12:].split(",")

3. Workflow Description from Tags

# Support description via tag
if not wf.description:
    for tag in tags:
        if tag.startswith("description:"):
            wf.description = tag[len("description:"):]
            break
# Auto-generate from graph_id if not set
if not wf.description and metadata.get("graph_id"):
    wf.description = f"LangGraph workflow: {metadata['graph_id']}"

Evidence

Before Fix (trace 27ba4165c26889bb6d328fd356d9381d)

Attribute Value
gen_ai.workflow.type ❌ Missing
gen_ai.framework ❌ Missing
gen_ai.workflow.description ❌ Missing
gen_ai.agent.type ❌ Missing
gen_ai.agent.description ❌ Missing
gen_ai.agent.tools ❌ Missing

After Fix

Agent trace (fe915fd88fd3c8542e2adee30b42559f):

Attribute Value
gen_ai.agent.name healthcare_agent
gen_ai.agent.type react
gen_ai.agent.description Healthcare agent
gen_ai.agent.tools ["query_member_data","search_knowledge_base"]
gen_ai.framework langchain

Workflow trace (8593063fe9ba82df06d5f7a126e658b2):

Attribute Value
gen_ai.workflow.type graph
gen_ai.workflow.description Healthcare processing workflow
gen_ai.framework langgraph

Testing

Added 5 unit tests:

  • test_langgraph_workflow_auto_detection_from_metadata
  • test_agent_tag_parsing_name
  • test_agent_tag_parsing_type_and_description
  • test_agent_tag_parsing_tools
  • test_description_tag_for_workflow

Files Changed

File Changes
callback_handler.py LangGraph detection + agent tag parsing logic
test_callback_handler_agent.py +5 tests

Why This Matters

  1. Agent Flow Visualization: workflow_type enables proper visualization in Splunk O11y
  2. LangGraph Support: LangGraph dev server replaces custom metadata but preserves tags - tag parsing ensures attributes survive
  3. Better Observability: Agent descriptions and tools visible in traces aid debugging

- Auto-detect LangGraph from metadata keys (langgraph_version, graph_id)
- Set workflow_type='graph' and framework='langgraph' for LangGraph workflows
- Parse agent attributes from tags (agent_type:, agent_description:, agent_tools:)
- Support description: tag for workflows
- Generate workflow description from graph_id if not provided
- Add 5 tests for LangGraph detection and agent tag parsing

This enables proper agent flow visualization in O11y and supports
LangGraph dev server which replaces custom metadata but preserves tags
@NikitaVoitov NikitaVoitov requested review from a team as code owners January 13, 2026 18:46
@github-actions
Copy link


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

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