DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
merge: bring 19 reviewed PRs from origin/dev into dev
Bingxi Zhao (Frank)4e2f08854829
diff --cc deeptutor/agents/research/pipeline.pyindex 83ab02281,f9c173e9f..1b9c0922e--- a/deeptutor/agents/research/pipeline.py+++ b/deeptutor/agents/research/pipeline.py@@@ -2577,8 -2592,14 +2593,10 @@@ class _BlockLoopHost"notices.start_retrieval", default="Starting retrieval"),too_many_tool_calls_message=too_many,- unknown_error_message_factory=lambda tn: self._pipeline._t(- "notices.tool_unknown_error",- tool=tn,- default=f"Error executing {tn}.",- ),+ tool_error_message_factory=tool_error_message_factory(self._pipeline._t),trace_id_prefix=f"research-{self._block.block_id}-iter",+ tool_timeout=self._pipeline.tool_timeout,+ tool_max_retries=self._pipeline.tool_max_retries,)pageindex_sources = [source for source in outcome.sources if source.get("type") == "pageindex"diff --cc deeptutor/book/blocks/_llm_writer.pyindex 0aa268efb,f5f831220..d41d3cce8--- a/deeptutor/book/blocks/_llm_writer.py+++ b/deeptutor/book/blocks/_llm_writer.py@@@ -139,10 -146,11 +140,14 @@@ async def llm_jsonReasoning models can spend the whole response budget on hidden/scratchpadtokens and leave the visible JSON object empty. For structured book blockswe first honor the configured reasoning mode, then retry once with low- reasoning effort if parsing fails or the expected top-level key is missing.- When a caller explicitly supplies an effort (book reader-facing blocks use- ``"none"``), the same value is used for the retry so it cannot silently- re-enable reasoning.+ reasoning effort if parsing fails or the expected top-level key is missing+ — the same rule the Book pipeline agents apply via+ :func:`deeptutor.book.json_retry.json_with_reasoning_retry`.+++ A caller that supplies an effort of its own (book reader-facing blocks pass++ ``"none"``) keeps that value on the retry, so a round that was deliberately++ run without thinking cannot silently re-enable it.+Also strips thinking/reasoning preamble text (common with local models)before JSON parsing."""@@@ -169,13 -177,14 +174,14 @@@recovered = parse_json_response(raw, fallback={})return _normalize_json_payload(recovered, expected_key=expected_key)- data = await _once(None)+ data = await _once(reasoning_effort)- if _json_has_expected(data, expected_key):+ if json_payload_is_usable(data, expected_key):return data- retry_data = await _once(RETRY_REASONING_EFFORT)- retry_effort = "low" if reasoning_effort is None else reasoning_effort++ retry_effort = RETRY_REASONING_EFFORT if reasoning_effort is None else reasoning_effort+ retry_data = await _once(retry_effort)- if _json_has_expected(retry_data, expected_key):+ if json_payload_is_usable(retry_data, expected_key):- retry_data.setdefault("_metadata", {})["reasoning_retry"] = RETRY_REASONING_EFFORT+ retry_data.setdefault("_metadata", {})["reasoning_retry"] = retry_effortreturn retry_datareturn data or retry_datadiff --cc deeptutor/runtime/agentic/tool_dispatch.pyindex feadd9aeb,1f4a9e7ec..9ef0b2edc--- a/deeptutor/runtime/agentic/tool_dispatch.py+++ b/deeptutor/runtime/agentic/tool_dispatch.py@@@ -134,8 -103,10 +134,10 @@@ async def dispatch_tool_callsempty_tool_result_message: str = "",start_retrieval_message: str = "Starting retrieval",too_many_tool_calls_message: str | None = None,- unknown_error_message_factory: UnknownErrorMessageFactory | None = None,+ tool_error_message_factory: ToolErrorMessageFactory | None = None,trace_id_prefix: str = "iter",+ tool_timeout: float | None = None,+ tool_max_retries: int = 0,) -> DispatchOutcome:"""Execute tool calls in parallel and assemble a :class:`DispatchOutcome`."""registry = registry or get_tool_registry()@@@ -238,8 -217,10 +248,10 @@@),empty_tool_result_message=empty_tool_result_message,start_retrieval_message=start_retrieval_message,- unknown_error_message_factory=unknown_error_message_factory,+ tool_error_message_factory=tool_error_message_factory,retrieve_label=retrieve_label,+ tool_timeout=None if policy_exempt else tool_timeout,+ tool_max_retries=0 if policy_exempt else tool_max_retries,)def _rebind(indices: list[int]) -> None:@@@ -582,7 -601,9 +632,9 @@@ async def execute_tool_callempty_tool_result_message: str = "",start_retrieval_message: str = "Starting retrieval",retrieve_label: str = "Retrieve",- unknown_error_message_factory: UnknownErrorMessageFactory | None = None,+ tool_error_message_factory: ToolErrorMessageFactory | None = None,+ tool_timeout: float | None = None,+ tool_max_retries: int = 0,) -> dict[str, Any]:"""Run one tool, streaming its state (and any intermediate progress) intothe tool's own sub-trace.