LangGraph Integration
Execute LangGraph StateGraphs securely through Sequrity's Dual-LLM runtime with policy enforcement.
Requirements
- LangGraph must be installed:
pip install langgraph - Requires Dual LLM mode (
features.agent_arch == "dual-llm") strip_response_contentmust beFalsein fine-grained config
langgraph
LangGraph resource — client.control.langgraph.
Classes:
-
LangGraphResource–LangGraph execution —
client.control.langgraph.
LangGraphResource
LangGraph execution — client.control.langgraph.
Methods:
-
run–Compile and execute a LangGraph StateGraph with Sequrity security.
Source code in src/sequrity/control/resources/langgraph/__init__.py
run
run(
graph: StateGraph,
initial_state: dict,
model: str,
*,
initial_state_meta: MetaData | None = None,
max_exec_steps: int = 20,
node_functions: dict[str, Callable] | None = None,
internal_node_mapping: dict[str, str] | None = None,
timeout: float = 300.0,
llm_api_key: str | None | _NotGiven = NOT_GIVEN,
features: FeaturesHeader | None | _NotGiven = NOT_GIVEN,
security_policy: SecurityPolicyHeader | None | _NotGiven = NOT_GIVEN,
fine_grained_config: FineGrainedConfigHeader | None | _NotGiven = NOT_GIVEN,
provider: LlmServiceProvider | LlmServiceProviderStr | None | _NotGiven = NOT_GIVEN,
custom_headers: dict[str, str] | None = None,
) -> dict
Compile and execute a LangGraph StateGraph with Sequrity security.
Parameters:
-
(graphStateGraph) –A LangGraph StateGraph instance defining the agent workflow.
-
(initial_statedict) –Initial state dictionary to start graph execution.
-
(modelstr) –The LLM model identifier for agent nodes.
-
(initial_state_metaMetaData | None, default:None) –Optional metadata for the initial state.
-
(max_exec_stepsint, default:20) –Maximum number of execution steps. Defaults to 20.
-
(node_functionsdict[str, Callable] | None, default:None) –Custom node function implementations.
-
(internal_node_mappingdict[str, str] | None, default:None) –Mapping for internal node names.
-
(timeoutfloat, default:300.0) –Timeout in seconds for each API request. Defaults to 300.0.
-
(llm_api_keystr | None | _NotGiven, default:NOT_GIVEN) –LLM provider API key override.
-
(featuresFeaturesHeader | None | _NotGiven, default:NOT_GIVEN) –Security features override.
-
(security_policySecurityPolicyHeader | None | _NotGiven, default:NOT_GIVEN) –Security policy override.
-
(fine_grained_configFineGrainedConfigHeader | None | _NotGiven, default:NOT_GIVEN) –Fine-grained config override.
-
(providerLlmServiceProvider | LlmServiceProviderStr | None | _NotGiven, default:NOT_GIVEN) –LLM service provider override.
Returns:
-
dict–Dictionary containing the final state and execution results.
Source code in src/sequrity/control/resources/langgraph/__init__.py
LangGraphChatCompletionRequest
pydantic-model
Extended chat completion request for LangGraph execution (OpenAI-compatible providers).
Show JSON schema:
{
"$defs": {
"AssistantMessage": {
"description": "Assistant message.",
"properties": {
"role": {
"const": "assistant",
"description": "The role of the messages author, in this case 'assistant'.",
"title": "Role",
"type": "string"
},
"content": {
"anyOf": [
{
"type": "string"
},
{
"items": {
"anyOf": [
{
"$ref": "#/$defs/ContentPartText"
},
{
"$ref": "#/$defs/ContentPartRefusal"
}
]
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "The contents of the assistant message. Required unless tool_calls or function_call is specified.",
"title": "Content"
},
"name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "An optional name for the participant. Provides the model information to differentiate between participants of the same role.",
"title": "Name"
},
"refusal": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The refusal message by the assistant.",
"title": "Refusal"
},
"audio": {
"anyOf": [
{
"$ref": "#/$defs/AssistantMessageAudio"
},
{
"type": "null"
}
],
"default": null,
"description": "Data about a previous audio response from the model."
},
"tool_calls": {
"anyOf": [
{
"items": {
"$ref": "#/$defs/ToolCall"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "The tool calls generated by the model, such as function calls.",
"title": "Tool Calls"
},
"function_call": {
"anyOf": [
{
"$ref": "#/$defs/FunctionCallResult"
},
{
"type": "null"
}
],
"default": null,
"description": "Deprecated and replaced by tool_calls. The name and arguments of a function that should be called."
}
},
"required": [
"role"
],
"title": "AssistantMessage",
"type": "object"
},
"AssistantMessageAudio": {
"description": "Audio reference in assistant message.",
"properties": {
"id": {
"description": "Unique identifier for a previous audio response from the model.",
"title": "Id",
"type": "string"
}
},
"required": [
"id"
],
"title": "AssistantMessageAudio",
"type": "object"
},
"ContentPartFile": {
"description": "File content part.",
"properties": {
"type": {
"const": "file",
"description": "The type of the content part. Always 'file'.",
"title": "Type",
"type": "string"
},
"file": {
"$ref": "#/$defs/FileData",
"description": "The file data."
}
},
"required": [
"type",
"file"
],
"title": "ContentPartFile",
"type": "object"
},
"ContentPartImage": {
"description": "Image content part.",
"properties": {
"type": {
"const": "image_url",
"description": "The type of the content part.",
"title": "Type",
"type": "string"
},
"image_url": {
"$ref": "#/$defs/ImageUrl",
"description": "The image URL details."
}
},
"required": [
"type",
"image_url"
],
"title": "ContentPartImage",
"type": "object"
},
"ContentPartInputAudio": {
"description": "Input audio content part.",
"properties": {
"type": {
"const": "input_audio",
"description": "The type of the content part.",
"title": "Type",
"type": "string"
},
"input_audio": {
"$ref": "#/$defs/InputAudioData",
"description": "The input audio data."
}
},
"required": [
"type",
"input_audio"
],
"title": "ContentPartInputAudio",
"type": "object"
},
"ContentPartRefusal": {
"description": "Refusal content part.",
"properties": {
"type": {
"const": "refusal",
"description": "The type of the content part.",
"title": "Type",
"type": "string"
},
"refusal": {
"description": "The refusal message.",
"title": "Refusal",
"type": "string"
}
},
"required": [
"type",
"refusal"
],
"title": "ContentPartRefusal",
"type": "object"
},
"ContentPartText": {
"description": "Text content part.",
"properties": {
"type": {
"const": "text",
"description": "The type of the content part.",
"title": "Type",
"type": "string"
},
"text": {
"description": "The text content.",
"title": "Text",
"type": "string"
}
},
"required": [
"type",
"text"
],
"title": "ContentPartText",
"type": "object"
},
"DeveloperMessage": {
"description": "Developer message.",
"properties": {
"role": {
"const": "developer",
"description": "The role of the messages author, in this case 'developer'.",
"title": "Role",
"type": "string"
},
"content": {
"anyOf": [
{
"type": "string"
},
{
"items": {
"$ref": "#/$defs/ContentPartText"
},
"type": "array"
}
],
"description": "The contents of the developer message.",
"title": "Content"
},
"name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "An optional name for the participant. Provides the model information to differentiate between participants of the same role.",
"title": "Name"
}
},
"required": [
"role",
"content"
],
"title": "DeveloperMessage",
"type": "object"
},
"FileData": {
"description": "File data.",
"properties": {
"file_data": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The base64 encoded file data, used when passing the file to the model as a string.",
"title": "File Data"
},
"file_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The ID of an uploaded file to use as input.",
"title": "File Id"
},
"filename": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The name of the file, used when passing the file to the model as a string.",
"title": "Filename"
}
},
"title": "FileData",
"type": "object"
},
"FunctionCallResult": {
"description": "Function call result in assistant message.",
"properties": {
"arguments": {
"description": "The arguments to call the function with, as generated by the model in JSON format.",
"title": "Arguments",
"type": "string"
},
"name": {
"description": "The name of the function to call.",
"title": "Name",
"type": "string"
}
},
"required": [
"arguments",
"name"
],
"title": "FunctionCallResult",
"type": "object"
},
"FunctionDefinition": {
"description": "Function definition for tools.",
"properties": {
"name": {
"description": "The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.",
"title": "Name",
"type": "string"
},
"description": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "A description of what the function does, used by the model to choose when and how to call the function.",
"title": "Description"
},
"parameters": {
"anyOf": [
{
"additionalProperties": true,
"type": "object"
},
{
"type": "null"
}
],
"default": null,
"description": "The parameters the functions accepts, described as a JSON Schema object.",
"title": "Parameters"
},
"strict": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": null,
"description": "Whether to enable strict schema adherence when generating the function call.",
"title": "Strict"
}
},
"required": [
"name"
],
"title": "FunctionDefinition",
"type": "object"
},
"FunctionMessage": {
"description": "Function message (deprecated).",
"properties": {
"role": {
"const": "function",
"description": "The role of the messages author, in this case 'function'.",
"title": "Role",
"type": "string"
},
"content": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"description": "The contents of the function message.",
"title": "Content"
},
"name": {
"description": "The name of the function.",
"title": "Name",
"type": "string"
}
},
"required": [
"role",
"content",
"name"
],
"title": "FunctionMessage",
"type": "object"
},
"FunctionTool": {
"description": "Function tool.",
"properties": {
"type": {
"const": "function",
"description": "The type of the tool. Currently, only 'function' is supported.",
"title": "Type",
"type": "string"
},
"function": {
"$ref": "#/$defs/FunctionDefinition",
"description": "The function definition."
}
},
"required": [
"type",
"function"
],
"title": "FunctionTool",
"type": "object"
},
"ImageUrl": {
"description": "Image URL details.",
"properties": {
"url": {
"description": "Either a URL of the image or the base64 encoded image data.",
"title": "Url",
"type": "string"
},
"detail": {
"anyOf": [
{
"enum": [
"auto",
"low",
"high"
],
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Specifies the detail level of the image. 'low', 'high', or 'auto' for automatic selection.",
"title": "Detail"
}
},
"required": [
"url"
],
"title": "ImageUrl",
"type": "object"
},
"InputAudioData": {
"description": "Input audio data.",
"properties": {
"data": {
"description": "Base64 encoded audio data.",
"title": "Data",
"type": "string"
},
"format": {
"description": "The format of the audio data.",
"enum": [
"wav",
"mp3"
],
"title": "Format",
"type": "string"
}
},
"required": [
"data",
"format"
],
"title": "InputAudioData",
"type": "object"
},
"JsonSchema": {
"additionalProperties": false,
"description": "JSON schema definition.",
"properties": {
"name": {
"description": "The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.",
"title": "Name",
"type": "string"
},
"description": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "A description of what the response format is for, used by the model to determine how to respond in the format.",
"title": "Description"
},
"schema": {
"anyOf": [
{
"additionalProperties": true,
"type": "object"
},
{
"type": "null"
}
],
"default": null,
"description": "The schema for the response format, described as a JSON Schema object.",
"title": "Schema"
},
"strict": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": null,
"description": "Whether to enable strict schema adherence when generating the output.",
"title": "Strict"
}
},
"required": [
"name"
],
"title": "JsonSchema",
"type": "object"
},
"MetaData": {
"additionalProperties": false,
"description": "Metadata associated with a value for Sequrity Control's policy enforcement system.\n\nEvery value flowing through the dual-LLM interpreter carries metadata that\nrecords *who* produced it, *who* may consume it, and arbitrary *tags* for\npolicy matching.",
"properties": {
"producers": {
"items": {
"type": "string"
},
"title": "Producers",
"type": "array",
"uniqueItems": true
},
"consumers": {
"items": {
"type": "string"
},
"title": "Consumers",
"type": "array",
"uniqueItems": true
},
"tags": {
"items": {
"type": "string"
},
"title": "Tags",
"type": "array",
"uniqueItems": true
}
},
"title": "MetaData",
"type": "object"
},
"ResponseFormatJsonObject": {
"description": "JSON object response format.",
"properties": {
"type": {
"const": "json_object",
"description": "The type of response format being defined. Always 'json_object'.",
"title": "Type",
"type": "string"
}
},
"required": [
"type"
],
"title": "ResponseFormatJsonObject",
"type": "object"
},
"ResponseFormatJsonSchema": {
"description": "JSON schema response format.",
"properties": {
"type": {
"const": "json_schema",
"description": "The type of response format being defined. Always 'json_schema'.",
"title": "Type",
"type": "string"
},
"json_schema": {
"$ref": "#/$defs/JsonSchema",
"description": "Structured Outputs configuration options, including a JSON Schema."
}
},
"required": [
"type",
"json_schema"
],
"title": "ResponseFormatJsonSchema",
"type": "object"
},
"ResponseFormatText": {
"description": "Text response format.",
"properties": {
"type": {
"const": "text",
"description": "The type of response format being defined. Always 'text'.",
"title": "Type",
"type": "string"
}
},
"required": [
"type"
],
"title": "ResponseFormatText",
"type": "object"
},
"SystemMessage": {
"description": "System message.",
"properties": {
"role": {
"const": "system",
"description": "The role of the messages author, in this case 'system'.",
"title": "Role",
"type": "string"
},
"content": {
"anyOf": [
{
"type": "string"
},
{
"items": {
"$ref": "#/$defs/ContentPartText"
},
"type": "array"
}
],
"description": "The contents of the system message.",
"title": "Content"
},
"name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "An optional name for the participant. Provides the model information to differentiate between participants of the same role.",
"title": "Name"
}
},
"required": [
"role",
"content"
],
"title": "SystemMessage",
"type": "object"
},
"ToolCall": {
"description": "Tool call in assistant message.",
"properties": {
"id": {
"description": "The ID of the tool call.",
"title": "Id",
"type": "string"
},
"type": {
"const": "function",
"description": "The type of the tool. Currently, only 'function' is supported.",
"title": "Type",
"type": "string"
},
"function": {
"$ref": "#/$defs/ToolCallFunction",
"description": "The function that the model called."
}
},
"required": [
"id",
"type",
"function"
],
"title": "ToolCall",
"type": "object"
},
"ToolCallFunction": {
"description": "Function details in tool call.",
"properties": {
"arguments": {
"description": "The arguments to call the function with, as generated by the model in JSON format.",
"title": "Arguments",
"type": "string"
},
"name": {
"description": "The name of the function to call.",
"title": "Name",
"type": "string"
}
},
"required": [
"arguments",
"name"
],
"title": "ToolCallFunction",
"type": "object"
},
"ToolMessage": {
"description": "Tool message.",
"properties": {
"role": {
"const": "tool",
"description": "The role of the messages author, in this case 'tool'.",
"title": "Role",
"type": "string"
},
"content": {
"anyOf": [
{
"type": "string"
},
{
"items": {
"$ref": "#/$defs/ContentPartText"
},
"type": "array"
}
],
"description": "The contents of the tool message.",
"title": "Content"
},
"tool_call_id": {
"description": "Tool call that this message is responding to.",
"title": "Tool Call Id",
"type": "string"
}
},
"required": [
"role",
"content",
"tool_call_id"
],
"title": "ToolMessage",
"type": "object"
},
"UserMessage": {
"description": "User message.",
"properties": {
"role": {
"const": "user",
"description": "The role of the messages author, in this case 'user'.",
"title": "Role",
"type": "string"
},
"content": {
"anyOf": [
{
"type": "string"
},
{
"items": {
"anyOf": [
{
"$ref": "#/$defs/ContentPartText"
},
{
"$ref": "#/$defs/ContentPartImage"
},
{
"$ref": "#/$defs/ContentPartInputAudio"
},
{
"$ref": "#/$defs/ContentPartFile"
}
]
},
"type": "array"
}
],
"description": "The contents of the user message.",
"title": "Content"
},
"name": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "An optional name for the participant. Provides the model information to differentiate between participants of the same role.",
"title": "Name"
}
},
"required": [
"role",
"content"
],
"title": "UserMessage",
"type": "object"
},
"ValueWithMeta": {
"description": "Python value wrapper with metadata for Sequrity Control's policy enforcement system.",
"properties": {
"value": {
"title": "Value"
},
"meta": {
"$ref": "#/$defs/MetaData"
}
},
"required": [
"value"
],
"title": "ValueWithMeta",
"type": "object"
}
},
"description": "Extended chat completion request for LangGraph execution (OpenAI-compatible providers).",
"properties": {
"user_provided_program": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The user-provided Python program to execute.",
"title": "User Provided Program"
},
"context_vars": {
"anyOf": [
{
"additionalProperties": {
"$ref": "#/$defs/ValueWithMeta"
},
"type": "object"
},
{
"type": "null"
}
],
"default": null,
"description": "Predefined variables with meta for the interpreter.",
"title": "Context Vars"
},
"messages": {
"description": "A list of messages comprising the conversation so far.",
"items": {
"discriminator": {
"mapping": {
"assistant": "#/$defs/AssistantMessage",
"developer": "#/$defs/DeveloperMessage",
"function": "#/$defs/FunctionMessage",
"system": "#/$defs/SystemMessage",
"tool": "#/$defs/ToolMessage",
"user": "#/$defs/UserMessage"
},
"propertyName": "role"
},
"oneOf": [
{
"$ref": "#/$defs/DeveloperMessage"
},
{
"$ref": "#/$defs/SystemMessage"
},
{
"$ref": "#/$defs/UserMessage"
},
{
"$ref": "#/$defs/AssistantMessage"
},
{
"$ref": "#/$defs/ToolMessage"
},
{
"$ref": "#/$defs/FunctionMessage"
}
]
},
"title": "Messages",
"type": "array"
},
"model": {
"description": "Model ID used to generate the response, like 'gpt-4o' or 'o3'.",
"title": "Model",
"type": "string"
},
"reasoning_effort": {
"anyOf": [
{
"enum": [
"none",
"minimal",
"low",
"medium",
"high",
"xhigh"
],
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Constrains effort on reasoning for reasoning models. Supported values are 'none', 'minimal', 'low', 'medium', 'high', and 'xhigh'.",
"title": "Reasoning Effort"
},
"response_format": {
"anyOf": [
{
"$ref": "#/$defs/ResponseFormatText"
},
{
"$ref": "#/$defs/ResponseFormatJsonObject"
},
{
"$ref": "#/$defs/ResponseFormatJsonSchema"
},
{
"type": "null"
}
],
"default": null,
"description": "An object specifying the format that the model must output. Setting to json_schema enables Structured Outputs.",
"title": "Response Format"
},
"seed": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"default": null,
"description": "If specified, the system will make a best effort to sample deterministically for reproducible results.",
"title": "Seed"
},
"stream": {
"anyOf": [
{
"type": "boolean"
},
{
"type": "null"
}
],
"default": null,
"description": "If set to true, partial message deltas will be sent as server-sent events.",
"title": "Stream"
},
"temperature": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"description": "What sampling temperature to use, between 0 and 2. Higher values make output more random.",
"title": "Temperature"
},
"tools": {
"anyOf": [
{
"items": {
"$ref": "#/$defs/FunctionTool"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "A list of tools the model may call. Currently, only functions are supported as a tool.",
"title": "Tools"
},
"top_p": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"default": null,
"description": "An alternative to sampling with temperature, called nucleus sampling. Use 0.1 for top 10% probability mass.",
"title": "Top P"
}
},
"required": [
"messages",
"model"
],
"title": "LangGraphChatCompletionRequest",
"type": "object"
}
Config:
extra:ignore
Fields:
-
user_provided_program(str | None) -
context_vars(dict[str, ValueWithMeta] | None) -
messages(list[Message]) -
model(str) -
reasoning_effort(ReasoningEffort | None) -
response_format(ResponseFormat | None) -
seed(int | None) -
stream(bool | None) -
temperature(float | None) -
tools(list[Tool] | None) -
top_p(float | None)
user_provided_program
pydantic-field
user_provided_program: str | None = None
The user-provided Python program to execute.
context_vars
pydantic-field
context_vars: dict[str, ValueWithMeta] | None = None
Predefined variables with meta for the interpreter.
messages
pydantic-field
A list of messages comprising the conversation so far.
reasoning_effort
pydantic-field
Constrains effort on reasoning for reasoning models. Supported values are 'none', 'minimal', 'low', 'medium', 'high', and 'xhigh'.
response_format
pydantic-field
response_format: ResponseFormat | None = None
An object specifying the format that the model must output. Setting to json_schema enables Structured Outputs.
seed
pydantic-field
seed: int | None = None
If specified, the system will make a best effort to sample deterministically for reproducible results.
stream
pydantic-field
stream: bool | None = None
If set to true, partial message deltas will be sent as server-sent events.
temperature
pydantic-field
temperature: float | None = None
What sampling temperature to use, between 0 and 2. Higher values make output more random.
tools
pydantic-field
A list of tools the model may call. Currently, only functions are supported as a tool.
top_p
pydantic-field
top_p: float | None = None
An alternative to sampling with temperature, called nucleus sampling. Use 0.1 for top 10% probability mass.
LangGraphChatCompletionResponse
pydantic-model
Chat completion response from LangGraph execution.
Show JSON schema:
{
"$defs": {
"Annotation": {
"description": "Annotation in message.",
"properties": {
"type": {
"const": "url_citation",
"description": "The type of the URL citation. Always 'url_citation'.",
"title": "Type",
"type": "string"
},
"url_citation": {
"$ref": "#/$defs/AnnotationUrlCitation",
"description": "A URL citation when using web search."
}
},
"required": [
"type",
"url_citation"
],
"title": "Annotation",
"type": "object"
},
"AnnotationUrlCitation": {
"description": "URL citation annotation.",
"properties": {
"end_index": {
"description": "The index of the last character of the URL citation in the message.",
"title": "End Index",
"type": "integer"
},
"start_index": {
"description": "The index of the first character of the URL citation in the message.",
"title": "Start Index",
"type": "integer"
},
"title": {
"description": "The title of the web resource.",
"title": "Title",
"type": "string"
},
"url": {
"description": "The URL of the web resource.",
"title": "Url",
"type": "string"
}
},
"required": [
"end_index",
"start_index",
"title",
"url"
],
"title": "AnnotationUrlCitation",
"type": "object"
},
"AudioResponse": {
"description": "Audio response from the model.",
"properties": {
"id": {
"description": "Unique identifier for this audio response.",
"title": "Id",
"type": "string"
},
"data": {
"description": "Base64 encoded audio bytes generated by the model, in the format specified in the request.",
"title": "Data",
"type": "string"
},
"expires_at": {
"description": "The Unix timestamp (in seconds) for when this audio response will no longer be accessible on the server.",
"title": "Expires At",
"type": "integer"
},
"transcript": {
"description": "Transcript of the audio generated by the model.",
"title": "Transcript",
"type": "string"
}
},
"required": [
"id",
"data",
"expires_at",
"transcript"
],
"title": "AudioResponse",
"type": "object"
},
"Choice": {
"description": "A chat completion choice.",
"properties": {
"finish_reason": {
"anyOf": [
{
"enum": [
"stop",
"length",
"tool_calls",
"content_filter",
"function_call",
"error"
],
"type": "string"
},
{
"type": "string"
}
],
"description": "The reason the model stopped generating tokens. 'stop' for natural stop, 'length' for max tokens, 'tool_calls' for tool call, 'content_filter' for content filter, 'function_call' (deprecated) for function call, 'error' if an error occurred.",
"title": "Finish Reason"
},
"index": {
"description": "The index of the choice in the list of choices.",
"title": "Index",
"type": "integer"
},
"message": {
"$ref": "#/$defs/ResponseMessage"
},
"logprobs": {
"anyOf": [
{
"$ref": "#/$defs/ChoiceLogprobs"
},
{
"type": "null"
}
],
"default": null,
"description": "Log probability information for the choice."
}
},
"required": [
"finish_reason",
"index",
"message"
],
"title": "Choice",
"type": "object"
},
"ChoiceLogprobs": {
"description": "Log probability information for a choice.",
"properties": {
"content": {
"anyOf": [
{
"items": {
"$ref": "#/$defs/TokenLogprob"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "A list of message content tokens with log probability information.",
"title": "Content"
},
"refusal": {
"anyOf": [
{
"items": {
"$ref": "#/$defs/TokenLogprob"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "A list of message refusal tokens with log probability information.",
"title": "Refusal"
}
},
"title": "ChoiceLogprobs",
"type": "object"
},
"CompletionUsage": {
"description": "Usage statistics for the completion request.",
"properties": {
"completion_tokens": {
"description": "Number of tokens in the generated completion.",
"title": "Completion Tokens",
"type": "integer"
},
"prompt_tokens": {
"description": "Number of tokens in the prompt.",
"title": "Prompt Tokens",
"type": "integer"
},
"total_tokens": {
"description": "Total number of tokens used in the request (prompt + completion).",
"title": "Total Tokens",
"type": "integer"
}
},
"required": [
"completion_tokens",
"prompt_tokens",
"total_tokens"
],
"title": "CompletionUsage",
"type": "object"
},
"ResponseMessage": {
"description": "A chat completion message generated by the model.",
"properties": {
"role": {
"const": "assistant",
"description": "The role of the author of this message.",
"title": "Role",
"type": "string"
},
"content": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The contents of the message.",
"title": "Content"
},
"refusal": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The refusal message generated by the model.",
"title": "Refusal"
},
"annotations": {
"anyOf": [
{
"items": {
"$ref": "#/$defs/Annotation"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "Annotations for the message, when applicable, as when using the web search tool.",
"title": "Annotations"
},
"audio": {
"anyOf": [
{
"$ref": "#/$defs/AudioResponse"
},
{
"type": "null"
}
],
"default": null,
"description": "If the audio output modality is requested, this object contains data about the audio response from the model."
},
"tool_calls": {
"anyOf": [
{
"items": {
"$ref": "#/$defs/ResponseToolCall"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "The tool calls generated by the model, such as function calls.",
"title": "Tool Calls"
}
},
"required": [
"role"
],
"title": "ResponseMessage",
"type": "object"
},
"ResponseToolCall": {
"description": "Tool call in assistant message.",
"properties": {
"id": {
"description": "The ID of the tool call.",
"title": "Id",
"type": "string"
},
"type": {
"const": "function",
"description": "The type of the tool. Currently, only 'function' is supported.",
"title": "Type",
"type": "string"
},
"function": {
"$ref": "#/$defs/ToolCallFunction",
"description": "The function that the model called."
}
},
"required": [
"id",
"type",
"function"
],
"title": "ResponseToolCall",
"type": "object"
},
"TokenLogprob": {
"description": "Token log probability information.",
"properties": {
"token": {
"description": "The token.",
"title": "Token",
"type": "string"
},
"bytes": {
"anyOf": [
{
"items": {
"type": "integer"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "A list of integers representing the UTF-8 bytes representation of the token.",
"title": "Bytes"
},
"logprob": {
"description": "The log probability of this token, if it is within the top 20 most likely tokens.",
"title": "Logprob",
"type": "number"
},
"top_logprobs": {
"description": "List of the most likely tokens and their log probability, at this token position.",
"items": {
"$ref": "#/$defs/TopLogprob"
},
"title": "Top Logprobs",
"type": "array"
}
},
"required": [
"token",
"logprob",
"top_logprobs"
],
"title": "TokenLogprob",
"type": "object"
},
"ToolCallFunction": {
"description": "Function details in tool call.",
"properties": {
"arguments": {
"description": "The arguments to call the function with, as generated by the model in JSON format.",
"title": "Arguments",
"type": "string"
},
"name": {
"description": "The name of the function to call.",
"title": "Name",
"type": "string"
}
},
"required": [
"arguments",
"name"
],
"title": "ToolCallFunction",
"type": "object"
},
"TopLogprob": {
"description": "Top logprob entry.",
"properties": {
"token": {
"description": "The token.",
"title": "Token",
"type": "string"
},
"bytes": {
"anyOf": [
{
"items": {
"type": "integer"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"description": "A list of integers representing the UTF-8 bytes representation of the token.",
"title": "Bytes"
},
"logprob": {
"description": "The log probability of this token, if it is within the top 20 most likely tokens.",
"title": "Logprob",
"type": "number"
}
},
"required": [
"token",
"logprob"
],
"title": "TopLogprob",
"type": "object"
}
},
"description": "Chat completion response from LangGraph execution.",
"properties": {
"id": {
"description": "A unique identifier for the chat completion.",
"title": "Id",
"type": "string"
},
"choices": {
"description": "A list of chat completion choices. Can be more than one if 'n' is greater than 1.",
"items": {
"$ref": "#/$defs/Choice"
},
"title": "Choices",
"type": "array"
},
"created": {
"description": "The Unix timestamp (in seconds) of when the chat completion was created.",
"title": "Created",
"type": "integer"
},
"model": {
"description": "The model used for the chat completion.",
"title": "Model",
"type": "string"
},
"object": {
"const": "chat.completion",
"description": "The object type, which is always 'chat.completion'.",
"title": "Object",
"type": "string"
},
"usage": {
"anyOf": [
{
"$ref": "#/$defs/CompletionUsage"
},
{
"type": "null"
}
],
"default": null,
"description": "Usage statistics for the completion request."
},
"session_id": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "The session ID associated with this chat completion, if applicable.",
"title": "Session Id"
}
},
"required": [
"id",
"choices",
"created",
"model",
"object"
],
"title": "LangGraphChatCompletionResponse",
"type": "object"
}
Config:
extra:ignore
Fields:
-
id(str) -
choices(list[Choice]) -
created(int) -
model(str) -
object(Literal['chat.completion']) -
usage(CompletionUsage | None) -
session_id(str | None)
choices
pydantic-field
A list of chat completion choices. Can be more than one if 'n' is greater than 1.
created
pydantic-field
created: int
The Unix timestamp (in seconds) of when the chat completion was created.
object
pydantic-field
object: Literal['chat.completion']
The object type, which is always 'chat.completion'.
usage
pydantic-field
usage: CompletionUsage | None = None
Usage statistics for the completion request.
session_id
pydantic-field
session_id: str | None = None
The session ID associated with this chat completion, if applicable.
LangGraphExecutor
LangGraphExecutor(
graph: StateGraph,
node_functions: dict[str, Callable] | None = None,
internal_node_mapping: dict[str, str] | None = None,
)
Executor for running LangGraph StateGraphs through Sequrity.
This class handles
- Converting LangGraph to executable Python code
- Mapping nodes to tools (external) or internal functions
- Executing code via secure orchestrator
- Handling tool calls for external nodes
Parameters:
-
(graphStateGraph) –LangGraph StateGraph to execute.
-
(node_functionsdict[str, Callable] | None, default:None) –Dict mapping node names to their functions.
-
(internal_node_mappingdict[str, str] | None, default:None) –Map of node names to internal tool names (e.g., {"agent": "parse_with_ai"}).
Raises:
-
RuntimeError–If LangGraph is not installed.
Methods:
-
build_tool_definitions–Build tool definitions for external nodes.
-
execute_tool_call–Execute a tool call (external node).
build_tool_definitions
build_tool_definitions(rest_api_type: RestApiType = CHAT_COMPLETIONS) -> list[dict]
Build tool definitions for external nodes.
Parameters:
-
(rest_api_typeRestApiType, default:CHAT_COMPLETIONS) –The REST API type determining the tool definition format.
CHAT_COMPLETIONSproduces OpenAI-style definitions.MESSAGESproduces Anthropic-style definitions.
Returns:
execute_tool_call
execute_tool_call(
tool_call: dict, rest_api_type: RestApiType = CHAT_COMPLETIONS
) -> dict
Execute a tool call (external node).
Parameters:
-
(tool_calldict) –Tool call dict. Format depends on
rest_api_type: -CHAT_COMPLETIONS:{"function": {"name": ..., "arguments": ...}}-MESSAGES:{"name": ..., "input": {...}} -
(rest_api_typeRestApiType, default:CHAT_COMPLETIONS) –The REST API type determining the tool call format.
Returns:
-
dict–The result dict from executing the node function.
Raises:
-
RuntimeError–If no function is found for the specified tool name.