AgentOps-AI / agentops

Python SDK for AI agent monitoring, LLM cost tracking, benchmarking, and more. Integrates with most LLMs and agent frameworks like CrewAI, Langchain, and Autogen
https://agentops.ai
MIT License
1.88k stars 179 forks source link

[Bug]: Program hangs if I call agentops.record 100 or more times #439

Open zli11010 opened 1 week ago

zli11010 commented 1 week ago

Contact Details

No response

πŸ“¦ Package Version

0.3.13

🎞️ Framework Version

No response

πŸ”Ž Describe the Bug

Calling agentops.record 100 or more times in a program causes it to hang, and it seems consistent. It appears to be a deadlock at line 303 of agentops/session.py. Example program reproducing the bug:

import agentops
from agentops import ActionEvent

agentops.init(default_tags=["agentops-debug"])

N = 100
for _ in range(N):
    agentops.record(
        ActionEvent(
            action_type="Agent says hello",
            params="hi",
            returns="bye",
        )
    )

agentops.end_session("Success")

Changing N to a larger number similarly causes the program to hang, but if N is smaller (such as 99) then the program no longer hangs. It appears to be related to self.max_queue_size = 100 at line 13 of agentops/config.py.

🀝 Contribution

zli11010 commented 1 week ago

OK I fixed the bug by unindent lines 234-235 in agentops/session.py. Because they try to acquire a lock, putting them under the with self.lock block causes a deadlock.

areibman commented 1 week ago

OK I fixed the bug by unindent lines 234-235 in agentops/session.py. Because they try to acquire a lock, putting them under the with self.lock block causes a deadlock.

Thanks for pointing this out! Will try to get a patch in ASAP.

Out of curiosity-- what kind of agent are you using that records more than 100 actions simultaneously?