mirror of
https://github.com/openai/codex.git
synced 2026-09-09 15:58:47 +00:00
Avoid realtime final answer progress echo
This commit is contained in:
@@ -107,6 +107,7 @@ use codex_protocol::items::UserMessageItem;
|
||||
use codex_protocol::items::build_hook_prompt_message;
|
||||
use codex_protocol::mcp::CallToolResult;
|
||||
use codex_protocol::models::BaseInstructions;
|
||||
use codex_protocol::models::MessagePhase;
|
||||
use codex_protocol::models::PermissionProfile;
|
||||
use codex_protocol::models::format_allow_prefixes;
|
||||
use codex_protocol::openai_models::ModelInfo;
|
||||
@@ -2935,10 +2936,14 @@ impl Session {
|
||||
}
|
||||
|
||||
async fn maybe_clear_realtime_handoff_for_event(&self, msg: &EventMsg) {
|
||||
if !matches!(msg, EventMsg::TurnComplete(_)) {
|
||||
let EventMsg::TurnComplete(event) = msg else {
|
||||
return;
|
||||
}
|
||||
if let Err(err) = self.conversation.handoff_complete().await {
|
||||
};
|
||||
if let Err(err) = self
|
||||
.conversation
|
||||
.handoff_complete(event.last_agent_message.clone())
|
||||
.await
|
||||
{
|
||||
debug!("failed to finalize realtime handoff output: {err}");
|
||||
}
|
||||
self.conversation.clear_active_handoff().await;
|
||||
@@ -7349,7 +7354,12 @@ fn realtime_text_for_event(msg: &EventMsg) -> Option<String> {
|
||||
match msg {
|
||||
EventMsg::AgentMessage(event) => Some(event.message.clone()),
|
||||
EventMsg::ItemCompleted(event) => match &event.item {
|
||||
TurnItem::AgentMessage(item) => Some(agent_message_text(item)),
|
||||
TurnItem::AgentMessage(item)
|
||||
if item.phase.as_ref() != Some(&MessagePhase::FinalAnswer) =>
|
||||
{
|
||||
Some(agent_message_text(item))
|
||||
}
|
||||
TurnItem::AgentMessage(_) => None,
|
||||
_ => None,
|
||||
},
|
||||
EventMsg::Error(_)
|
||||
|
||||
@@ -448,7 +448,10 @@ impl RealtimeConversationManager {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn handoff_complete(&self) -> CodexResult<()> {
|
||||
pub(crate) async fn handoff_complete(
|
||||
&self,
|
||||
final_output_text: Option<String>,
|
||||
) -> CodexResult<()> {
|
||||
let handoff = {
|
||||
let guard = self.state.lock().await;
|
||||
guard.as_ref().map(|state| state.handoff.clone())
|
||||
@@ -464,10 +467,20 @@ impl RealtimeConversationManager {
|
||||
let Some(handoff_id) = handoff.active_handoff.lock().await.clone() else {
|
||||
return Ok(());
|
||||
};
|
||||
let Some(output_text) = handoff.last_output_text.lock().await.clone() else {
|
||||
return Ok(());
|
||||
let output_text = match final_output_text {
|
||||
Some(output_text) => output_text,
|
||||
None => {
|
||||
let Some(output_text) = handoff.last_output_text.lock().await.clone() else {
|
||||
return Ok(());
|
||||
};
|
||||
output_text
|
||||
}
|
||||
};
|
||||
|
||||
if output_text.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
handoff
|
||||
.output_tx
|
||||
.send(HandoffOutput::FinalUpdate {
|
||||
|
||||
Reference in New Issue
Block a user