Skip to content

feat: skip segmented reply after agent tool use - #10176

Open
iuiu-py wants to merge 1 commit into
AstrBotDevs:masterfrom
iuiu-py:feat/skip-segmentation-after-tool-use
Open

iuiu-py wants to merge 1 commit into
AstrBotDevs:masterfrom
iuiu-py:feat/skip-segmentation-after-tool-use

Conversation

@iuiu-py

@iuiu-py iuiu-py commented Sep 21, 2026

Copy link
Copy Markdown

Motivation

Fixes #9305

When an agent run uses a tool, the completed final response can still be split by segmented reply into many platform messages. This is especially problematic on message-limited platforms because the final answer loses its original sentence grouping.

Modifications / 改动点

  • Added skip_segmentation to MessageEventResult.

  • Marked only the completed final result after a tool call so intermediate model output remains segmentable.

  • Honored the flag in ResultDecorateStage and RespondStage to preserve the final response as one message.

  • Kept the result content type as LLM_RESULT, so existing content-safety and TTS behavior remains unchanged.

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果

  • uv run pytest -q tests/test_astr_agent_run_util.py tests/test_qqofficial_group_message_create.py: 32 passed.
  • uv run pytest -q: 3528 passed, 82 skipped.
  • uv run ruff format --check .: passed.
  • uv run ruff check .: passed.
  • git diff --check: passed.

Checklist / 检查清单

  • If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
  • My changes have been well-tested, and verification results have been provided above.
  • I checked the affected WebUI instructions and screenshots; no documentation update is needed because this adds no user-facing configuration or navigation change.
  • I have ensured that no new dependencies are introduced.
  • My changes do not introduce malicious code.

Summary by Sourcery

Keep completed agent responses intact after tool calls by bypassing segmented reply processing only for the final result.

Bug Fixes:

  • Preserve an agent’s completed final response as a single platform message after tool usage instead of applying segmented reply splitting.

Enhancements:

  • Add result-level control for bypassing segmented replies while retaining the LLM result type and existing downstream behavior.
  • Ensure only the final result after a tool call skips segmentation, while intermediate model output remains segmentable.

Tests:

  • Add coverage for marking only the final post-tool result and preserving it through response decoration and delivery decisions.

@sourcery-ai sourcery-ai 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.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]Agent调用工具后的回复应跳过断句

1 participant