Skip to content

[BUG] Error: Event loop is closed #431

Closed
@cagataycali

Description

@cagataycali

Checks

  • I have updated to the lastest minor and patch version of Strands
  • I have checked the documentation and this is not expected behavior
  • I have searched ./issues and there are no duplicates of my issue

Strands Version

0.3.0

Python Version

3.13.5

Operating System

macOS

Installation Method

pip

Steps to Reproduce

  1. Create and activate a fresh virtual environment:
    python3 -m venv .venv
    source .venv/bin/activate
    
  2. Install the core packages:
    pip3 install strands-agents strands-agents-tools
    
  3. Save the following as agent.py:
    import sys
    import logging
    from strands import Agent
    from strands.models.ollama import OllamaModel
    from strands_tools import current_time
    
    logger = logging.getLogger(__name__)
    
    model = OllamaModel(host="http://localhost:11434", model_id="devstral:24b")
    agent = Agent(model=model, tools=[current_time], load_tools_from_directory=True)
    
    def main():
        if len(sys.argv) > 1:
            agent(" ".join(sys.argv[1:]))
        else:
            print("Type 'exit' or 'quit' to end the session.\n")
            while True:
                query = input("\n> ").strip()
                if query.lower() in {"exit", "quit"}:
                    break
                if not query:
                    continue
                agent(query)
                print("\n")
    
    if __name__ == "__main__":
        main()
  4. Run the agent in interactive mode:
    python3 agent.py
    
  5. At the prompt:
    > what can you do
    
    the agent prints its help text successfully. Then enter:
    > ls -la
    
    instead of returning directory contents, the program outputs:
    Error: Event loop is closed
    
  6. Further inputs randomly repeats the same error.

Expected Behavior

N/A

Actual Behavior

Error: Event loop is closed

Additional Context

Runtime outputs:

# Type 'exit' or 'quit' to end the session.


# > what can you do
# I'm Devstral, a helpful assistant designed by Mistral AI. I can execute commands, modify code, solve technical problems, and help with various tasks on your computer. I follow guidelines to be thorough, efficient, and focused on quality rather than speed.

# Here are some of the things I can do:
# 1. Execute shell commands
# 2. Help with software development tasks (editing files, fixing bugs, etc.)
# 3. Explore file systems and locate specific files
# 4. Assist with version control using git
# 5. Perform efficient searches across codebases

# I'm designed to make minimal changes when implementing solutions, prioritize understanding the codebase before making changes, and avoid committing files that shouldn't go into version control.

# What do you need help with today?


# > okey run ls -la
# Error: Event loop is closed

# > hey
# I'm here to help with your requests! However, I currently don't have the capability to directly execute commands like `ls -la` on your system. If you need assistance with something else or have any other questions, feel free to ask!


# > what can you do
# Error: Event loop is closed

# > 

Possible Solution

No response

Related Issues

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions