Skip to content

TypeError: Expected a Runnable, callable or dict. Instead got an unsupported type: <class 'module'> in unified container #11

Description

@wasim786700

Description:
I am attempting to run the OpenManus backend using docker-compose on Windows 10 with Docker Desktop. The unified container starts, but when the UI (or any client) attempts to interact with the /api/chat/stream endpoint, the unified container logs a TypeError and the application fails to process the request.
Steps to Reproduce:

Clone the OpenManus repository.
Ensure Docker Desktop is running.
Navigate to the OpenManus directory in Command Prompt.
Run docker-compose up --build.
Observe the unified container starting successfully.
Attempt to interact with the OpenManus backend (e.g., via the UI or by making a POST request to /api/chat/stream).

Expected Behavior:
The OpenManus backend should process the request without a TypeError and provide a response.
Actual Behavior:
The unified container logs the following TypeError:

ERROR: Exception in ASGI application

  • Exception Group Traceback (most recent call last):
    | File "/usr/local/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
    | result = await app( # type: ignore[func-returns-value]
    | File "/usr/local/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in call
    | return await self.app(scope, receive, send )
    | File "/usr/local/lib/python3.9/site-packages/fastapi/applications.py", line 1054, in call
    | await super().call(scope, receive, send)
    | File "/usr/local/lib/python3.9/site-packages/starlette/applications.py", line 112, in call
    | await self.middleware_stack(scope, receive, send)
    | File "/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 187, in call
    | raise exc
    | File "/usr/local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 165, in call
    | await self.app(scope, receive, _send)
    | File "/usr/local/lib/python3.9/site-packages/starlette/middleware/cors.py", line 93, in call
    | await self.simple_response(scope, receive, send, request_headers=headers)
    | File "/usr/local/lib/python3.9/site-packages/starlette/middleware/cors.py", line 144, in simple_response
    | await self.app(scope, receive, send)
    | File "/usr/local/lib/python3.9/site-packages/starlette/middleware/exceptions.py", line 62, in call
    | await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
    | File "/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    | raise exc
    | File "/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    | await app(scope, receive, sender)
    | File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 714, in call
    | await self.middleware_stack(scope, receive, send)
    | File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 734, in app
    | await route.handle(scope, receive, send)
    | File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 288, in handle
    | await self.app(scope, receive, send)
    | File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 76, in app
    | await wrap_app_handling_exceptions(app, request)(scope, receive, send)
    | File "/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    | raise exc
    | File "/usr/local/lib/python3.9/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    | await app(scope, receive, sender)
    | File "/usr/local/lib/python3.9/site-packages/starlette/routing.py", line 74, in app
    | await response(scope, receive, send)
    | File "/usr/local/lib/python3.9/site-packages/sse_starlette/sse.py", line 251, in call
    | task_group.start_soon(
    | File "/usr/local/lib/python3.9/site-packages/anyio/_backends/_asyncio.py", line 772, in aexit
    | raise BaseExceptionGroup(
    | exceptiongroup.ExceptionGroup: unhandled errors in a TaskGroup (1 sub-exception)
    +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    | File "/usr/local/lib/python3.9/site-packages/sse_starlette/sse.py", line 240, in cancel_on_finish
    | await coro()
    | File "/usr/local/lib/python3.9/site-packages/sse_starlette/sse.py", line 159, in _stream_response
    | async for data in self.body_iterator:
    | File "/app/src/server.py", line 57, in event_generator
    | async for event in run_agent_workflow(
    | File "/app/src/service/workflow_service.py", line 23, in run_agent_workflow
    | workflow = build_graph()
    | File "/app/src/workflow/graph.py", line 18, in build_graph
    | builder.add_node("coordinator", coordinator_node)
    | File "/usr/local/lib/python3.9/site-packages/langgraph/graph/state.py", line 436, in add_node
    | coerce_to_runnable(action, name=cast(str, node), trace=False),
    | File "/usr/local/lib/python3.9/site-packages/langgraph/utils/runnable.py", line 496, in coerce_to_runnable
    | raise TypeError(
    | TypeError: Expected a Runnable, callable or dict.Instead got an unsupported type: <class 'module'>

Environment:

Operating System: Windows 10
Docker Desktop Version: (4.42.1 (196648))
OpenManus Repository: https://github.com/henryalps/OpenManus (latest main branch )

Troubleshooting Steps Already Taken:

Ensured Docker Desktop is running.
Verified start.sh has Unix line endings (manually replaced the file).
Modified src/workflow/graph.py to directly import node functions (e.g., from src.agents.nodes.coordinator_node import coordinator_node).
Modified src/workflow/graph.py to wrap node functions in lambda when adding them to the graph (e.g., builder.add_node("coordinator", lambda state: coordinator_node(state))).
Rebuilt Docker images multiple times using docker-compose up --build after each change.

Additional Context:
This error consistently occurs when the langgraph library attempts to coerce_to_runnable the coordinator_node (and potentially other nodes) within the build_graph function, indicating it's receiving a module object instead of a callable function, despite explicit import and lambda wrapping attempts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions