Install the integration extra:
pip install "agentx-python[crewai]" crewai
observer.kickoff()
Wraps crew.kickoff() for you. Task outputs are automatically captured as tool calls.
from agentx import AgentX
from agentx.integrations.crewai import AgentXCrewObserver
from crewai import Agent, Task, Crew
client = AgentX(
api_key="agx-xxxxxxxxxxxxxxxx",
workspace_id="xxxxxxxxxxxx", # optional
)
observer = AgentXCrewObserver(
tracer=client.tracer,
name="support-crew",
metadata={"env": "production"},
)
researcher = Agent(
role="Policy Researcher",
goal="Find relevant company policies",
backstory="You look up policies from the knowledge base.",
verbose=False,
)
writer = Agent(
role="Support Writer",
goal="Write clear, friendly support responses",
backstory="You turn policy details into helpful customer replies.",
verbose=False,
)
crew = Crew(
agents=[researcher, writer],
tasks=[
Task(
description="Look up the cancellation policy and summarize it.",
expected_output="A concise policy statement.",
agent=researcher,
),
Task(
description="Write a friendly support reply about cancelling a subscription.",
expected_output="A clear, helpful response to send to the customer.",
agent=writer,
),
],
verbose=False,
)
result = observer.kickoff(crew, inputs={"query": "cancel subscription"})
print(result.raw)
client.tracer.flush(timeout=10)
What gets traced
| Field | Source |
|---|
input | inputs dict passed to kickoff() |
output | result.raw (CrewOutput string) |
latencyMs | Wall-clock time of the full crew run |
toolCalls | Each task output — description as name, raw as output |
error | Exception message if crew.kickoff() raises |
AgentXCrewObserver reference
AgentXCrewObserver(
tracer: Tracer,
name: str = "crewai-crew",
metadata: dict | None = None,
session_id: str | None = None,
)
| Parameter | Description |
|---|
tracer | client.tracer from your AgentX instance |
name | Label shown in the AgentX UI |
metadata | Static key-value metadata attached to every trace |
session_id | Links traces from the same conversation thread |
observe() parameters
observer.observe(
name: str | None = None,
input: Any = None,
metadata: dict | None = None,
session_id: str | None = None,
) -> contextmanager
Inside the with block, assign span.output before exiting to set the trace output.
Call tracer.flush() before your process exits in scripts or one-shot jobs.
In long-running servers it is not required — traces drain automatically in the
background.