Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
fix: Patch model dump issues on firecrawl (#2864)
Matthew Zhou75edfda3c357
diff --git a/letta/functions/prompts.py b/letta/functions/prompts.pyindex f9bac2a0b..85bd99a94 100644--- a/letta/functions/prompts.py+++ b/letta/functions/prompts.py@@ -6,10 +6,9 @@ Guidelines:1. Extract substantial, lengthy text snippets that directly address the question2. Preserve important context and details in each snippet - err on the side of including more rather than less3. Keep thinking very brief (1 short sentence) - focus on WHY the snippet is relevant, not WHAT it says-4. Include a concise summary of how the overall document relates to the question-5. Only extract snippets that actually answer or relate to the question - don't force relevance-6. Be comprehensive - include all relevant information, don't limit the number of snippets-7. Prioritize longer, information-rich passages over shorter ones"""+4. Only extract snippets that actually answer or relate to the question - don't force relevance+5. Be comprehensive - include all relevant information, don't limit the number of snippets+6. Prioritize longer, information-rich passages over shorter ones"""def get_firecrawl_search_user_prompt(query: str, question: str, markdown_content: str) -> str:diff --git a/letta/services/tool_executor/builtin_tool_executor.py b/letta/services/tool_executor/builtin_tool_executor.pyindex d8abe2986..859cb8aef 100644--- a/letta/services/tool_executor/builtin_tool_executor.py+++ b/letta/services/tool_executor/builtin_tool_executor.py@@ -31,7 +31,6 @@ class DocumentAnalysis(BaseModel):"""Analysis of a document's relevance to a search question."""citations: List[Citation]- summary: str # Brief summary of how this document relates to the questionclass LettaBuiltinToolExecutor(ToolExecutor):@@ -225,7 +224,7 @@ class LettaBuiltinToolExecutor(ToolExecutor):for result, analysis in zip(results_with_markdown, analyses):if isinstance(analysis, Exception) or analysis is None:logger.error(f"Analysis failed for {result.get('url')}, falling back to raw results")- return search_result.model_dump_json(exclude_none=True)+ return str(search_result)# All analyses succeeded, build processed resultsfor result, analysis in zip(results_with_markdown, analyses):@@ -252,7 +251,7 @@ class LettaBuiltinToolExecutor(ToolExecutor):logger.error(f"Error with OpenAI processing: {e}")# Return raw search results if OpenAI processing isn't available or fails- return search_result.model_dump_json(exclude_none=True)+ return str(search_result)async def _analyze_document_with_openai(self, client, markdown_content: str, query: str, question: str) -> Optional[DocumentAnalysis]:"""Use OpenAI to analyze a document and extract relevant passages."""@@ -283,11 +282,9 @@ class LettaBuiltinToolExecutor(ToolExecutor):if result.get("analysis") and result["analysis"].get("citations"):analysis = result["analysis"]- source["summary"] = analysis.get("summary")source["citations"] = analysis["citations"]total_snippets += len(analysis["citations"])else:- source["summary"] = "No relevant information found to answer the question"source["citations"] = []sources.append(source)