Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch Python agent protocol library from trio to asyncio #8

Merged
merged 2 commits into from
Jul 23, 2023

Conversation

jakubno
Copy link
Contributor

@jakubno jakubno commented Jul 23, 2023

I changed the asyncio due to having issues with implementing agent-protocol to smol_developer.

After switching from trio to asyncio everything worked. It's probably caused by mixing asyncio with trio. I tried trio-asyncio package. But it led to another issue.

Traceback

[ERROR] Error in ASGI Framework
Traceback (most recent call last):
  File "/Users/i/Work/e2b/sdk/.venv/lib/python3.11/site-packages/hypercorn/trio/task_group.py", line 26, in _handle
    await app(scope, receive, send, sync_spawn, call_soon)
  File "/Users/i/Work/e2b/sdk/.venv/lib/python3.11/site-packages/hypercorn/app_wrappers.py", line 33, in __call__
    await self.app(scope, receive, send)
  File "/Users/i/Work/e2b/sdk/.venv/lib/python3.11/site-packages/fastapi/applications.py", line 289, in __call__
    await super().__call__(scope, receive, send)
  File "/Users/i/Work/e2b/sdk/.venv/lib/python3.11/site-packages/starlette/applications.py", line 122, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/i/Work/e2b/sdk/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 184, in __call__
    raise exc
  File "/Users/i/Work/e2b/sdk/.venv/lib/python3.11/site-packages/starlette/middleware/errors.py", line 162, in __call__
    await self.app(scope, receive, _send)
  File "/Users/i/Work/e2b/sdk/.venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 79, in __call__
    raise exc
  File "/Users/i/Work/e2b/sdk/.venv/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 68, in __call__
    await self.app(scope, receive, sender)
  File "/Users/i/Work/e2b/sdk/.venv/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 20, in __call__
    raise e
  File "/Users/i/Work/e2b/sdk/.venv/lib/python3.11/site-packages/fastapi/middleware/asyncexitstack.py", line 17, in __call__
    await self.app(scope, receive, send)
  File "/Users/i/Work/e2b/sdk/.venv/lib/python3.11/site-packages/starlette/routing.py", line 718, in __call__
    await route.handle(scope, receive, send)
  File "/Users/i/Work/e2b/sdk/.venv/lib/python3.11/site-packages/starlette/routing.py", line 276, in handle
    await self.app(scope, receive, send)
  File "/Users/i/Work/e2b/sdk/.venv/lib/python3.11/site-packages/starlette/routing.py", line 66, in app
    response = await func(request)
               ^^^^^^^^^^^^^^^^^^^
  File "/Users/i/Work/e2b/sdk/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 273, in app
    raw_response = await run_endpoint_function(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/i/Work/e2b/sdk/.venv/lib/python3.11/site-packages/fastapi/routing.py", line 190, in run_endpoint_function
    return await dependant.call(**values)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/i/Work/e2b/sdk/agent/python/agent_protocol/agent.py", line 105, in execute_agent_task_step
    result = await handler(body.input if body else None)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/i/Work/e2b/sdk/agent/python/examples/smol_developer.py", line 33, in step_handler
    result = await anext(smol_developer_loop, None)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/i/Work/e2b/sdk/agent/python/examples/smol_developer.py", line 22, in smol
    code = await generate_code(prompt, shared_deps, file_path)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/i/Work/e2b/sdk/.venv/lib/python3.11/site-packages/tenacity/_asyncio.py", line 88, in async_wrapped
    return await fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/i/Work/e2b/sdk/.venv/lib/python3.11/site-packages/tenacity/_asyncio.py", line 57, in __call__
    await self.sleep(do)
  File "/opt/homebrew/Cellar/python@3.11/3.11.4_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/tasks.py", line 633, in sleep
    loop = events.get_running_loop()
           ^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: no running event loop

It crashed on this line

@jakubno jakubno added the bug Something isn't working label Jul 23, 2023
Copy link
Contributor

@ValentaTomas ValentaTomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@jakubno jakubno merged commit dd847c4 into main Jul 23, 2023
@jakubno jakubno deleted the switch-from-trio-to-asyncio branch August 1, 2023 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants