Metadata-Version: 2.4
Name: loongsuite-instrumentation-deepagents
Version: 0.7.0
Summary: LoongSuite DeepAgents Instrumentation
Project-URL: Homepage, https://github.com/alibaba/loongsuite-python-agent/tree/main/instrumentation-loongsuite/loongsuite-instrumentation-deepagents
Project-URL: Repository, https://github.com/alibaba/loongsuite-python-agent
Author-email: OpenTelemetry Authors <cncf-opentelemetry-contributors@lists.cncf.io>
License-Expression: Apache-2.0
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.11
Requires-Dist: loongsuite-instrumentation-langchain
Requires-Dist: loongsuite-instrumentation-langgraph
Requires-Dist: opentelemetry-api~=1.37
Requires-Dist: opentelemetry-instrumentation>=0.58b0
Requires-Dist: opentelemetry-semantic-conventions>=0.58b0
Requires-Dist: wrapt<2.0.0,>=1.0.0
Provides-Extra: instruments
Requires-Dist: deepagents<0.7.0,>=0.6.0; extra == 'instruments'
Description-Content-Type: text/markdown

# LoongSuite DeepAgents Instrumentation

LoongSuite instrumentation for [DeepAgents](https://github.com/langchain-ai/deepagents).

## Installation

```bash
pip install loongsuite-instrumentation-deepagents
```

## Usage

```python
from opentelemetry.instrumentation.deepagents import DeepAgentsInstrumentor

DeepAgentsInstrumentor().instrument()

from deepagents import create_deep_agent
```

When instrumenting manually, call `DeepAgentsInstrumentor().instrument()` before
importing or binding `deepagents.create_deep_agent`. Auto-instrumentation runs
before application imports and does not need this extra ordering step.

## What it does

This instrumentation patches `deepagents.graph.create_deep_agent` so the final
graph returned by DeepAgents is marked with `_loongsuite_react_agent = True`.
It also marks the graph as a DeepAgents agent and injects the same flags into
call-time `RunnableConfig` metadata for `invoke`, `ainvoke`, `stream`, and
`astream`.

The marker is consumed by `loongsuite-instrumentation-langchain`, which routes
the DeepAgents root graph span as an `AGENT` span instead of a generic `CHAIN`
span.

The LangChain tracer also maps each DeepAgents `model` decision node to a
`react step` span. Multi-round tool flows end the previous step with
`gen_ai.react.finish_reason = "tool_calls"` and the final step with `"stop"`.
This package intentionally does not create separate ENTRY spans or GenAI
metrics.

For DeepAgents skills, the framework first loads skill metadata through
`SkillsMiddleware.before_agent` and exposes the available skills in the system
prompt. Loading the full skill instructions happens when the agent calls the
built-in filesystem tool to read the skill file, for example
`read_file(file_path="/skills/foo/SKILL.md")`. That `execute_tool read_file`
span is annotated with `gen_ai.skill.name`, `gen_ai.skill.id`,
`gen_ai.skill.description`, and `gen_ai.skill.version` when the file path
matches a registered top-level `SKILL.md`. Reading helper files under the same
skill directory is recorded as a normal file read, not as a skill load.

## Compatibility

- `deepagents >= 0.6.0, < 0.7.0`
- Python 3.11+
