live · mainnetoc · docs
specs · api · guides
docs / documentation

@orangecheck/agent-langgraph


@orangecheck/agent-langgraph / ocToolNode

Function: ocToolNode()

function ocToolNode<TArgs, TResult>(input: OcToolNodeInput<TArgs, TResult>): OcToolNodeWrapped<TArgs, TResult>;

Defined in: index.ts:204

Wrap a LangGraph tool-node execute path so it produces an OC Agent action envelope per call. The wrapper computes the graph_state_hash inline from the supplied state object, so the verifier replaying the graph against a persisted snapshot gets the same hash deterministically.

Typical shape:

const createInvoice = ocToolNode({ verb: 'invoice.create', execute: async (args) => myInvoiceCreateImpl(args), });

const graph = new StateGraph(MyState) .addNode('createInvoice', async (state) => { const args = pickToolArgs(state); const callId = state.lastToolCallId; const { result, action } = await createInvoice.execute(args, { agent, delegation, callId, graphState: state, }); await audit.append(action); return mergeResultIntoState(state, result); });

Type Parameters

Type Parameter
TArgs extends Record&lt;string, unknown>
TResult

Parameters

ParameterType
inputOcToolNodeInput&lt;TArgs, TResult>

Returns

OcToolNodeWrapped&lt;TArgs, TResult>