Skip to content

fix(search): stop double-counting fail_count so DeepSearch terminates… - #17

Open
QingCheng24 wants to merge 1 commit into
openJiuwen-ai:mainfrom
QingCheng24:fix/search-fail-count-double-count
Open

fix(search): stop double-counting fail_count so DeepSearch terminates…#17
QingCheng24 wants to merge 1 commit into
openJiuwen-ai:mainfrom
QingCheng24:fix/search-fail-count-double-count

Conversation

@QingCheng24

@QingCheng24 QingCheng24 commented Jul 23, 2026

Copy link
Copy Markdown

Paired: GitHub #17GitCode !324

What type of PR is this?

/kind bug

What does this PR do / why do we need it:

  • Fix a double-counting bug in the DeepSearch action loop that made the agent terminate far too early.
  • Each state_creation sub-workflow was invoked with the parent's cumulative fail_count (workflow.py), and the sub-workflow increments it by 1 on a failed action (algorithm/search_nodes/utils.py). The parent then added that already-cumulative value back with +=, re-adding the base every iteration and compounding under parallel workers. As a result self.fail_count >= fail_limit tripped much earlier than intended, and the agent returned FAIL_LIMIT with a missing or low-quality answer.
  • Fix by making the accounting a per-action delta:
    • pass fail_count=0 into each sub-workflow, so it reports only its own 0/1 increment rather than echoing back the running total;
    • accumulate that delta with a default of 0 (the previous default of self.fail_count doubled the counter whenever the key was absent).
  • The intended contract is unchanged — fail_limit still means "terminate after N failed actions"; this PR makes the counter actually honor it.

Which issue(s) this PR fixes:

N/A (no tracked issue)

What scenarios were tested, and what were the verification results (Function, performance, reliability, etc.):

  • Function / Reliability — New integration regression test test_fail_count_accumulates_one_per_failed_action in tests/search_agent/test_integration_search_loop.py. It mirrors the real sub-workflow contract (returns the passed-in fail_count + 1 inside config) and asserts that with fail_limit=3 the loop needs exactly 3 failed actions to terminate, that agent.fail_count == 3, and that each sub-workflow is handed a delta base of 0.
  • Bug reproduction confirmed — With the fix temporarily reverted, the new test fails: termination fires after only 2 failed actions (config shows fail_count jumping 1 -> 2 -> limit). With the fix in place it passes.
  • Regression / no side effects:
    • pytest tests/search_agent/test_integration_search_loop.py -> 5 passed.
    • Full tests/search_agent run -> passing (1 pre-existing failure test_simple_react_telemetry_uses_built_tool_map, confirmed failing on clean main, unrelated to this PR).
    • python -m compileall openjiuwen_deepsearch server -> clean.
  • Performance — No impact.

Self-checklist:

    • Design: Has the solution corresponding to the PR been reviewed by the Maintainer, and have all review comments been replied to and revised
    • Test: Has the code in the PR been fully covered by UT/ST test cases, and have the newly added test cases been uploaded to the repository along with this PR or already uploaded.
    • Verification: Does the PR description contains a detailed description of the verification results regarding the achievement of the expected goals for the Feature, Refactor, and Bugfix to this PR.
    • Interface: Does it involve changes to external interfaces? (No external interface / public SDK / API changes; only internal loop accounting.)
    • Document: Does it involve modifications to the official website documentation? (No — fail_limit semantics are unchanged; this restores the intended behavior.)

@CLAassistant

CLAassistant commented Jul 23, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@openjiuwen-ci-bot

Copy link
Copy Markdown

Hi @QingCheng24, thanks for your contribution!

This pull request is currently waiting for the CLA Assistant check to pass before the CI process can continue.

Please follow the signing link shown by CLA Assistant on this PR. If you have already signed the CLA but the check is still failing, please make sure that all email addresses used in your commits are added to and verified on your GitHub account.

After updating your email settings or signing the CLA, please click Recheck in the CLA Assistant comment/check so the status can be refreshed.

Once the CLA Assistant check passes, CI will continue automatically.

@openjiuwen-collaboration-bot

Copy link
Copy Markdown

head_sha: 15a9a64d6fceff00c5e94e30b3a27a07e317d0e4

任务名称 结果 日志操作
静态检查 ❌FAILED 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
UT测试 ❌FAILED 点此跳转
ST测试 N/A N/A
build 编译包 N/A N/A
ruff codecheck ✅SUCCESS N/A

… on time

Each state_creation sub-workflow was invoked with the parent's cumulative
fail_count (workflow.py) and increments it by 1 on a failed action
(algorithm/search_nodes/utils.py). The parent then added that already-
cumulative value back with `+=`, re-adding the base every iteration and
compounding under parallel workers. With fail_limit reached far too early,
the agent returned FAIL_LIMIT with a missing or low-quality answer.

Fix by making the accounting a per-action delta:
- pass fail_count=0 into each sub-workflow, so it reports only its own
  0/1 increment rather than echoing back the running total;
- accumulate that delta with a default of 0 (the previous default of
  self.fail_count doubled the counter whenever the key was absent).

Adds an integration regression test that mirrors the real sub-workflow
contract; with fail_limit=3 it now requires 3 failed actions to terminate
(the bug terminated after 2).
@QingCheng24
QingCheng24 force-pushed the fix/search-fail-count-double-count branch from 15a9a64 to ea449ef Compare August 7, 2026 12:36
@openjiuwen-collaboration-bot

Copy link
Copy Markdown

head_sha: ea449efc9340fca4369170def2b9e15a8e092e02

任务名称 结果 日志操作
静态检查 ✅SUCCESS 点此跳转
防投毒检查 ✅SUCCESS 点此跳转
开源合规检查 ✅SUCCESS 点此跳转
UT测试 ✅SUCCESS 点此跳转
ST测试 N/A N/A
build 编译包 N/A N/A
ruff codecheck ✅SUCCESS N/A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants