Skip to content
This repository was archived by the owner on Jul 22, 2026. It is now read-only.

Commit a278432

Browse files
zerone0xclaude
andauthored
Forward warning messages and compact notifications to client (#175)
After /compact runs, the client received no feedback — the LLM-driven summarization ran silently and only a stopReason notification arrived. This change improves the UX in two ways: 1. When a ContextCompaction TurnItem completes (or a ContextCompacted event fires), send an agent message "Context compacted" so users see explicit confirmation that the operation finished. 2. Forward Warning events as agent messages. Codex emits user-facing warnings in several situations (post-compact advisory, deprecated config notices, etc.). Previously they were only logged server-side; now clients receive them as session/update notifications. Fixes #164 Co-authored-by: Claude <noreply@anthropic.com>
1 parent e979e7c commit a278432

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/thread.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ use codex_protocol::{
4848
config_types::TrustLevel,
4949
custom_prompts::CustomPrompt,
5050
dynamic_tools::{DynamicToolCallOutputContentItem, DynamicToolCallRequest},
51+
items::TurnItem,
5152
mcp::CallToolResult,
5253
models::{ResponseItem, WebSearchAction},
5354
openai_models::{ModelPreset, ReasoningEffort},
@@ -637,6 +638,11 @@ impl PromptState {
637638
item,
638639
}) => {
639640
info!("Item completed: thread_id={}, turn_id={}, item={:?}", thread_id, turn_id, item);
641+
// Notify the client when context compaction completes so users see
642+
// a status message rather than silence during /compact.
643+
if matches!(item, TurnItem::ContextCompaction(..)) {
644+
client.send_agent_text("Context compacted".to_string()).await;
645+
}
640646
}
641647
EventMsg::TurnComplete(TurnCompleteEvent { last_agent_message, turn_id }) => {
642648
info!(
@@ -725,6 +731,9 @@ impl PromptState {
725731
}
726732
EventMsg::Warning(WarningEvent { message }) => {
727733
warn!("Warning: {message}");
734+
// Forward warnings to the client as agent messages so users see
735+
// informational notices (e.g., the post-compact advisory message).
736+
client.send_agent_text(message).await;
728737
}
729738
EventMsg::McpStartupUpdate(McpStartupUpdateEvent { server, status }) => {
730739
info!("MCP startup update: server={server}, status={status:?}");
@@ -750,14 +759,18 @@ impl PromptState {
750759
info!("Model reroute: from={from_model}, to={to_model}, reason={reason:?}");
751760
}
752761

762+
EventMsg::ContextCompacted(..) => {
763+
info!("Context compacted");
764+
client.send_agent_text("Context compacted".to_string()).await;
765+
}
766+
753767
// Ignore these events
754768
EventMsg::AgentReasoningRawContent(..)
755769
| EventMsg::ThreadRolledBack(..)
756770
// we already have a way to diff the turn, so ignore
757771
| EventMsg::TurnDiff(..)
758772
// Revisit when we can emit status updates
759773
| EventMsg::BackgroundEvent(..)
760-
| EventMsg::ContextCompacted(..)
761774
| EventMsg::SkillsUpdateAvailable
762775
// Old events
763776
| EventMsg::AgentMessageDelta(..)

0 commit comments

Comments
 (0)