Using subworkflow node as tool in langchain code node

Describe the problem/error/question

Hi, I’m trying to use the langchain code node and can’t make it work with a sub workflow tool. The code is inspired from Quickstart | 🦜️🔗 Langchain
See workflow attached.

What is the error message (if any)?

It seems like the tool is not implemented. When trying to log the result of the custom tool invocation, I received this message:

[
    {
        "lc": 1,
        "type": "not_implemented",
        "id": [
            "langchain",
            "tools",
            "DynamicTool"
        ]
    }
]

I’

Please share your workflow

Share the output returned by the last node

[
  {
    "output": {
      "lc": 1,
      "type": "constructor",
      "id": [
        "langchain_core",
        "messages",
        "AIMessage"
      ],
      "kwargs": {
        "content": "",
        "additional_kwargs": {
          "tool_calls": [
            {
              "id": "call_Bl7S32df8y4p3DeoQYSg9zpF",
              "type": "function",
              "function": {
                "name": "fetch_linkedin_profile",
                "arguments": "{\"input\":\"https://example/result.json\"}"
              }
            }
          ]
        }
      }
    }
  }
]
```
## Information on your n8n setup
- **n8n version:** 1.38.1
- **Database (default: SQLite):** Postgres
- **n8n EXECUTIONS_PROCESS setting (default: own, main):** Default
- **Running n8n via (Docker, npm, n8n cloud, desktop app):** Docker
- **Operating system:** Debian

Hi @Anthony_Brebion, welcome to the community!

There’s indeed a bug which prevent custom n8n tools from executing when using Langchain code node. I just pushed a fix and it’ll go out in the next release(a message will be sent to this channel once it’s out).
But there’s also a small issue with your code, you’re not actually executing the function that LLM suggest. To do that, you’d need to manually extract the toolName, match it to one of the connected tool and execute it with the arguments LLM provided. Here’s a slightly modified workflow with these changes:

Once the fix I’ve mentioned above is out, this should works as expected.

Thank you @oleg. The provided code will certainly guide me on the right path.
I’m waiting for the fix to test deeper.

New version [email protected] got released which includes the GitHub PR 9265.