-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
The latest code agent version no longer works in a thread due to the use of signals. We are trying to use smolagents in a fastapi service, so having it run in a non-main thread is a pretty hard requirement (otherwise it blocks streaming for extended periods of time).
Making timeout decorator optional in local_python_executor
fixes the issue. I'm happy to contribute a PR if you want.
Code to reproduce the error
import threading
from smolagents import CodeAgent, WebSearchTool, InferenceClientModel
model = InferenceClientModel()
agent = CodeAgent(tools=[WebSearchTool()], model=model, stream_outputs=True)
def run_agent():
agent.run(
"How many seconds would it take for a leopard at full speed to run through Pont des Arts?"
)
thread = threading.Thread(target=run_agent)
thread.start()
thread.join()
Error logs (if any)
Interpreter fails with:
signal only works in main thread of the main interpreter
Packages version:
smolagents==1.16.0
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working