From 5eb793d7d869b7f984956c42236b7d6519af2bd6 Mon Sep 17 00:00:00 2001 From: Lance Martin <122662504+rlancemartin@users.noreply.github.com> Date: Thu, 20 Feb 2025 15:04:11 -0800 Subject: [PATCH 1/4] Update packages w/ Open Deep Research (#3539) Here: https://github.com/langchain-ai/open_deep_research --------- Co-authored-by: Vadym Barda --- docs/_scripts/third_party_page/packages.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/_scripts/third_party_page/packages.yml b/docs/_scripts/third_party_page/packages.yml index 518b5f5d9..969dab2b2 100644 --- a/docs/_scripts/third_party_page/packages.yml +++ b/docs/_scripts/third_party_page/packages.yml @@ -14,4 +14,7 @@ packages: description: "Build agents that learn and adapt from interactions over time." - name: "langchain-mcp-adapters" repo: "langchain-ai/langchain-mcp-adapters" - description: "Make Anthropic Model Context Protocol (MCP) tools compatible with LangGraph agents." \ No newline at end of file + description: "Make Anthropic Model Context Protocol (MCP) tools compatible with LangGraph agents." + - name: "open_deep_research" + repo: "langchain-ai/open_deep_research" + description: "Open source assistant for iterative web research and report writing." \ No newline at end of file From 39b2bb9c8fca58aafb3f5ee0db2dfbaadbfcfab3 Mon Sep 17 00:00:00 2001 From: Vadym Barda Date: Thu, 20 Feb 2025 18:16:40 -0500 Subject: [PATCH 2/4] update opendeepresearch name (#3541) --- docs/_scripts/third_party_page/packages.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/_scripts/third_party_page/packages.yml b/docs/_scripts/third_party_page/packages.yml index 969dab2b2..82ab8a147 100644 --- a/docs/_scripts/third_party_page/packages.yml +++ b/docs/_scripts/third_party_page/packages.yml @@ -15,6 +15,6 @@ packages: - name: "langchain-mcp-adapters" repo: "langchain-ai/langchain-mcp-adapters" description: "Make Anthropic Model Context Protocol (MCP) tools compatible with LangGraph agents." - - name: "open_deep_research" + - name: "open-deep-research" repo: "langchain-ai/open_deep_research" - description: "Open source assistant for iterative web research and report writing." \ No newline at end of file + description: "Open source assistant for iterative web research and report writing." From 078b33544869b0ba5f9356f35b33c7c929fc5510 Mon Sep 17 00:00:00 2001 From: Nino Risteski <95188570+NinoRisteski@users.noreply.github.com> Date: Sat, 22 Feb 2025 12:10:09 +0100 Subject: [PATCH 3/4] chore(checkpoint): fix typos in README (#3553) --- libs/checkpoint/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/checkpoint/README.md b/libs/checkpoint/README.md index 19c7d3807..3dafce79b 100644 --- a/libs/checkpoint/README.md +++ b/libs/checkpoint/README.md @@ -1,6 +1,6 @@ # LangGraph Checkpoint -This library defines the base interface for LangGraph checkpointers. Checkpointers provide persistence layer for LangGraph. They allow you to interact with and manage the graph's state. When you use a graph with a checkpointer, the checkpointer saves a _checkpoint_ of the graph state at every superstep, enabling several powerful capabilities like human-in-the-loop, "memory" between interactions and more. +This library defines the base interface for LangGraph checkpointers. Checkpointers provide a persistence layer for LangGraph. They allow you to interact with and manage the graph's state. When you use a graph with a checkpointer, the checkpointer saves a _checkpoint_ of the graph state at every superstep, enabling several powerful capabilities like human-in-the-loop, "memory" between interactions and more. ## Key concepts @@ -12,8 +12,8 @@ Checkpoint is a snapshot of the graph state at a given point in time. Checkpoint Threads enable the checkpointing of multiple different runs, making them essential for multi-tenant chat applications and other scenarios where maintaining separate states is necessary. A thread is a unique ID assigned to a series of checkpoints saved by a checkpointer. When using a checkpointer, you must specify a `thread_id` and optionally `checkpoint_id` when running the graph. -- `thread_id` is simply the ID of a thread. This is always required -- `checkpoint_id` can optionally be passed. This identifier refers to a specific checkpoint within a thread. This can be used to kick of a run of a graph from some point halfway through a thread. +- `thread_id` is simply the ID of a thread. This is always required. +- `checkpoint_id` can optionally be passed. This identifier refers to a specific checkpoint within a thread. This can be used to kick off a run of a graph from some point halfway through a thread. You must pass these when invoking the graph as part of the configurable part of the config, e.g. From 57e80819211461e03fc1c615f282882ea828f7bb Mon Sep 17 00:00:00 2001 From: Sudar Selva Ganesh M <117903686+ssganesh035@users.noreply.github.com> Date: Sat, 22 Feb 2025 16:47:21 +0530 Subject: [PATCH 4/4] chore(docs): make webhooks platform doc more readable (#3551) 1. Provided additional context on webhook usage and setup. 2. Structured supported endpoints into a table for better readability. --- docs/docs/cloud/how-tos/webhooks.md | 233 ++++++++++++++-------------- 1 file changed, 119 insertions(+), 114 deletions(-) diff --git a/docs/docs/cloud/how-tos/webhooks.md b/docs/docs/cloud/how-tos/webhooks.md index 8e3396923..7bae74001 100644 --- a/docs/docs/cloud/how-tos/webhooks.md +++ b/docs/docs/cloud/how-tos/webhooks.md @@ -1,142 +1,147 @@ -# Use Webhooks +# Using Webhooks -You may wish to use webhooks in your client, especially when using async streams in case you want to update something in your service once the API call to LangGraph Cloud has finished running. To do so, you will need to expose an endpoint that can accept POST requests, and then pass it to your API request in the "webhook" parameter. +When working with LangGraph Cloud, you may want to use webhooks to receive updates after an API call completes. Webhooks are useful for triggering actions in your service once a run has finished processing. To implement this, you need to expose an endpoint that can accept `POST` requests and pass this endpoint as a `webhook` parameter in your API request. -Currently, the SDK has not exposed this endpoint but you can access it through curl commands as follows. +Currently, the SDK does not provide built-in support for defining webhook endpoints, but you can specify them manually using API requests. -The following endpoints accept `webhook` as a parameter: +## Supported Endpoints -- Create Run -> POST /thread/{thread_id}/runs -- Create Thread Cron -> POST /thread/{thread_id}/runs/crons -- Stream Run -> POST /thread/{thread_id}/runs/stream -- Wait Run -> POST /thread/{thread_id}/runs/wait -- Create Cron -> POST /runs/crons -- Stream Run Stateless -> POST /runs/stream -- Wait Run Stateless -> POST /runs/wait +The following API endpoints accept a `webhook` parameter: -In this example, we will show calling a webhook after streaming a run. +| Operation | HTTP Method | Endpoint | +|-----------|------------|----------| +| Create Run | `POST` | `/thread/{thread_id}/runs` | +| Create Thread Cron | `POST` | `/thread/{thread_id}/runs/crons` | +| Stream Run | `POST` | `/thread/{thread_id}/runs/stream` | +| Wait Run | `POST` | `/thread/{thread_id}/runs/wait` | +| Create Cron | `POST` | `/runs/crons` | +| Stream Run Stateless | `POST` | `/runs/stream` | +| Wait Run Stateless | `POST` | `/runs/wait` | -## Setup +In this guide, we’ll show how to trigger a webhook after streaming a run. -First, let's setup our assistant and thread: +## Setting Up Your Assistant and Thread + +Before making API calls, set up your assistant and thread. === "Python" +```python +from langgraph_sdk import get_client - ```python - from langgraph_sdk import get_client +client = get_client(url=) +assistant_id = "agent" +thread = await client.threads.create() +print(thread) +``` - client = get_client(url=) - # Using the graph deployed with the name "agent" - assistant_id = "agent" - # create thread - thread = await client.threads.create() - print(thread) - ``` +=== "JavaScript" +```js +import { Client } from "@langchain/langgraph-sdk"; -=== "Javascript" - - ```js - import { Client } from "@langchain/langgraph-sdk"; - - const client = new Client({ apiUrl: }); - // Using the graph deployed with the name "agent" - const assistantID = "agent"; - // create thread - const thread = await client.threads.create(); - console.log(thread); - ``` +const client = new Client({ apiUrl: }); +const assistantID = "agent"; +const thread = await client.threads.create(); +console.log(thread); +``` === "CURL" +```bash +curl --request POST \ + --url /assistants/search \ + --header 'Content-Type: application/json' \ + --data '{ "limit": 10, "offset": 0 }' | jq -c 'map(select(.config == null or .config == {})) | .[0]' && \ +curl --request POST \ + --url /threads \ + --header 'Content-Type: application/json' \ + --data '{}' +``` - ```bash - curl --request POST \ - --url /assistants/search \ - --header 'Content-Type: application/json' \ - --data '{ - "limit": 10, - "offset": 0 - }' | jq -c 'map(select(.config == null or .config == {})) | .[0]' && \ - curl --request POST \ - --url /threads \ - --header 'Content-Type: application/json' \ - --data '{}' - ``` +### Example Response +```json +{ + "thread_id": "9dde5490-2b67-47c8-aa14-4bfec88af217", + "created_at": "2024-08-30T23:07:38.242730+00:00", + "updated_at": "2024-08-30T23:07:38.242730+00:00", + "metadata": {}, + "status": "idle", + "config": {}, + "values": null +} +``` -Output: +## Using a Webhook with a Graph Run - { - 'thread_id': '9dde5490-2b67-47c8-aa14-4bfec88af217', - 'created_at': '2024-08-30T23:07:38.242730+00:00', - 'updated_at': '2024-08-30T23:07:38.242730+00:00', - 'metadata': {}, - 'status': 'idle', - 'config': {}, - 'values': None - } +To use a webhook, specify the `webhook` parameter in your API request. When the run completes, LangGraph Cloud sends a `POST` request to the specified webhook URL. -## Use graph with a webhook - -To invoke a run with a webhook, we specify the `webhook` parameter with the desired endpoint when creating a run. Webhook requests are triggered by the end of a run. - -For example, if we can receive requests at `https://my-server.app/my-webhook-endpoint`, we can pass this to `stream`: +For example, if your server listens for webhook events at `https://my-server.app/my-webhook-endpoint`, include this in your request: === "Python" +```python +input = { "messages": [{ "role": "user", "content": "Hello!" }] } - ```python - # create input - input = { "messages": [{ "role": "user", "content": "Hello!" }] } +async for chunk in client.runs.stream( + thread_id=thread["thread_id"], + assistant_id=assistant_id, + input=input, + stream_mode="events", + webhook="https://my-server.app/my-webhook-endpoint" +): + pass +``` - async for chunk in client.runs.stream( - thread_id=thread["thread_id"], - assistant_id=assistant_id, - input=input, - stream_mode="events", - webhook="https://my-server.app/my-webhook-endpoint" - ): - # Do something with the stream output - pass - ``` +=== "JavaScript" +```js +const input = { messages: [{ role: "human", content: "Hello!" }] }; -=== "Javascript" +const streamResponse = client.runs.stream( + thread["thread_id"], + assistantID, + { + input: input, + webhook: "https://my-server.app/my-webhook-endpoint" + } +); - ```js - // create input - const input = { messages: [{ role: "human", content: "Hello!" }] }; - - // stream events - const streamResponse = client.runs.stream( - thread["thread_id"], - assistantID, - { - input: input, - webhook: "https://my-server.app/my-webhook-endpoint" - } - ); - for await (const chunk of streamResponse) { - // Do something with the stream output - } - ``` +for await (const chunk of streamResponse) { + // Handle stream output +} +``` === "CURL" - - ```bash - curl --request POST \ - --url /threads//runs/stream \ - --header 'Content-Type: application/json' \ - --data '{ - "assistant_id": , - "input" : {"messages":[{"role": "user", "content": "Hello!"}]}, - "webhook": "https://my-server.app/my-webhook-endpoint" - }' - ``` - -The schema for the payload sent to `my-webhook-endpoint` is that of a [run](../../concepts/langgraph_server.md/#runs). See [API Reference](https://langchain-ai.github.io/langgraph/cloud/reference/api/api_ref.html#model/run) for more detail. Note that the run input, configuration, etc. are included in the `kwargs` field. - -### Signing webhook requests - -To sign the webhook requests, we can specify a token parameter in the webhook URL, e.g., -``` -https://my-server.app/my-webhook-endpoint?token=... +```bash +curl --request POST \ + --url /threads//runs/stream \ + --header 'Content-Type: application/json' \ + --data '{ + "assistant_id": , + "input": {"messages": [{"role": "user", "content": "Hello!"}]}, + "webhook": "https://my-server.app/my-webhook-endpoint" + }' ``` -The server should then extract the token from the request's parameters and validate it before processing the payload. +## Webhook Payload + +LangGraph Cloud sends webhook notifications in the format of a [Run](../../concepts/langgraph_server.md/#runs). See the [API Reference](https://langchain-ai.github.io/langgraph/cloud/reference/api/api_ref.html#model/run) for details. The request payload includes run input, configuration, and other metadata in the `kwargs` field. + +## Securing Webhooks + +To ensure only authorized requests hit your webhook endpoint, consider adding a security token as a query parameter: + +``` +https://my-server.app/my-webhook-endpoint?token=YOUR_SECRET_TOKEN +``` + +Your server should extract and validate this token before processing requests. + +## Testing Webhooks + +You can test your webhook using online services like: + +- **[Beeceptor](https://beeceptor.com/)** – Quickly create a test endpoint and inspect incoming webhook payloads. +- **[Webhook.site](https://webhook.site/)** – View, debug, and log incoming webhook requests in real time. + +These tools help you verify that LangGraph Cloud is correctly triggering and sending webhooks to your service. + +--- + +By following these steps, you can integrate webhooks into your LangGraph Cloud workflow, automating actions based on completed runs.