Skip to content

Commit eb508b5

Browse files
nPepponAndrea
andauthored
Enhance ResearchAgentMixin with context parameter for rag tool and skip extended thinking message in Agent class for non Anthropic models (#2210)
Co-authored-by: Andrea <npeppon@XMG-Core24>
1 parent eca4923 commit eb508b5

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

py/core/agent/research.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def rag_tool(self) -> Tool:
115115
},
116116
"required": ["query"],
117117
},
118+
context=self,
118119
)
119120

120121
def reasoning_tool(self) -> Tool:

py/core/base/agent/agent.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,17 @@ async def handle_function_or_tool_call(
227227
)
228228
)
229229
# HACK - to fix issues with claude thinking + tool use [https://github.com/anthropics/anthropic-cookbook/blob/main/extended_thinking/extended_thinking_with_tool_use.ipynb]
230-
if self.rag_generation_config.extended_thinking:
230+
logger.debug(
231+
f"Extended thinking - Claude needs a particular message continuation which however breaks other models. Model in use : {self.rag_generation_config.model}"
232+
)
233+
is_anthropic = (
234+
self.rag_generation_config.model
235+
and "anthropic/" in self.rag_generation_config.model
236+
)
237+
if (
238+
self.rag_generation_config.extended_thinking
239+
and is_anthropic
240+
):
231241
await self.conversation.add_message(
232242
Message(
233243
role="user",

0 commit comments

Comments
 (0)