Repository navigation
🪡 fix: Persist and Continue Stored Responses - #15683
dustinhealy wants to merge 15 commits into
Conversation
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: cf32c5e4f3
ℹ️ 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".
There was a problem hiding this comment.
🔵 Needs a closer look
getResponse currently maps read_only resolutions to a 404, which is misleading and inconsistent with the controller’s 409 handling for the same condition elsewhere.
Pull request overview
Fixes Responses API history persistence and retrieval by ensuring stored responses are linked to the correct UUID conversation, resolving resp_* IDs through the owning assistant message, and filtering/branch-selecting retained history for retrieval and continuation.
Changes:
- Add retention-aware visibility checks and apply retention filters when loading/storing Responses history.
- Introduce a persistence helper to resolve response IDs → canonical conversation + select the correct message branch for continuation.
- Update the legacy
/apiResponses controller to persist input/output with authenticated context, link parent chains, append message ObjectIds to the conversation, and expand test coverage (including MongoDB-memory integration).
File summaries
| File | Description |
|---|---|
| packages/data-schemas/src/utils/retention.ts | Adds isRetentionVisible helper to mirror retention visibility rules in code paths that need in-memory checks. |
| packages/api/src/agents/responses/persistence.ts | New resolver/selector utilities for mapping resp_* IDs to UUID conversations and selecting the correct history branch. |
| packages/api/src/agents/responses/persistence.spec.ts | Unit coverage for resolution rules and history branch selection behavior. |
| packages/api/src/agents/responses/persistence.database.spec.ts | MongoDB-memory coverage for tenant scoping and retention visibility constraints in resolution. |
| packages/api/src/agents/responses/index.ts | Re-exports new persistence utilities for use by the legacy controller layer. |
| api/server/controllers/agents/responses.js | Uses persistence utilities; fixes continuation conversation ID selection; links parentMessageId chain; appends message refs; applies retention filters. |
| api/server/controllers/agents/tests/responses.unit.spec.js | Updates mocks + adds regression/integration tests for persistence, retrieval by response ID, and continuation behavior. |
Review details
Suppressed comments (1)
api/server/controllers/agents/responses.js:1777
getResponsetreatsresolveStoredResponseresults other thanfoundas 404, which also includes theread_onlycase (child thread). That makes the error misleading and inconsistent withcreateResponse, which returns a 409conversation_read_onlyfor the same condition.
if (resolution.status !== 'found') {
return sendResponsesErrorResponse(
res,
404,
`Response not found: ${responseId}`,
- Files reviewed: 7/7 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 173a8685e4
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 54eb53a5ae
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d8521cf7b0
ℹ️ 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. 👍 Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: acde433615
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 37f5ac2321
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4cc0c63aef
ℹ️ 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".
4cc0c63 to
7179189
Compare
e7616b4 to
0f35405
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0f35405ad4
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f748aa9f1b
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 08eec5b00f
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b47172e243
ℹ️ 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
|
Closing this for now while I evaluate alternative approaches that may address the underlying persistence issues without the substantial refactor this PR requires. The behavior still needs fixing, but I’d like to settle the broader direction before moving this implementation forward. |
Summary
Requests to
/api/agents/v1/responseswithstore: truecould return success while saving an empty conversation, and the returnedresp_*ID could not be used to retrieve or continue it. Stored turns now retain their agent association and linked messages; retrieval returns the original completed response, and continuation restores the selected branch through the authenticated owner's response ID.Fixes #14466.
Documentation: librechat.ai PR #760. No new package or deployment dependencies are required.
How it works
persistStoredResponseowns turn publication. Shared message reads expose the turn only after its output marker commits, so a partial save cannot appear in history, search, shares, or insights.Response IDs resolve through the owner's generated output to its conversation. Continuation follows that output's parent chain; legacy UUID continuation selects the latest visible branch, while flat legacy history and earlier snapshots remain readable. Shared visibility uses DocumentDB-compatible joins and does not require MongoDB transactions.
Compatibility:
store: truecombined withisTemporary: truenow returns HTTP 400 before execution, because temporary conversations are excluded from response retrieval. A branched legacy UUID continuation now uses the latest branch instead of combining sibling branches. Persistence failures are reported instead of returning a successful stored response; streaming failures emitresponse.failedbefore[DONE].Change Type
Testing
549 focused tests passed, covering create/GET envelope equality, streamed completion, canonical and legacy continuation, tenant ownership, concurrent appends, failed and ambiguous writes, deletion, staged-row visibility, pagination, search projections, sharing, and limiter regression cases.
Run from the repository root after installing dependencies and building the workspaces:
The full application build, shared-package typecheck, scoped ESLint/Prettier/import checks, and Lighthouse passed locally. CI at
5de9d1c6fchas 30 passing checks and two intentional skips, including TypeScript, API/shared tests, E2E, integration tests, Lighthouse, and container smoke tests. The local API typecheck reports a Langfuse dependency diagnostic in an unchanged file; CI's TypeScript job passes.Test Configuration:
mongodb-memory-serverand require local socket access; no live model provider is needed.Checklist