Session Link Not Appearing In Terminal When AGENTOPS_LOG_LEVEL=DEBUG

by ADMIN 69 views

Issue Description

When setting AGENTOPS_LOG_LEVEL=DEBUG, the AgentOps session link is not displayed in the terminal output. This issue can cause confusion and make it difficult to track and manage sessions, especially in environments where debugging is crucial.

Steps to Reproduce

To reproduce this issue, follow these steps:

1. Set Environment Variable

Set the AGENTOPS_LOG_LEVEL environment variable to DEBUG. This can be done using the following command:

export AGENTOPS_LOG_LEVEL=DEBUG

2. Import and Initialize AgentOps

Import and initialize the AgentOps library in your code. This will enable the logging of session links and other events.

import agentops

# Initialize AgentOps
agentops.init()

3. Make LLM Calls (e.g., with OpenAI)

Make LLM calls using the AgentOps library. For example, you can use the OpenAI API to make a call to the model.

import openai

# Make an LLM call using OpenAI
response = openai.Model.create(
    model="text-davinci-003",
    prompt="This is a prompt for the model",
    temperature=0.5,
    max_tokens=2048,
)

Expected Behavior

The session link should be displayed in the terminal output regardless of the log level setting. This is because the session link is a critical piece of information that helps users track and manage their sessions.

Actual Behavior

The session link is not displayed when the DEBUG log level is set. This is because the session link logging is filtered out when the log level is set to DEBUG.

Additional Context

This issue was observed when using AgentOps with OpenAI in a Jupyter notebook environment. The session is being created correctly and events are being tracked, but the link to view the session in the dashboard is not displayed in the terminal output.

Possible Solution

To resolve this issue, ensure that the session link logging is not filtered out when the DEBUG log level is set. This can be done by modifying the logging configuration to include the session link logging at the DEBUG level.

Modify Logging Configuration

Modify the logging configuration to include the session link logging at the DEBUG level. This can be done by adding the following code:

import logging

# Create a logger
logger = logging.getLogger('agentops')

# Set the log level to DEBUG
logger.setLevel(logging.DEBUG)

# Create a formatter
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')

# Create a handler
handler = logging.StreamHandler()

# Add the formatter to the handler
handler.setFormatter(formatter)

# Add the handler to the logger
logger.addHandler(handler)

Verify Session Link Logging

Verify that the session link logging is included at the DEBUG level by checking the terminal output. If the session link logging is included, the link should be displayed in the terminal output.

Conclusion

In conclusion, the session link is not displayed in the terminal output when AGENTOPS_LOG_LEVEL=DEBUG. This issue can be resolved by modifying the logging configuration to include the session link logging at the DEBUG level. By following the steps outlined in this article, developers can ensure that the session link is displayed in the terminal output, even when the DEBUG log level is set.

Troubleshooting Tips

  • Verify that the AGENTOPS_LOG_LEVEL environment variable is set to DEBUG.
  • Check the logging configuration to ensure that the session link logging is included at the DEBUG level.
  • Verify that the session link logging is not filtered out by the logging configuration.

Related Issues

API Documentation

Code Examples

FAQs

  • Q: Why is the session link not displayed in the terminal output? A: The session link is not displayed in the terminal output because the logging configuration is filtering out the session link logging at the DEBUG level.
  • Q: How can I resolve this issue? A: To resolve this issue, modify the logging configuration to include the session link logging at the DEBUG level.
    Frequently Asked Questions (FAQs) =====================================

Q: What is the purpose of the AgentOps session link?

A: The AgentOps session link is a unique identifier that allows users to track and manage their sessions. It provides a direct link to the session in the dashboard, making it easier to access and manage session data.

Q: Why is the session link not displayed in the terminal output when AGENTOPS_LOG_LEVEL=DEBUG?

A: The session link is not displayed in the terminal output when AGENTOPS_LOG_LEVEL=DEBUG because the logging configuration is filtering out the session link logging at the DEBUG level. To resolve this issue, modify the logging configuration to include the session link logging at the DEBUG level.

Q: How can I modify the logging configuration to include the session link logging at the DEBUG level?

A: To modify the logging configuration, you can add the following code:

import logging

# Create a logger
logger = logging.getLogger('agentops')

# Set the log level to DEBUG
logger.setLevel(logging.DEBUG)

# Create a formatter
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')

# Create a handler
handler = logging.StreamHandler()

# Add the formatter to the handler
handler.setFormatter(formatter)

# Add the handler to the logger
logger.addHandler(handler)

Q: What are the benefits of displaying the session link in the terminal output?

A: Displaying the session link in the terminal output provides several benefits, including:

  • Improved session management: By displaying the session link in the terminal output, users can easily access and manage their sessions.
  • Enhanced debugging: Displaying the session link in the terminal output can help developers debug issues related to session management.
  • Increased productivity: Displaying the session link in the terminal output can save users time and increase productivity by providing a direct link to the session in the dashboard.

Q: Can I customize the logging configuration to include additional logging levels?

A: Yes, you can customize the logging configuration to include additional logging levels. To do this, you can modify the logger.setLevel() method to include additional logging levels. For example:

logger.setLevel(logging.DEBUG | logging.INFO | logging.WARNING)

This will include the DEBUG, INFO, and WARNING logging levels in the logging configuration.

Q: How can I troubleshoot issues related to session link logging?

A: To troubleshoot issues related to session link logging, you can follow these steps:

  1. Verify the logging configuration: Check the logging configuration to ensure that the session link logging is included at the desired level.
  2. Check the terminal output: Verify that the session link is displayed in the terminal output.
  3. Check the dashboard: Verify that the session link is displayed in the dashboard.
  4. Check the logs: Check the logs to ensure that the session link logging is not being filtered out.

Q: Can I use the AgentOps session link in other applications or services?

A: Yes, you can use the AgentOps session link in other applications or services. The session link is a unique identifier that can be used to access and manage sessions in the dashboard. You can use the session link in other applications or services by including it in the API requests or by using it as a parameter in the application or service.

Q: How can I get support for AgentOps session link issues?

A: To get support for AgentOps session link issues, you can contact the AgentOps support team through the following channels:

Q: What are the system requirements for using the AgentOps session link?

A: The system requirements for using the AgentOps session link are:

  • Operating System: Windows, macOS, or Linux
  • Browser: Google Chrome, Mozilla Firefox, or Microsoft Edge
  • AgentOps version: 1.0 or later
  • Dashboard version: 1.0 or later

Q: Can I use the AgentOps session link with other libraries or frameworks?

A: Yes, you can use the AgentOps session link with other libraries or frameworks. The session link is a unique identifier that can be used to access and manage sessions in the dashboard. You can use the session link with other libraries or frameworks by including it in the API requests or by using it as a parameter in the application or service.