mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-08-11 21:30:59 +00:00
fix(longtext): avoid split interfering with multi-chain agent responses
Use query variable '_longtext_split_extra_chains' to pass extra split segments instead of appending to resp_message_chain directly. This prevents agent tool-call multi-round responses from being misidentified as split results and sent repeatedly. respback.py reverts to original single-chain logic and appends split extra chains after the main response.
This commit is contained in:
@@ -97,10 +97,15 @@ class LongTextProcessStage(stage.PipelineStage):
|
||||
original_text = str(query.resp_message_chain[-1])
|
||||
threshold = query.pipeline_config['output']['long-text-processing']['threshold']
|
||||
segments = self.strategy_impl.split_text(original_text, threshold)
|
||||
query.resp_message_chain.pop()
|
||||
for segment in segments:
|
||||
query.resp_message_chain.append(
|
||||
platform_message.MessageChain([platform_message.Plain(text=segment)])
|
||||
# Replace the last chain with the first segment, store extra segments separately
|
||||
# to avoid interfering with existing multi-chain scenarios (e.g. agent tool calls)
|
||||
query.resp_message_chain[-1] = platform_message.MessageChain(
|
||||
[platform_message.Plain(text=segments[0])]
|
||||
)
|
||||
if len(segments) > 1:
|
||||
query.set_variable(
|
||||
'_longtext_split_extra_chains',
|
||||
[platform_message.MessageChain([platform_message.Plain(text=seg)]) for seg in segments[1:]],
|
||||
)
|
||||
else:
|
||||
query.resp_message_chain[-1] = platform_message.MessageChain(
|
||||
|
||||
Reference in New Issue
Block a user