8000 Fix async tools by n-sviridenko · Pull Request #28 · langchain-ai/langgraph-codeact · GitHub
[go: up one dir, main page]

Skip to content

Fix async tools #28

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

n-sviridenko
Copy link

No description provided.

@n-sviridenko
Copy link
Author

Otherwise func is None and you get this:

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/uvicorn/protocols/http/h11_impl.py", line 403, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/uvicorn/middleware/proxy_headers.py", line 60, in __call__
    return await self.app(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/starlette/applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/starlette/middleware/errors.py", line 187, in __call__
    raise exc
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/starlette/middleware/errors.py", line 165, in __call__
    await self.app(scope, receive, _send)
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/starlette/middleware/base.py", line 176, in __call__
    with recv_stream, send_stream, collapse_excgroups():
  File "/Users/nsviridenko/.pyenv/versions/3.11.11/lib/python3.11/contextlib.py", line 158, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/starlette/_utils.py", line 82, in collapse_excgroups
    raise exc
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/starlette/middleware/base.py", line 178, in __call__
    response = await self.dispatch_func(request, call_next)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/langgraph_api/middleware/private_network.py", line 50, in dispatch
    response = await call_next(request)
               ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/starlette/middleware/base.py", line 156, in call_next
    raise app_exc
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/starlette/middleware/base.py", line 141, in coro
    await self.app(scope, receive_or_disconnect, send_no_error)
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/starlette/middleware/cors.py", line 93, in __call__
    await self.simple_response(scope, receive, send, request_headers=headers)
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/starlette/middleware/cors.py", line 144, in simple_response
    await self.app(scope, receive, send)
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/langgraph_api/middleware/http_logger.py", line 65, in __call__
    raise exc
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/langgraph_api/middleware/http_logger.py", line 59, in __call__
    await self.app(scope, inner_receive, inner_send)
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/langgraph_api/middleware/request_id.py", line 30, in __call__
    await self.app(scope, receive, send)
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/starlette/middleware/exceptions.py", line 62, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 714, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 734, in app
    await route.handle(scope, receive, send)
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 460, in handle
    await self.app(scope, receive, send)
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/langgraph_api/auth/middleware.py", line 49, in __call__
    return await super().__call__(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/starlette/middleware/authentication.py", line 48, in __call__
    await self.app(scope, receive, send)
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 714, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 734, in app
    await route.handle(scope, receive, send)
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/langgraph_api/route.py", line 134, in handle
    return await super().handle(scope, receive, send)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/starlette/routing.py", line 288, in handle
    await self.app(scope, receive, send)
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/langgraph_api/route.py", line 49, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    raise exc
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/starlette/_exception_handler.py", line 42, in wrapped_app
    await app(scope, receive, sender)
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/langgraph_api/route.py", line 42, in app
    response: ASGIApp = await func(request)
                        ^^^^^^^^^^^^^^^^^^^
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/langgraph_runt
B86F
ime_inmem/retry.py", line 27, in wrapper
    return await func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/langgraph_api/api/assistants.py", line 193, in get_assistant_graph
    async with get_graph(
  File "/Users/nsviridenko/.pyenv/versions/3.11.11/lib/python3.11/contextlib.py", line 210, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/langgraph_api/graph.py", line 126, in get_graph
    async with _generate_graph(value) as graph_obj:
  File "/Users/nsviridenko/.pyenv/versions/3.11.11/lib/python3.11/contextlib.py", line 210, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/langgraph_api/graph.py", line 87, in _generate_graph
    async with value as ctx_value:
  File "/Users/nsviridenko/.pyenv/versions/3.11.11/lib/python3.11/contextlib.py", line 210, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nsviridenko/ws/nikita-ai/langgraph-codeact-mcp-example/./agent/agent.py", line 8, in codeact_virtual_assistant_graph
    async with create_virtual_assistant_graph('codeact') as graph:
  File "/Users/nsviridenko/.pyenv/versions/3.11.11/lib/python3.11/contextlib.py", line 210, in __aenter__
    return await anext(self.gen)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nsviridenko/ws/nikita-ai/langgraph-codeact-mcp-example/agent/virtual_assistant/virtual_assistant_graph.py", line 104, in create_virtual_assistant_graph
    workflow = create_codeact(
               ^^^^^^^^^^^^^^^
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/langgraph_codeact/__init__.py", line 81, in create_codeact
    prompt = create_default_prompt(tools)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nsviridenko/Library/Caches/pypoetry/virtualenvs/virtual-assistant-agent-CM0ACcp7-py3.11/lib/python3.11/site-packages/langgraph_codeact/__init__.py", line 42, in create_default_prompt
    def {tool.name}{str(inspect.signature(tool.func))}:
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nsviridenko/.pyenv/versions/3.11.11/lib/python3.11/inspect.py", line 3263, in signature
    return Signature.from_callable(obj, follow_wrapped=follow_wrapped,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nsviridenko/.pyenv/versions/3.11.11/lib/python3.11/inspect.py", line 3011, in from_callable
    return _signature_from_callable(obj, sigcls=cls,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/nsviridenko/.pyenv/versions/3.11.11/lib/python3.11/inspect.py", line 2456, in _signature_from_callable
    raise TypeError('{!r} is not a callable object'.format(obj))
TypeError: None is not a callable object

@n-sviridenko n-sviridenko mentioned this pull request May 17, 2025
@ilan-belfer
Copy link

Guys, please could you approve/check it?:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0