Skip to content

Commit 247c170

Browse files
committed
opt
1 parent 1acdc60 commit 247c170

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

src/agent/custom_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ async def step(self, step_info: Optional[CustomAgentStepInfo] = None) -> None:
264264
# TODO: fix no action case
265265
result = [ActionResult(is_done=True, extracted_content=step_info.memory, include_in_memory=True)]
266266
for ret_ in result:
267-
if "Extracted page as" in ret_.extracted_content:
267+
if "Extracted page" in ret_.extracted_content:
268268
# record every extracted page
269269
self.extracted_content += ret_.extracted_content
270270
self._last_result = result

tests/test_deep_research.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,13 @@ async def deep_research():
8181
8282
**Important Considerations:**
8383
84-
1. **Minimize Information Loss:** While concise, prioritize retaining important details and nuances from the sources. Aim for a summary that captures the essence of the information without over-simplification.
84+
1. **Minimize Information Loss:** While concise, prioritize retaining important details and nuances from the sources. Aim for a summary that captures the essence of the information without over-simplification. **Crucially, ensure to preserve key data and figures within the `summary_content`. This is essential for later stages, such as generating tables and reports.**
8585
8686
2. **Avoid Redundancy:** Do not record information that is already present in the Previous Recorded Information. Check for semantic similarity, not just exact matches. However, if the same information is expressed differently in a new source and this variation adds valuable context or clarity, it should be included.
8787
88-
3. **Utility Focus:** Only record information that is likely to be useful for completing the user's original instruction. Ask yourself: "How might this information contribute to the AI agent achieving its goal?" Prefer more information over less, as long as it remains relevant to the user's request.
88+
3. **Source Information:** Extract and include the source title and URL for each piece of information summarized. This is crucial for verification and context. **The Current Search Results are provided in a specific format, where each item starts with "Title:", followed by the title, then "URL Source:", followed by the URL, and finally "Markdown Content:", followed by the content. Please extract the title and URL from this structure.** If a piece of information cannot be attributed to a specific source from the provided search results, use `"url": "unknown"` and `"title": "unknown"`.
8989
90-
4. **Source Information:** Extract and include the source title and URL for each piece of information summarized. This is crucial for verification and context. If a piece of information cannot be attributed to a specific source from the provided search results, use `"url": "unknown"` and `"title": "unknown"`.
91-
92-
5. **Thinking and Report Structure:** For each extracted piece of information, add a `"thinking"` key. This field should contain your assessment of how this information could be used in a report, which section it might belong to (e.g., introduction, background, analysis, conclusion, specific subtopics), and any other relevant thoughts about its significance or connection to other information.
90+
4. **Thinking and Report Structure:** For each extracted piece of information, add a `"thinking"` key. This field should contain your assessment of how this information could be used in a report, which section it might belong to (e.g., introduction, background, analysis, conclusion, specific subtopics), and any other relevant thoughts about its significance or connection to other information.
9391
9492
**Output Format:**
9593
@@ -100,7 +98,7 @@ async def deep_research():
10098
{
10199
"url": "source_url_1",
102100
"title": "source_title_1",
103-
"summary_content": "concise_summary_of_content_from_source_1",
101+
"summary_content": "Concise summary of content. Remember to include key data and figures here.",
104102
"thinking": "This could be used in the introduction to set the context. It also relates to the section on the history of the topic."
105103
},
106104
// ... more entries
@@ -183,7 +181,7 @@ async def deep_research():
183181
os.makedirs(query_result_dir, exist_ok=True)
184182
for i in range(len(query_tasks)):
185183
query_result = query_results[i].final_result()
186-
with open(os.path.join(query_result_dir, f"{search_iteration}-{i}.md"), "w") as fw:
184+
with open(os.path.join(query_result_dir, f"{search_iteration}-{i}.md"), "w", encoding="utf-8") as fw:
187185
fw.write(f"Query: {query_tasks[i]}\n")
188186
fw.write(query_result)
189187
history_infos_ = json.dumps(history_infos, indent=4)
@@ -213,9 +211,18 @@ async def deep_research():
213211
* **Accuracy, Credibility, and Citations:** Ensure that all information presented is meticulously accurate, rigorously truthful, and robustly supported by the available data. **Cite sources exclusively using bracketed sequential numbers within the text (e.g., [1], [2], etc.). If no references are used, omit citations entirely.** These numbers must correspond to a numbered list of references at the end of the report.
214212
* **Publication-Ready Formatting:** Adhere strictly to Markdown formatting for excellent readability and a clean, highly professional visual appearance. Pay close attention to formatting details like headings, lists, emphasis, and spacing to optimize the visual presentation and reader experience. The report should be ready for immediate publication upon completion, requiring minimal to no further editing for style or format.
215213
* **Conciseness and Clarity (Unless Specified Otherwise):** When the user does not provide a specific length, prioritize concise and to-the-point writing, maximizing information density while maintaining clarity.
214+
* **Data-Driven Comparisons with Tables:** **When appropriate and beneficial for enhancing clarity and impact, present data comparisons in well-structured Markdown tables. This is especially encouraged when dealing with numerical data or when a visual comparison can significantly improve the reader's understanding.**
216215
* **Length Adherence:** When the user specifies a length constraint, meticulously stay within reasonable bounds of that specification, ensuring the content is appropriately scaled without sacrificing quality or completeness.
217216
* **Comprehensive Instruction Following:** Pay meticulous attention to all details and nuances provided in the user instructions. Strive to fulfill every aspect of the user's request with the highest degree of accuracy and attention to detail, creating a report that not only meets but exceeds expectations for quality and professionalism.
218-
* **Reference List Formatting:** The reference list at the end must be formatted as follows: `[1] Title (URL, if available)`.
217+
* **Reference List Formatting:** The reference list at the end must be formatted as follows:
218+
`[1] Title (URL, if available)`
219+
**Each reference must be separated by a blank line to ensure proper spacing.** For example:
220+
221+
```
222+
[1] Title 1 (URL1, if available)
223+
224+
[2] Title 2 (URL2, if available)
225+
```
219226
* **ABSOLUTE FINAL OUTPUT RESTRICTION:** **Your output must contain ONLY the finished, publication-ready Markdown report. Do not include ANY extraneous text, phrases, preambles, meta-commentary, or markdown code indicators (e.g., "```markdown```"). The report should begin directly with the title and introductory paragraph, and end directly after the conclusion and the reference list (if applicable).** **Your response will be deemed a failure if this instruction is not followed precisely.**
220227
221228
**Inputs:**
@@ -224,7 +231,7 @@ async def deep_research():
224231
3. **Search Information:** Information gathered from the recent search queries.
225232
"""
226233
with open(os.path.join(save_dir, "record_infos.json"), "w") as fw:
227-
json.dump(history_infos, fw)
234+
json.dump(history_infos, fw, indent=4)
228235
history_infos_ = json.dumps(history_infos, indent=4)
229236
report_prompt = f"User Instruction:{task} \n Search Information:\n {history_infos_}"
230237
report_messages = [SystemMessage(content=writer_system_prompt),

0 commit comments

Comments
 (0)