fix: record message confirmations in context
This commit is contained in:
@@ -43,6 +43,7 @@ from services.message_stage import (
|
||||
MessageDisplaySpec,
|
||||
MessageStageRunner,
|
||||
MessageStageSpec,
|
||||
confirmation_context_message,
|
||||
)
|
||||
from services.runtime_variables import DynamicVariableError, DynamicVariableStore
|
||||
from services.system_tools import state_update_properties, system_tool_kind
|
||||
@@ -226,8 +227,12 @@ class PromptBrain(BaseBrain):
|
||||
self.prepare_greeting_context(speech, runtime.context)
|
||||
try:
|
||||
if opening_message is not None:
|
||||
message_spec = self._opening_message_stage_spec(
|
||||
speech,
|
||||
opening_message,
|
||||
)
|
||||
message_result = await self._message_stages.run(
|
||||
self._opening_message_stage_spec(speech, opening_message),
|
||||
message_spec,
|
||||
speak=self._speak_opening,
|
||||
set_input_enabled=runtime.set_input_enabled,
|
||||
input_already_blocked=self._opening_input_blocked,
|
||||
@@ -241,6 +246,12 @@ class PromptBrain(BaseBrain):
|
||||
message_result.error or "开场消息显示失败"
|
||||
)
|
||||
return
|
||||
context_message = confirmation_context_message(
|
||||
message_result,
|
||||
source="prompt-opening",
|
||||
)
|
||||
if context_message is not None:
|
||||
runtime.context.add_message(context_message)
|
||||
|
||||
if opening_actions:
|
||||
result = await self._action_stages.run(
|
||||
|
||||
@@ -58,6 +58,7 @@ from services.message_stage import (
|
||||
MessageStageResult,
|
||||
MessageStageRunner,
|
||||
MessageStageSpec,
|
||||
confirmation_context_message,
|
||||
)
|
||||
from services.runtime_variables import DynamicVariableError, DynamicVariableStore
|
||||
from services.system_tools import state_update_properties, system_tool_kind
|
||||
@@ -1421,6 +1422,12 @@ class WorkflowBrain(BaseBrain):
|
||||
context_message = fixed_speech_context_message(result.speech)
|
||||
if context_message is not None:
|
||||
context_messages.append(context_message)
|
||||
confirmation_message = confirmation_context_message(
|
||||
result,
|
||||
source=f"workflow-message:{continuation.node_id}",
|
||||
)
|
||||
if confirmation_message is not None:
|
||||
context_messages.append(confirmation_message)
|
||||
|
||||
if not self._engine.has_outgoing(continuation.node_id):
|
||||
self._state.enter(
|
||||
|
||||
Reference in New Issue
Block a user