Skip to content

[Bug]: Workflow agent completions default stream=True when stream is omitted - #15484

Merged
yuzhichang merged 2 commits into
infiniflow:mainfrom
glorysr1209-png:fix/workflow-stream-default-false
Jul 6, 2026
Merged

yuzhichang merged 2 commits into
infiniflow:mainfrom
glorysr1209-png:fix/workflow-stream-default-false

Conversation

@glorysr1209-png

Copy link
Copy Markdown
Contributor

Summary

Closes #15483.

Default workflow/session agent completions to non-streaming when stream is omitted.

Changes

  • api/apps/restful_apis/agent_api.py: req.get("stream", False) on workflow paths.

Test plan

  • POST workflow completion without stream; assert JSON response.

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Jun 1, 2026
@coderabbitai

coderabbitai Bot commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR changes agent completion handling so workflow-session and non-session paths default to non-streaming: stream now defaults to False when omitted, causing JSON responses instead of SSE unless stream: true is provided.

Changes

Workflow Completion Streaming Defaults

Layer / File(s) Summary
Default stream parameter handling in workflow completions
api/apps/restful_apis/agent_api.py
Workflow-session and non-session completion paths now default the stream argument to False and use req.get("stream", False) to decide SSE vs JSON responses.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • infiniflow/ragflow#15394: Both PRs change default streaming behavior for chat-completion endpoints when stream is omitted.
  • infiniflow/ragflow#14596: Adjusts agent_chat_completion streaming vs non-streaming selection; overlaps with this change.

Suggested labels

🐖api, 🌈 python

Suggested reviewers

  • wangq8
  • yingfeng
  • yuzhichang

Poem

🐰 I hopped through code at break of day,
Changing stream to False along the way,
No SSE surprise when callers forget,
JSON answers now — a tidy reset.
Hooray! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main bug fix - changing the default stream behavior for workflow agent completions from True to False.
Description check ✅ Passed The description follows the template with a clear summary, identifies the linked issue, and includes changes and test plan sections.
Linked Issues check ✅ Passed The PR changes directly address issue #15483 by modifying workflow agent completion paths to default stream to False, aligning with OpenAI-compatible endpoint behavior.
Out of Scope Changes check ✅ Passed All changes are scoped to the workflow agent completion endpoints mentioned in the linked issue, with no unrelated modifications present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
api/apps/restful_apis/agent_api.py (1)

450-499: ⚡ Quick win

Add audit logs for the new bulk-delete session flow.

This new destructive path has no entry/result logs, which makes support/audit of partial deletes and delete_all actions harder.

Proposed patch
 async def delete_agent_session(tenant_id, agent_id):
+    logging.info("delete_agent_session requested: tenant_id=%s agent_id=%s", tenant_id, agent_id)
     errors = []
     success_count = 0
     req = await get_request_json()
@@
     if not ids:
         if req.get("delete_all") is True:
             ids = [conv.id for conv in await thread_pool_exec(API4ConversationService.query, dialog_id=agent_id)]
+            logging.info(
+                "delete_agent_session delete_all resolved: tenant_id=%s agent_id=%s ids_count=%d",
+                tenant_id, agent_id, len(ids)
+            )
             if not ids:
                 return get_result()
@@
     if errors:
+        logging.warning(
+            "delete_agent_session partial/failed: tenant_id=%s agent_id=%s success_count=%d error_count=%d",
+            tenant_id, agent_id, success_count, len(errors)
+        )
         if success_count > 0:
@@
     if duplicate_messages:
+        logging.info(
+            "delete_agent_session duplicates: tenant_id=%s agent_id=%s success_count=%d duplicate_count=%d",
+            tenant_id, agent_id, success_count, len(duplicate_messages)
+        )
         if success_count > 0:
@@
+    logging.info(
+        "delete_agent_session completed: tenant_id=%s agent_id=%s success_count=%d",
+        tenant_id, agent_id, success_count
+    )
     return get_result()

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 `@api/apps/restful_apis/agent_api.py` around lines 450 - 499, The
delete_agent_session flow lacks audit logging; add structured audit logs via the
existing logger when the bulk-delete starts (include tenant_id, agent_id,
requested ids or delete_all flag and duplicate detection results from
check_duplicate_ids), log each attempted deletion (session_id, outcome
success/failure, and error message) around the
API4ConversationService.delete_by_id call, and emit a final summary log
recording success_count, errors, and whether delete_all was used; reference
delete_agent_session, get_request_json, check_duplicate_ids,
API4ConversationService.delete_by_id and UserCanvasService.query to locate the
spots to insert start/per-session/final audit entries.
🤖 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 `@api/apps/restful_apis/agent_api.py`:
- Around line 450-499: The delete_agent_session flow lacks audit logging; add
structured audit logs via the existing logger when the bulk-delete starts
(include tenant_id, agent_id, requested ids or delete_all flag and duplicate
detection results from check_duplicate_ids), log each attempted deletion
(session_id, outcome success/failure, and error message) around the
API4ConversationService.delete_by_id call, and emit a final summary log
recording success_count, errors, and whether delete_all was used; reference
delete_agent_session, get_request_json, check_duplicate_ids,
API4ConversationService.delete_by_id and UserCanvasService.query to locate the
spots to insert start/per-session/final audit entries.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: be8f81a8-23c7-4f6c-95f4-42ee425e9e79

📥 Commits

Reviewing files that changed from the base of the PR and between d9977cb and 98375ae.

📒 Files selected for processing (1)
  • api/apps/restful_apis/agent_api.py

@yuzhichang yuzhichang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 6, 2026
@yuzhichang yuzhichang added the ci Continue Integration label Jul 6, 2026
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (5a04ac0) to head (98375ae).
⚠️ Report is 596 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15484      +/-   ##
==========================================
- Coverage   94.56%   93.16%   -1.40%     
==========================================
  Files          10       10              
  Lines         717      717              
  Branches      118      118              
==========================================
- Hits          678      668      -10     
- Misses         25       29       +4     
- Partials       14       20       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yuzhichang
yuzhichang merged commit 5a8660d into infiniflow:main Jul 6, 2026
7 checks passed
wangq8 added a commit that referenced this pull request Jul 7, 2026
Follow on this PR: #15484 it break the Agent chat
yuzhichang pushed a commit that referenced this pull request Jul 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Workflow agent completions default stream=True when stream is omitted

2 participants