mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-07-10 00:18:36 +00:00
fix(gateway): propagate thread_id for LangGraph context API (#3735)
Some checks are pending
Backend Blocking IO / backend-blocking-io (push) Waiting to run
Unit Tests / backend-unit-tests (push) Waiting to run
Frontend Unit Tests / frontend-unit-tests (push) Waiting to run
Lint Check / lint-backend (push) Waiting to run
Lint Check / lint-frontend (push) Waiting to run
Replay E2E (front-back contract) / Layer 1 — backend golden (no API key) (push) Waiting to run
Replay E2E (front-back contract) / Layer 2 — full-stack render (no API key) (push) Waiting to run
Some checks are pending
Backend Blocking IO / backend-blocking-io (push) Waiting to run
Unit Tests / backend-unit-tests (push) Waiting to run
Frontend Unit Tests / frontend-unit-tests (push) Waiting to run
Lint Check / lint-backend (push) Waiting to run
Lint Check / lint-frontend (push) Waiting to run
Replay E2E (front-back contract) / Layer 1 — backend golden (no API key) (push) Waiting to run
Replay E2E (front-back contract) / Layer 2 — full-stack render (no API key) (push) Waiting to run
This commit is contained in:
parent
b66e3253a0
commit
caf54938db
2 changed files with 18 additions and 1 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue