Skip to content

📌 fix: Preserve Ephemeral Agent Selections on Optimistic Hydration - #13433

Merged
danny-avila merged 1 commit into
devfrom
danny-avila/fix-ephemeral-agent-mcp-selection
May 31, 2026
Merged

danny-avila merged 1 commit into
devfrom
danny-avila/fix-ephemeral-agent-mcp-selection

Conversation

@danny-avila

Copy link
Copy Markdown
Collaborator

Summary

I fixed the new-chat optimistic update path so explicit ephemeral agent selections survive when a generated conversation receives its persisted conversation ID.

  • Preserved an explicit ephemeralAgent when useApplyNewAgentTemplate is asked to apply state to the same conversation ID after optimistic hydration.
  • Kept the existing same-ID short circuit for cases that do not provide an explicit ephemeral agent, so the helper still avoids pointless self-copy reads.
  • Added a focused regression test covering MCP selections and the other ephemeral agent flags carried by the same state object.

Root cause: resumable SSE optimistic hydration updates the submission to the persisted conversation ID before created/final applies the ephemeral agent template. That made sourceId and targetId match, so the helper skipped writing the request-time ephemeralAgent into the saved conversation state.

Change Type

  • Bug fix (non-breaking change which fixes an issue)

Testing

  • Ran git diff --check
  • Did not run local tests per request

Test Configuration:

  • Local worktree: /Users/danny/.codex/worktrees/99d4/LibreChat

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • I have written tests demonstrating that my changes are effective or that my feature works

Copilot AI review requested due to automatic review settings May 31, 2026 20:07

Copy link
Copy Markdown
Collaborator Author

@codex review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes an edge case in the client’s ephemeral-agent state hydration: when optimistic new-chat hydration updates the submission to a persisted conversation ID before the agent template is applied, useApplyNewAgentTemplate no longer drops an explicitly provided ephemeralAgent due to a same-ID short-circuit.

Changes:

  • Adjusted the same-source/target guard in useApplyNewAgentTemplate to only short-circuit when no explicit ephemeralAgentState is provided.
  • Added a regression test ensuring explicit ephemeral agent selections (including MCP + tool flags) are preserved even when source and target conversation IDs match.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
client/src/store/agents.ts Updates same-ID short-circuit to still apply explicitly provided ephemeral agent state.
client/src/store/tests/agents.spec.tsx Adds regression test covering same-ID optimistic hydration with explicit ephemeral agent state.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

ℹ️ 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".

@github-actions

Copy link
Copy Markdown
Contributor

GitNexus: 🚀 deployed

The LibreChat-pr-13433 index is now live on the MCP server.
Deploy run

@danny-avila danny-avila changed the title 🧷 fix: Preserve Ephemeral Agent Selections 📌 fix: Preserve Ephemeral Agent Selections on Optimistic Hydration May 31, 2026
@danny-avila
danny-avila changed the base branch from main to dev May 31, 2026 20:27
@danny-avila
danny-avila marked this pull request as ready for review May 31, 2026 20:27
@danny-avila
danny-avila merged commit fd5d441 into dev May 31, 2026
10 checks passed
@danny-avila
danny-avila deleted the danny-avila/fix-ephemeral-agent-mcp-selection branch May 31, 2026 20:32
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.

2 participants