The difference between the use of configurable and metadata in RunnableConfig? #144

Closed
opened 2026-02-20 17:28:57 -05:00 by yindo · 4 comments
Owner

Originally created by @gbaian10 on GitHub (Jul 9, 2024).

Checked other resources

  • I added a very descriptive title to this issue.
  • I searched the LangGraph/LangChain documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangGraph/LangChain rather than my code.
  • I am sure this is better as an issue rather than a GitHub discussion, since this is a LangGraph bug and not a design question.

Example Code

from langchain_core.messages import AIMessage
from langchain_core.runnables import RunnableConfig
from langgraph.graph import StateGraph, MessagesState


def print_config(state: MessagesState, config: RunnableConfig) -> MessagesState:
    print(config["metadata"])  # The value of container type does not appear here
    # These values must be use configurable to get
    print(config["configurable"]["cherries"])
    print(config["configurable"]["dates"])
    print(config["configurable"]["egg"])
    return {"messages": [AIMessage(content="foo")]}


graph_builder = StateGraph(MessagesState)
graph_builder.set_entry_point("foo")
graph_builder.add_node("foo", print_config)
graph_builder.set_finish_point("foo")

config = {
    "configurable": {
        "apple": 1,
        "banana": "two",
        "cherries": [3, "four", 5.0],
        "dates": {"Alice": 6, "Bob": "seven"},
        "egg": (1, 2),
    },
}

app = graph_builder.compile()
app.invoke({"messages": [("human", "Hello World!")]}, config)

Error Message and Stack Trace (if applicable)

`config["metadata"]` cannot retrieve some of the data entered from `configurable`

Description

When I use

{
    "configurable": {
        "apple": 1,
        "banana": "two",
        "cherries": [3, "four", 5.0],
        "dates": {"Alice": 6, "Bob": "seven"},
        "egg": (1, 2),
    },
}

config["metadata"] seems to only save basic types of content?

Is this normal output? What is the principle of saving metadata? When should I use metadata or configurable?

configurable contains a lot of information, while metadata is much cleaner. I encountered this problem when trying to use metadata to get some of my own data.


When I use metadata to input, all values ​​can be obtained normally.

{
    "metadata": {
        "apple": 1,
        "banana": "two",
        "cherries": [3, "four", 5.0],
        "dates": {"Alice": 6, "Bob": "seven"},
        "egg": (1, 2),
    },
}

System Info

langgraph == 0.1.5
langchain == 0.2.6
python version == 3.10.12

Originally created by @gbaian10 on GitHub (Jul 9, 2024). ### Checked other resources - [X] I added a very descriptive title to this issue. - [X] I searched the [LangGraph](https://langchain-ai.github.io/langgraph/)/LangChain documentation with the integrated search. - [X] I used the GitHub search to find a similar question and didn't find it. - [X] I am sure that this is a bug in LangGraph/LangChain rather than my code. - [X] I am sure this is better as an issue [rather than a GitHub discussion](https://github.com/langchain-ai/langgraph/discussions/new/choose), since this is a LangGraph bug and not a design question. ### Example Code ```python from langchain_core.messages import AIMessage from langchain_core.runnables import RunnableConfig from langgraph.graph import StateGraph, MessagesState def print_config(state: MessagesState, config: RunnableConfig) -> MessagesState: print(config["metadata"]) # The value of container type does not appear here # These values must be use configurable to get print(config["configurable"]["cherries"]) print(config["configurable"]["dates"]) print(config["configurable"]["egg"]) return {"messages": [AIMessage(content="foo")]} graph_builder = StateGraph(MessagesState) graph_builder.set_entry_point("foo") graph_builder.add_node("foo", print_config) graph_builder.set_finish_point("foo") config = { "configurable": { "apple": 1, "banana": "two", "cherries": [3, "four", 5.0], "dates": {"Alice": 6, "Bob": "seven"}, "egg": (1, 2), }, } app = graph_builder.compile() app.invoke({"messages": [("human", "Hello World!")]}, config) ``` ### Error Message and Stack Trace (if applicable) ```shell `config["metadata"]` cannot retrieve some of the data entered from `configurable` ``` ### Description When I use ```py { "configurable": { "apple": 1, "banana": "two", "cherries": [3, "four", 5.0], "dates": {"Alice": 6, "Bob": "seven"}, "egg": (1, 2), }, } ``` config["metadata"] seems to only save basic types of content? Is this normal output? What is the principle of saving metadata? When should I use `metadata` or `configurable`? `configurable` contains a lot of information, while `metadata` is much cleaner. I encountered this problem when trying to use `metadata` to get some of my own data. --- When I use metadata to input, all values ​​can be obtained normally. ```py { "metadata": { "apple": 1, "banana": "two", "cherries": [3, "four", 5.0], "dates": {"Alice": 6, "Bob": "seven"}, "egg": (1, 2), }, } ``` ### System Info langgraph == 0.1.5 langchain == 0.2.6 python version == 3.10.12
yindo closed this issue 2026-02-20 17:28:57 -05:00
Author
Owner

@hinthornw commented on GitHub (Jul 9, 2024):

Metadata was designed for tracing (instrumentation) rather than control flow.

Configurable parameters are meant for actual configuration of the graph / runnable execution.

We log primitive values as metadata since that's useful for observability.

But I do see how that's non-obvious just by looking at the config

@hinthornw commented on GitHub (Jul 9, 2024): Metadata was designed for tracing (instrumentation) rather than control flow. Configurable parameters are meant for actual configuration of the graph / runnable execution. We log primitive values as metadata since that's useful for observability. But I do see how that's non-obvious just by looking at the config
Author
Owner

@gbaian10 commented on GitHub (Jul 9, 2024):

Because I observed before that the metadata has the Configurable I entered, and its contents are very clean.

It was easy for me to find all the values ​​I passed in, until I discovered that it seemed to only save the contents of the basic type.

In short, metadata should be an attribute used for langchain internal program tracking.

If the user passes some data to Node and want to use it in Node, should it always be through Configurable?

@gbaian10 commented on GitHub (Jul 9, 2024): Because I observed before that the metadata has the Configurable I entered, and its contents are very clean. It was easy for me to find all the values ​​I passed in, until I discovered that it seemed to only save the contents of the basic type. In short, metadata should be an attribute used for langchain internal program tracking. If the user passes some data to Node and want to use it in Node, should it always be through Configurable?
Author
Owner

@hinthornw commented on GitHub (Jul 9, 2024):

The input would either be in the configuration or the state. Typically configuration is things like IDs, selecting the model type, etc., whereas state is things like messages, documents, database connection, etc.

@hinthornw commented on GitHub (Jul 9, 2024): The input would either be in the configuration or the state. Typically configuration is things like IDs, selecting the model type, etc., whereas state is things like messages, documents, database connection, etc.
Author
Owner

@gbaian10 commented on GitHub (Jul 9, 2024):

Thank you for your answer, I will close this issue.

@gbaian10 commented on GitHub (Jul 9, 2024): Thank you for your answer, I will close this issue.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#144