Repository navigation
[Bug]: Workflow agent completions default stream=True when stream is omitted - #15484
yuzhichang merged 2 commits into
Conversation
📝 WalkthroughWalkthroughThe PR changes agent completion handling so workflow-session and non-session paths default to non-streaming: ChangesWorkflow Completion Streaming Defaults
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
api/apps/restful_apis/agent_api.py (1)
450-499: ⚡ Quick winAdd 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_allactions 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
📒 Files selected for processing (1)
api/apps/restful_apis/agent_api.py
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Follow on this PR: #15484 it break the Agent chat
Summary
Closes #15483.
Default workflow/session agent completions to non-streaming when
streamis omitted.Changes
api/apps/restful_apis/agent_api.py:req.get("stream", False)on workflow paths.Test plan
stream; assert JSON response.