Skip to main content
View source

LangChain

View as Markdown

A RocketRide agent node that runs a single tool-calling agent loop using LangChain.

What it does

Receives a question on the questions lane, runs a LangChain agent loop (via langchain.agents.create_agent) against the connected LLM and tool nodes, and emits the final answer on the answers lane.

Uses langchain and langchain-core, installed lazily from requirements.txt when the pipeline starts (not at config time). The LangChain framework never talks to a model provider directly: it drives a thin chat-model adapter that delegates every completion to the LLM node connected on the llm channel, and a tool adapter that routes every tool call through the engine's control-plane invoke to the connected tool nodes.

The node is registered with classType: ["agent", "tool"], so besides answering questions from the lane it also exposes itself as a run_agent tool that parent agents can invoke for hierarchical orchestration.

Failures are graceful: if the agent run raises, the error message is emitted as the answer content with a RocketRide.agent.error.v1 entry on the payload's stack instead of crashing the pipeline.


Configuration

Lanes

LaneDirectionDescription
questionsinIncoming Question objects that trigger an agent run
answersoutFinal answer text produced by the agent

The node also streams progress events over the thinking SSE lane during a run: agent start, LLM call start/completion/error, tool call start/completion/error, and agent think/finish notifications.

Fields

FieldTypeDescription
agent_descriptionstringDefault empty. What does this agent do? Describe its purpose and capabilities, this helps parent agents select and invoke it correctly.
instructionsarrayAdditional instructions to guide the agent.
profilestringDefault "default".

A single default profile exists (agent_langchain.profile), containing both fields.


Connections

ChannelRequiredDescription
llmyes (min: 1)LLM the agent thinks with
toolno (min: 0)Tools available to the agent (via control-plane invoke)

Tool calling: JSON envelope protocol

RocketRide's LLM seam is text-only, but LangChain agents expect a chat model that returns structured tool_calls. The node bridges this with a JSON envelope protocol: on every turn the LLM is instructed to output exactly one JSON object, either

{"type":"tool_call","name":"server.tool","args":{...}}

or

{"type":"final","content":"..."}

The envelope is parsed into an AIMessage with structured tool_calls, so the protocol works with any LLM that can follow JSON instructions; native function-calling support is not required. Up to three attempts are made per turn: after each malformed output the model is re-prompted with a correction notice, and if all attempts fail the raw text is returned as the final answer for that turn.

Each connected tool is wrapped as a LangChain BaseTool whose argument schema is built dynamically from the tool's real JSON input schema (falling back to a generic input field when no usable schema is available), so tool parameters are preserved end-to-end across LangChain versions.


Using as a tool

The node exposes a run_agent tool (invocable as <nodeId>.run_agent) so parent agents can delegate work to it in hierarchical pipelines.

DirectionShape
Input{query: string, context?: object}
Output{content, meta, stack}

query must be a non-empty string. An optional context object is attached to the question as a RocketRide.agent.tool_context.v1 JSON block. When invoked as a tool the answer payload is returned to the caller and not written to the answers lane.

The tool's description automatically includes the configured agent_description, which is how a parent agent decides whether this agent fits a sub-task.


Answer payload

Every run produces a payload with:

  • content: the final answer text (or the error message on failure)
  • meta: framework (langchain), agent_id, run_id, started_at, ended_at, and task_id when available
  • stack: a RocketRide.agent.raw.v1 entry carrying the raw framework output, or a RocketRide.agent.error.v1 entry on failure

When the run is triggered from the questions lane, only content is written to the answers lane; the full payload is what run_agent callers receive.


Schema

FieldTypeDescriptionDefault
agent_descriptionstringAgent description
What does this agent do? Describe its purpose and capabilities, this helps parent agents select and invoke it correctly.
""
agent_langchain.profilestringProfile"default"
instructionsarrayInstructions
Additional instructions to guide the agent.

Dependencies

  • langchain
  • langchain-core