Skip to content

Commit 50471d3

Browse files
committed
Deliver an async-tool result on its own once the user is answered
A result that lands after the model has already answered is delivered alone; the guidance used to have it re-answer the user first, which had the cascade frontend re-tell a joke before relaying the weather.
1 parent d81599b commit 50471d3

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fixed the async-tool guidance given to LLMs (`ASYNC_TOOL_INSTRUCTIONS` and the final-result message) so a result that lands after the model has already answered the user is delivered on its own, without the model repeating its previous reply first. The guidance now distinguishes a result arriving while the user has an unanswered request from one arriving on a run of its own.

src/pipecat/processors/aggregators/async_tool_messages.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,30 +96,32 @@
9696

9797
# Standing guidance composed into the system instruction whenever an async tool is
9898
# registered. The per-result message says the same thing, but it arrives buried in a
99-
# context whose most recent turn is the user asking for something else; a model
99+
# context whose most recent turn may be the user asking for something else; a model
100100
# weighing the two follows the nearer, louder request. This states the policy before
101101
# any result exists, so it is in force when one arrives.
102102
ASYNC_TOOL_INSTRUCTIONS = """ASYNC TOOLS:
103103
Some of your tools keep running after you have replied. Their results arrive later as \
104104
messages in the conversation, on whatever turn happens to be in progress by then.
105105
106106
A result that has arrived is owed to the user, whatever the conversation has moved on to. \
107-
Answer what the user just said first, then add the result at the end of that same reply — \
108-
never before your answer, and never as a reply of its own. State a short result outright; \
109-
for a long one, say what came back and offer the details. Say it once, and do not repeat \
110-
it in later replies."""
107+
If the user has said something you have not answered yet, answer that first, then add the \
108+
result at the end of that same reply — never before your answer. If you have already \
109+
answered everything the user said, deliver just the result — do not repeat or rephrase \
110+
your earlier reply. State a short result outright; for a long one, say what came back and \
111+
offer the details. Say it once, and do not repeat it in later replies."""
111112

112113
# Description shipped on the final-result message.
113114
_FINAL_DESCRIPTION = (
114115
"This is the final result for the asynchronous task associated with this "
115116
"tool_call_id. The task has completed. No further results will arrive for "
116117
"this tool_call_id. You must convey this result to the user, even if the "
117-
"conversation has moved on. Never leave it unsaid. First finish responding "
118-
"to whatever the user is talking about now, then deliver the result at the "
119-
"end of your response. How you deliver it depends on its size: if the "
120-
"result is short, simply state it; if it is long or complex, name what has "
121-
"come back and offer the details. Convey it once; do not repeat it in "
122-
"later responses."
118+
"conversation has moved on. Never leave it unsaid. If the user has said "
119+
"something you have not answered yet, first finish responding to that, "
120+
"then deliver the result at the end of your response; if you have already "
121+
"answered, deliver just the result and do not repeat your earlier reply. "
122+
"How you deliver it depends on its size: if the result is short, simply "
123+
"state it; if it is long or complex, name what has come back and offer "
124+
"the details. Convey it once; do not repeat it in later responses."
123125
)
124126

125127

0 commit comments

Comments
 (0)