thinklogic

ThinkLogic LLM Structure chat model for n8n AI Agents, Chains and Output Parsers

Package Information

Released: this month
Downloads: 0 weekly / 0 monthly
Latest Version: 0.2.0
Author: Subin K Soman

Documentation

n8n-nodes-thinklogic

A custom chat model node that lets an n8n AI Agent, Basic LLM Chain or any
other AI node run against a ThinkLogic LLM Structure endpoint.

It is built on @n8n/ai-node-sdk, so it plugs into n8n's AI stack the same way
the built-in chat models do — including tool calling, Output Parsers,
Memory and the Agent's streaming mode.

Install

npm run build
npm pack

Then either install the tarball into ~/.n8n/nodes, or publish it and use
Settings → Community nodes → Install.

Credential — "ThinkLogic API"

Field Example Sent as
Backend URL https://….execute-api.eu-west-1.amazonaws.com/f2-api/shared/llm-structure/processing request URL
LLM Structure ID 00000000-0000-0000-0000-000000000000 llmStructureId in the body
Shared Token <your shared token> X-Shared-Token header
API Key <your api key> x-api-key header

All four live on the credential (the Connection tab) — the structure ID
identifies the backend this connection points at, so there is no per-node
override.

Wire format

// request
{ "llmStructureId": "<structure id>", "message": "<the whole prompt>" }

// response
{ "text": "…", "sessionId": "…" }

How the AI Agent features are supported

The endpoint takes one string and returns one string. Everything else is
built on top of that.

Conversation state

The API is stateless — verified directly: replaying the sessionId it
returns gives the model no recall of the previous turn. The node therefore
flattens the entire message array (system prompt, chat history, tool calls and
tool results) into the single message field on every request.

Consequently Session Handling does not give the model memory — attach a
Memory sub-node for that. It only controls whether a sessionId is echoed back
so turns can be correlated in ThinkLogic's own logs.

Tool calling

The endpoint has no native tool API, so the node injects a JSON protocol into
the prompt, listing each bound tool with its JSON-Schema parameters, and parses
the reply back into real tool calls.

The parser is deliberately lenient — live responses arrive as bare JSON, wrapped
in a ```json fence, or with a sentence of prose around them. It also
accepts the OpenAI {function:{name,arguments}} shape and arguments delivered
as a JSON string.

Guard against false positives: a bare {"name": …} object is only treated as a
tool call when the name matches a tool that is actually bound. Without that, a
structured-output answer containing a name field would be misread as a tool
call.

Output parsers

No extra work is needed: n8n implements Structured Output Parser as a tool
called format_final_json_response, so it rides on the tool-calling support
above. Attach an Output Parser to the Agent and it works.

Streaming

The endpoint returns one complete body, so there is nothing to stream. The node
implements stream() by replaying the finished reply as a single chunk — the
Agent's default streaming mode works, it simply is not incremental.

Options

Option Default Notes
Allow Parallel Tool Calls off See the caveat below
Session Handling Echo returned session ID Correlation only, not memory
Fixed Session ID — Shown when Session Handling is Fixed
Response Text Field text Dot-path, e.g. data.output
Additional Body Fields — JSON merged into the request body
Timeout (ms) 120000

Caveat: parallel tool calls while streaming

n8n's stream adapter pins every tool-call delta to index: 0, so two tool calls
in one streamed turn would concatenate into a single corrupt call. With
Allow Parallel Tool Calls off (the default) the node emits one call per turn
and the Agent loops — correct in both streaming and non-streaming mode. Turn the
option on only if you know the Agent will not stream.

Notes for maintainers

This package has zero runtime dependencies. @n8n/ai-node-sdk is a peer
dependency, resolved from the running n8n installation at call time
(nodes/LmChatThinkLogic/sdk.ts) rather than bundled.

That is not an optimisation, it is a correctness fix. Declaring the SDK as a real
dependency pulls in the whole LangChain tree — ~494 MB installed. n8n's
community-package installer runs npm install inline during the UI request, and
at that size it does not finish: the package is extracted but node_modules is
never populated, so the node fails to load with
Cannot find module '@n8n/ai-node-sdk'. Installing now takes seconds and the
package is ~120 KB.

Borrowing n8n's copy also removes a correctness trap. With a bundled copy, tool
schemas are built by n8n's zod but checked against this package's zod —
two copies of the same version are different module objects, so instanceof
returns false, the Zod object is stringified into the prompt instead of a
parameter list, and the model invents field names (observed:
temperature_celsius instead of tempC). schema.ts detects Zod structurally
(typeof schema.safeParse === 'function') so it holds either way.

Everything else interoperates because n8n's guards are duck-typed —
isChatInstance() checks lc_namespace, not instanceof.

n8n-workflow is likewise a types-only peer dependency; nothing requires it
at runtime. n8n strips peerDependencies before installing a community package,
which is what keeps both out of the install — and also avoids isolated-vm's
native build.

Discussion