Skip to content

fix(agent): avoid literal null chat output#38287

Merged
zyssyz123 merged 1 commit into
feat/agent-v2from
fix/dify-2666-null-chat-output
Jul 2, 2026
Merged

fix(agent): avoid literal null chat output#38287
zyssyz123 merged 1 commit into
feat/agent-v2from
fix/dify-2666-null-chat-output

Conversation

@zyssyz123

Copy link
Copy Markdown
Contributor

Summary

  • Avoid exposing literal null when Agent backend terminal output is null.
  • Preserve already streamed assistant text as the final message content when terminal output is empty/null.
  • Add Agent App runner regression tests for both null-output paths.

Testing

  • PYTHONPATH=/tmp/dify-no-readline uv run pytest tests/unit_tests/core/app/apps/agent_app -q (81 passed)
  • Deployed to deploy/agent (f83cce3846) and verified on https://agent.dify.dev:
    • Created Agent Roster app through /console/api/agent
    • Checked out and saved build draft with model/prompt
    • Ran Build/Preview chat with draft_type=debug_build
    • Applied build draft and published
    • Ran published Agent chat
    • Confirmed streaming responses and /chat-messages history do not contain literal null

@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label Jul 2, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → PR
--- /tmp/pyrefly_base.txt	2026-07-02 03:05:48.076983650 +0000
+++ /tmp/pyrefly_pr.txt	2026-07-02 03:05:38.481948688 +0000
@@ -3230,19 +3230,23 @@
 ERROR Argument `DummyAccount` is not assignable to parameter `user` with type `Account | EndUser` in function `core.app.apps.agent_app.app_generator.AgentAppGenerator._run_stateless` [bad-argument-type]
    --> tests/unit_tests/core/app/apps/agent_app/test_app_generator.py:258:18
 ERROR Object of class `NoneType` has no attribute `message` [missing-attribute]
-   --> tests/unit_tests/core/app/apps/agent_app/test_app_runner.py:362:12
+   --> tests/unit_tests/core/app/apps/agent_app/test_app_runner.py:402:12
 ERROR Object of class `NoneType` has no attribute `model` [missing-attribute]
-   --> tests/unit_tests/core/app/apps/agent_app/test_app_runner.py:363:12
+   --> tests/unit_tests/core/app/apps/agent_app/test_app_runner.py:403:12
 ERROR Object of class `NoneType` has no attribute `message` [missing-attribute]
-   --> tests/unit_tests/core/app/apps/agent_app/test_app_runner.py:396:12
+   --> tests/unit_tests/core/app/apps/agent_app/test_app_runner.py:436:12
 ERROR Object of class `NoneType` has no attribute `usage` [missing-attribute]
-   --> tests/unit_tests/core/app/apps/agent_app/test_app_runner.py:397:12
+   --> tests/unit_tests/core/app/apps/agent_app/test_app_runner.py:437:12
 ERROR Object of class `NoneType` has no attribute `usage` [missing-attribute]
-   --> tests/unit_tests/core/app/apps/agent_app/test_app_runner.py:398:12
+   --> tests/unit_tests/core/app/apps/agent_app/test_app_runner.py:438:12
 ERROR Object of class `NoneType` has no attribute `usage` [missing-attribute]
-   --> tests/unit_tests/core/app/apps/agent_app/test_app_runner.py:399:12
+   --> tests/unit_tests/core/app/apps/agent_app/test_app_runner.py:439:12
 ERROR Object of class `NoneType` has no attribute `message` [missing-attribute]
-   --> tests/unit_tests/core/app/apps/agent_app/test_app_runner.py:414:12
+   --> tests/unit_tests/core/app/apps/agent_app/test_app_runner.py:454:12
+ERROR Object of class `NoneType` has no attribute `message` [missing-attribute]
+   --> tests/unit_tests/core/app/apps/agent_app/test_app_runner.py:468:12
+ERROR Object of class `NoneType` has no attribute `message` [missing-attribute]
+   --> tests/unit_tests/core/app/apps/agent_app/test_app_runner.py:482:12
 ERROR Object of class `NoneType` has no attribute `message` [missing-attribute]
   --> tests/unit_tests/core/app/apps/agent_app/test_input_guards.py:67:12
 ERROR Object of class `NoneType` has no attribute `prompt_messages` [missing-attribute]

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 51.86% 51.86% +0.00%
Strict coverage 51.38% 51.38% +0.00%
Typed symbols 31,522 31,528 +6
Untyped symbols 29,533 29,535 +2
Modules 2952 2952 0

@zyssyz123 zyssyz123 merged commit 2f0ba0f into feat/agent-v2 Jul 2, 2026
4 checks passed
@zyssyz123 zyssyz123 deleted the fix/dify-2666-null-chat-output branch July 2, 2026 03:08
@lyzno1 lyzno1 mentioned this pull request Jul 2, 2026
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant