mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-07-22 14:08:28 +00:00
fix(gateway): propagate thread_id for LangGraph context API (#3735)
This commit is contained in:
parent
b66e3253a0
commit
caf54938db
@ -252,6 +252,7 @@ def build_run_config(
|
||||
context = dict(context_value)
|
||||
else:
|
||||
raise ValueError("request config 'context' must be a mapping or null.")
|
||||
context["thread_id"] = thread_id
|
||||
config["context"] = context
|
||||
else:
|
||||
configurable = {"thread_id": thread_id}
|
||||
|
||||
@ -705,17 +705,33 @@ def test_build_run_config_with_context():
|
||||
)
|
||||
assert "context" in config
|
||||
assert config["context"]["user_id"] == "u-42"
|
||||
assert config["context"]["thread_id"] == "thread-1"
|
||||
assert "configurable" not in config
|
||||
assert config["recursion_limit"] == 100
|
||||
|
||||
|
||||
def test_build_run_config_context_injects_thread_id():
|
||||
from app.gateway.services import build_run_config
|
||||
|
||||
config = build_run_config(
|
||||
"T-deadbeef-42",
|
||||
{"context": {"user_id": "u-1", "thinking_enabled": True}},
|
||||
None,
|
||||
)
|
||||
|
||||
assert config["context"]["user_id"] == "u-1"
|
||||
assert config["context"]["thinking_enabled"] is True
|
||||
assert config["context"]["thread_id"] == "T-deadbeef-42"
|
||||
assert "configurable" not in config
|
||||
|
||||
|
||||
def test_build_run_config_null_context_becomes_empty_context():
|
||||
"""When caller sends context=null, treat it as an empty context object."""
|
||||
from app.gateway.services import build_run_config
|
||||
|
||||
config = build_run_config("thread-1", {"context": None}, None)
|
||||
|
||||
assert config["context"] == {}
|
||||
assert config["context"] == {"thread_id": "thread-1"}
|
||||
assert "configurable" not in config
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user