Repository navigation
Fix: Adjust ExecutionStrategy of THINKING_MODES. - #17862
Conversation
📝 WalkthroughWalkthroughThe change expands search tools in harness modes, conditionally preserves closing reasoning markers in tool-result history, and stores tokenized fields for refined wiki pages. ChangesHarness mode configuration
Tool-result reasoning markers
Wiki token metadata
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@rag/advanced_rag/harness/config.py`:
- Line 18: Add informational logging at the selected-tool dispatch boundary in
Pipeline.execute, recording non-error tool calls, and add an informational log
when a selected tool executes without producing chunks; preserve the existing
error logging for unknown executors and exceptions.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 6ecec06b-8ab1-4349-aa95-bb53851031e5
📒 Files selected for processing (1)
rag/advanced_rag/harness/config.py
| max_agent_cycles=0, | ||
| max_parallel_agents=1, | ||
| available_tools=["hybrid_search"], | ||
| available_tools=["hybrid_search", "web_search", "bm25_search"], |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C 8 'available_tools|web_search|bm25_search|requires_agent_loop|logger|logging' --glob '*.py' .Repository: infiniflow/ragflow
Length of output: 50375
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== locate config.py candidates =="
fd -a '^config\.py$' . | sed 's#^\./##' | rg 'rag/advanced_rag/harness/config.py|advanced_rag|dispatcher|harness' || true
echo "== inspect target config.py =="
if [ -f rag/advanced_rag/harness/config.py ]; then
nl -ba rag/advanced_rag/harness/config.py | sed -n '1,120p'
fi
echo "== focused search for dispatcher / modes / new tools =="
rg -n --glob '*.py' 'class .*Dispatcher|dispatcher|dispatch|requires_agent_loop|available_tools|hybrid_search|web_search|bm25_search|logger|logging\b' rag/advanced_rag rag/advanced_rag/harness || true
echo "== list advanced_rag harness =="
git ls-files rag/advanced_rag/harnessRepository: infiniflow/ragflow
Length of output: 315
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== inspect target config.py =="
awk '{printf "%6d\t%s\n", NR, $0}' rag/advanced_rag/harness/config.py | sed -n '1,140p'
echo "== focused search for dispatcher / modes / new tools =="
rg -n --glob '*.py' 'class .*Dispatcher|dispatcher|dispatch|requires_agent_loop|available_tools|hybrid_search|web_search|bm25_search|logger|logging\b' rag/advanced_rag rag/advanced_rag/harness || true
echo "== list advanced_rag harness files =="
git ls-files rag/advanced_rag/harnessRepository: infiniflow/ragflow
Length of output: 49112
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== orchestrator implementation =="
awk '{printf "%6d\t%s\n", NR, $0}' rag/advanced_rag/harness/orchestrator/__init__.py | sed -n '1,220p'
echo "== direct implementation =="
awk '{printf "%6d\t%s\n", NR, $0}' rag/advanced_rag/harness/orchestrator/direct.py | sed -n '1,80p'
echo "== tool pipeline implementation =="
awk '{printf "%6d\t%s\n", NR, $0}' rag/advanced_rag/harness/pipeline.py | sed -n '1,180p'
echo "== route implementation =="
awk '{printf "%6d\t%s\n", NR, $0}' rag/advanced_rag/harness/route.py | sed -n '1,220p'
echo "== inspecting logging calls in dispatching modules =="
python3 - <<'PY'
from pathlib import Path
for path in [
Path("rag/advanced_rag/harness/orchestrator/__init__.py"),
Path("rag/advanced_rag/harness/orchestrator/direct.py"),
Path("rag/advanced_rag/harness/pipeline.py"),
Path("rag/advanced_rag/harness/route.py"),
]:
text = path.read_text()
lines = text.splitlines()
print(f"\n--- {path} ---")
for i, line in enumerate(lines, 1):
l = line.strip()
if l.startswith(("logging.", "_LOG.", "print(")) or "selective" in l.lower() or "dispatch" in l.lower() or "tool" in l.lower() or "mode" in l.lower() or "available" in l.lower():
print(f"{i}: {l}")
PYRepository: infiniflow/ragflow
Length of output: 21348
Add logging at the tool execution boundary.
orchestrator_loop logs the selected strategy, and Pipeline.execute logs unknown/missing executors and exceptions, but selected tool execution is not logged. Add an info/log at dispatch for non-error selected calls, and an info/log for tools that run with no chunks.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@rag/advanced_rag/harness/config.py` at line 18, Add informational logging at
the selected-tool dispatch boundary in Pipeline.execute, recording non-error
tool calls, and add an informational log when a selected tool executes without
producing chunks; preserve the existing error logging for unknown executors and
exceptions.
Source: Coding guidelines
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
rag/llm/chat_model.py (1)
2002-2002: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd debug logging for the new marker-normalization path.
This change introduces a new tool-history rewrite path without a diagnostic event. Add a debug-level log with marker counts. Do not log the raw tool content.
As per coding guidelines, new Python flows must add logging.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@rag/llm/chat_model.py` at line 2002, Add a debug-level log in the tool-history rewrite path around the hist.append logic in chat_model.py so the new marker-normalization flow is observable. Update the nearby normalization branch to emit marker counts or other summary metrics from content processing, and keep the log free of raw tool content while preserving the existing append behavior.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@rag/llm/chat_model.py`:
- Line 2002: The tool-message normalization in the history append logic must
stop removing every </think> marker. Update the surrounding chat-model handling
to preserve valid closing markers, append only the missing number needed to
balance existing <think> markers, and keep nested markers balanced; add tests
covering complete, missing, and nested marker cases.
---
Nitpick comments:
In `@rag/llm/chat_model.py`:
- Line 2002: Add a debug-level log in the tool-history rewrite path around the
hist.append logic in chat_model.py so the new marker-normalization flow is
observable. Update the nearby normalization branch to emit marker counts or
other summary metrics from content processing, and keep the log free of raw tool
content while preserving the existing append behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 19d08382-c189-4447-8bc2-14a3dfdaf36f
📒 Files selected for processing (1)
rag/llm/chat_model.py
| else: | ||
| content = str(result) | ||
| hist.append({"role": "tool", "tool_call_id": tc.id, "content": content.replace("</think>", "")}) | ||
| hist.append({"role": "tool", "tool_call_id": tc.id, "content": content.replace("</think>", "") + ("</think>" if content.find("<think>") >= 0 else "")}) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Preserve valid closing markers and append only missing markers.
For content = "<think>reason</think>answer", this expression produces <think>reasonanswer</think>. It moves normal output into the reasoning section. Nested markers can also become unbalanced because all closing markers are removed and only one is appended.
Use marker-aware balancing. Preserve existing closing markers. Add tests for complete, missing, and nested marker cases.
Suggested normalization
- hist.append({"role": "tool", "tool_call_id": tc.id, "content": content.replace("</think>", "") + ("</think>" if content.find("<think>") >= 0 else "")})
+ missing_closers = max(0, content.count("<think>") - content.count("</think>"))
+ if missing_closers:
+ content += "</think>" * missing_closers
+ hist.append({"role": "tool", "tool_call_id": tc.id, "content": content})If marker text can occur as ordinary tool data, use a parser or escape that data before counting markers.
This matches the marker behavior covered by test/unit_test/common/test_think_stream_parser.py:257-270 and agent/component/agent_with_tools.py:130-134.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@rag/llm/chat_model.py` at line 2002, The tool-message normalization in the
history append logic must stop removing every </think> marker. Update the
surrounding chat-model handling to preserve valid closing markers, append only
the missing number needed to balance existing <think> markers, and keep nested
markers balanced; add tests covering complete, missing, and nested marker cases.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
rag/advanced_rag/knowlege_compile/wiki_incremental.py (1)
1672-1679: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd logging for the new wiki tokenization flow.
This flow adds tokenization but records no completion or output metadata. Add a structured debug log with safe metadata such as page version and field lengths. Do not log
content,page_title, or token text.As per coding guidelines,
**/*.py: Add logging for new flows.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@rag/advanced_rag/knowlege_compile/wiki_incremental.py` around lines 1672 - 1679, Add a structured debug log after the new tokenization flow completes, near rag_tokenizer.tokenize and embedding dimension derivation, recording safe metadata such as page version and content, summary, and tokenized-field lengths. Do not include content, page_title, or token text in the log, and use the module’s existing logger.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@rag/advanced_rag/knowlege_compile/wiki_incremental.py`:
- Around line 1672-1679: Add a structured debug log after the new tokenization
flow completes, near rag_tokenizer.tokenize and embedding dimension derivation,
recording safe metadata such as page version and content, summary, and
tokenized-field lengths. Do not include content, page_title, or token text in
the log, and use the module’s existing logger.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 95361a18-030b-412d-8d81-e805b73e4943
📒 Files selected for processing (1)
rag/advanced_rag/knowlege_compile/wiki_incremental.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #17862 +/- ##
=======================================
Coverage 90.65% 90.65%
=======================================
Files 10 10
Lines 717 717
Branches 118 118
=======================================
Hits 650 650
Misses 39 39
Partials 28 28 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Adjust ExecutionStrategy of THINKING_MODES.