Skip to content

Conversation

@ethanndickson
Copy link
Member

Problem

When using code_execution (PTC), nested tool calls (e.g., mux.bash(), mux.file_read()) didn't appear in the UI until they completed. Users expected to see "executing..." while long-running nested tools were in progress, just like regular top-level tool calls.

Root Cause

Two issues combined:

1. MessageId Mismatch

The backend was emitting nested tool events with the wrong messageId:

  • aiService.ts created assistantMessageId for history and the emitNestedEvent callback
  • streamManager.ts created a separate messageId for all stream events
  • Frontend aggregator looked up messages by messageId - nested events with assistantMessageId couldn't find the message stored under streamInfo.messageId
  • Events were silently dropped

2. React Reactivity

Even after fixing the messageId, the UI didn't update when nested tools completed:

  • handleToolCallEnd mutated nestedCall objects in place
  • React didn't detect changes because object references stayed the same
  • Fix: use immutable update pattern (create new array + new objects)

Solution

  1. Thread messageId through: Pass assistantMessageId from aiService.ts to streamManager.startStream() so both use the same ID

  2. Immutable updates: Replace in-place mutation with immutable update pattern in handleToolCallEnd

Testing

  • All existing tests pass
  • Manual testing confirms nested tools now show "executing..." and update to completed state in real-time

Generated with mux • Model: anthropic:claude-opus-4-5 • Thinking: high

Two fixes for code_execution (PTC) nested tool call display:

1. MessageId mismatch: aiService and streamManager were generating
   separate messageIds. Nested tool events used aiService's ID but
   the stream used streamManager's ID, so the frontend aggregator
   couldn't find the message to attach nested calls to. Fix: pass
   assistantMessageId from aiService to streamManager.startStream().

2. React reactivity: handleToolCallEnd mutated nestedCalls objects
   in place, so React didn't detect changes. Fix: use immutable
   update pattern (new array + new objects) to ensure re-renders.
@ethanndickson
Copy link
Member Author

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Delightful!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@ethanndickson ethanndickson added this pull request to the merge queue Dec 30, 2025
@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Nice work!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Merged via the queue into main with commit cdd438b Dec 30, 2025
20 checks passed
@ethanndickson ethanndickson deleted the code-execution-rge2 branch December 30, 2025 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant