Skip to content
7 changes: 7 additions & 0 deletions agentops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@
elif default_tags:
merged_tags = default_tags

# Check if in a Jupyter Notebook (manual start/end_trace())
try:
get_ipython().__class__.__name__ == "ZMQInteractiveShell" # type: ignore
auto_start_session = False

Check warning on line 122 in agentops/__init__.py

View check run for this annotation

Codecov / codecov/patch

agentops/__init__.py#L122

Added line #L122 was not covered by tests
except NameError:
pass

# Prepare initialization arguments
init_kwargs = {
"api_key": api_key,
Expand Down
1 change: 0 additions & 1 deletion agentops/instrumentation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
from agentops.logging import logger
from agentops.sdk.core import tracer


# Module-level state variables
_active_instrumentors: list[BaseInstrumentor] = []
_original_builtins_import = builtins.__import__ # Store original import
Expand Down
2 changes: 1 addition & 1 deletion docs/v2/usage/sdk-reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Initializes the AgentOps SDK and automatically starts tracking your application.
- `default_tags` (List[str], optional): Default tags for the sessions that can be used for grouping or sorting later (e.g. ["GPT-4"]).
- `tags` (List[str], optional): [Deprecated] Use `default_tags` instead.
- `instrument_llm_calls` (bool, optional): Whether to instrument LLM calls automatically. Defaults to True.
- `auto_start_session` (bool, optional): Whether to start a session automatically when the client is created. Defaults to True.
- `auto_start_session` (bool, optional): Whether to start a session automatically when the client is created. Set to False if running in a Jupyter Notebook. Defaults to True.
- `auto_init` (bool, optional): Whether to automatically initialize the client on import. Defaults to True.
- `skip_auto_end_session` (bool, optional): Don't automatically end session based on your framework's decision-making. Defaults to False.
- `env_data_opt_out` (bool, optional): Whether to opt out of collecting environment data. Defaults to False.
Expand Down
2 changes: 1 addition & 1 deletion examples/openai_agents/customer_service_agent.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"metadata": {},
"outputs": [],
"source": [
"agentops.init(tags=[\"customer-service-agent\", \"openai-agents\", \"agentops-example\"], auto_start_session=False)\n",
"agentops.init(tags=[\"customer-service-agent\", \"openai-agents\", \"agentops-example\"])\n",
"tracer = agentops.start_trace(trace_name=\"Customer Service Agent\")"
]
},
Expand Down
Loading