fix(skill-review): pass RunnableConfig with thread_id to satisfy ThreadDataMiddleware
This commit is contained in:
1 parent
3955bd72b5
commit
857798ff2f
1 file changed
+5
-1
@@ -136,6 +136,7 @@ async def _run_review(thread_id: str, messages: list[BaseMessage], app_config: "
|
|||||||
"""
|
"""
|
||||||
from langchain.agents import create_agent
|
from langchain.agents import create_agent
|
||||||
from langchain_core.messages import HumanMessage
|
from langchain_core.messages import HumanMessage
|
||||||
|
from langchain_core.runnables import RunnableConfig
|
||||||
|
|
||||||
from deerflow.agents.lead_agent.prompt import apply_prompt_template
|
from deerflow.agents.lead_agent.prompt import apply_prompt_template
|
||||||
from deerflow.agents.middlewares.prompt_prefix_middleware import PromptPrefixMiddleware
|
from deerflow.agents.middlewares.prompt_prefix_middleware import PromptPrefixMiddleware
|
||||||
@@ -182,6 +183,9 @@ async def _run_review(thread_id: str, messages: list[BaseMessage], app_config: "
|
|||||||
state_schema=ThreadState,
|
state_schema=ThreadState,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# RunnableConfig supplies thread_id so ThreadDataMiddleware is satisfied.
|
||||||
|
run_config = RunnableConfig(configurable={"thread_id": f"__skill-review__{thread_id}"})
|
||||||
|
|
||||||
# Review instructions arrive as prompt_prefix: PromptPrefixMiddleware prepends
|
# Review instructions arrive as prompt_prefix: PromptPrefixMiddleware prepends
|
||||||
# them before every model call without persisting them to state.
|
# them before every model call without persisting them to state.
|
||||||
first_message = HumanMessage(
|
first_message = HumanMessage(
|
||||||
@@ -196,7 +200,7 @@ async def _run_review(thread_id: str, messages: list[BaseMessage], app_config: "
|
|||||||
result = await asyncio.wait_for(
|
result = await asyncio.wait_for(
|
||||||
asyncio.get_event_loop().run_in_executor(
|
asyncio.get_event_loop().run_in_executor(
|
||||||
None,
|
None,
|
||||||
lambda: agent.invoke({"messages": [first_message]}),
|
lambda: agent.invoke({"messages": [first_message]}, config=run_config),
|
||||||
),
|
),
|
||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in new issue
Block a user