Metadata-Version: 2.4
Name: respan-instrumentation-agentspec
Version: 0.1.0
Summary: Respan instrumentation plugin for AgentSpec
License: Apache 2.0
Author: Respan
Author-email: team@respan.ai
Requires-Python: >=3.11,<3.14
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: openinference-instrumentation-agentspec (>=0.1.0)
Requires-Dist: respan-instrumentation-openinference (>=1.2.2)
Requires-Dist: respan-tracing (>=2.16.1,<3.0.0)
Description-Content-Type: text/markdown

# respan-instrumentation-agentspec

Respan instrumentation plugin for AgentSpec (`pyagentspec`).

This package activates the upstream OpenInference AgentSpec span processor
through Respan's OpenInference translator, so AgentSpec spans are exported
through the same Respan OTLP pipeline used by `Respan`.

## Installation

```bash
pip install respan-ai respan-instrumentation-agentspec "pyagentspec[langgraph]"
```

## Usage

```python
from pyagentspec.adapters.langgraph import AgentSpecLoader
from pyagentspec.agent import Agent
from pyagentspec.llms import OpenAiConfig
from respan import Respan
from respan_instrumentation_agentspec import AgentSpecInstrumentor

respan = Respan(
    app_name="agentspec-haiku-agent",
    instrumentations=[
        AgentSpecInstrumentor(workflow_name="agentspec_haiku_agent")
    ],
)

try:
    agent = Agent(
        name="haiku_assistant",
        description="A helpful assistant that writes haikus.",
        llm_config=OpenAiConfig(name="openai", model_id="gpt-4.1-nano"),
        system_prompt="You are a helpful assistant. Respond only with a haiku.",
    )

    langgraph_agent = AgentSpecLoader().load_component(agent)
    result = langgraph_agent.invoke(
        input={"messages": [{"role": "user", "content": "Write a haiku about tracing."}]}
    )

    print(result["messages"][-1].content)
finally:
    respan.shutdown()
    respan.flush()
```

