Skip to content

Commit 7b05cbb

Browse files
committed
remove query from input
1 parent 3039c8d commit 7b05cbb

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

deep_security/src/open_deep_research/deep_researcher.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,29 @@ async def write_research_brief(state: AgentState, config: RunnableConfig) -> Com
146146
.with_config(research_model_config)
147147
)
148148

149-
# Step 2: Generate structured research brief from user messages
149+
# Step 2: Extract original query from messages for caching
150+
messages = state.get("messages", [])
151+
original_query = None
152+
if not state.get("original_query"):
153+
# Find the first user/human message content
154+
for msg in messages:
155+
if hasattr(msg, 'type') and msg.type in ['human', 'user']:
156+
original_query = str(msg.content).strip()
157+
break
158+
elif isinstance(msg, HumanMessage):
159+
original_query = str(msg.content).strip()
160+
break
161+
else:
162+
original_query = state.get("original_query")
163+
164+
# Step 3: Generate structured research brief from user messages
150165
prompt_content = transform_messages_into_research_topic_prompt.format(
151-
messages=get_buffer_string(state.get("messages", [])),
166+
messages=get_buffer_string(messages),
152167
date=get_today_str()
153168
)
154169
response = await research_model.ainvoke([HumanMessage(content=prompt_content)])
155170

156-
# Step 3: Initialize supervisor with research brief and instructions
171+
# Step 4: Initialize supervisor with research brief and instructions
157172
supervisor_system_prompt = lead_researcher_prompt.format(
158173
date=get_today_str(),
159174
max_concurrent_research_units=configurable.max_concurrent_research_units,
@@ -164,6 +179,7 @@ async def write_research_brief(state: AgentState, config: RunnableConfig) -> Com
164179
goto="research_supervisor",
165180
update={
166181
"research_brief": response.research_brief,
182+
"original_query": original_query, # Add original query for caching
167183
"supervisor_messages": {
168184
"type": "override",
169185
"value": [

deep_security/src/open_deep_research/state.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,6 @@ def override_reducer(current_value, new_value):
255255
class AgentInputState(MessagesState):
256256
"""InputState is only 'messages'."""
257257

258-
original_query: Optional[str] = None
259-
260258
class AgentState(MessagesState):
261259
"""Main agent state containing messages and research data."""
262260

0 commit comments

Comments
 (0)