Skip to content

feat(search-mcp): chat continues a conversation by chatId - #10438

Merged
waleedlatif1 merged 3 commits into
stagingfrom
feat/search-mcp-chat-followups
Nov 26, 2026
Merged

waleedlatif1 merged 3 commits into
stagingfrom
feat/search-mcp-chat-followups

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • MCP chat takes an optional chatId (from an earlier chat answer) and asks the follow-up in that conversation; the worker rehydrates the conversation's history from the chat ID, so the second answer builds on the first
  • A resumed chat must be the caller's own, in this organization, mothership type, not deleted, and in Assistant mode; anything else (another member's chat, another org, Agent/Plan chats, malformed IDs) is the same not-found before any work or billing
  • Each turn holds the per-chat stream lock (acquirePendingChatStream, no wait) inside the turn's try/finally, so a follow-up sent while the conversation is answering fails cleanly with conflict, and the lock is always released
  • A resumed conversation is never soft-deleted when its turn fails, and its chatId is returned even if this turn's transcript save failed
  • Tool description tells the client to pass the returned chatId for follow-ups; chatId has no uuid pattern in tools/list (validated server-side) to keep the schema small

Type of Change

  • New feature

Testing

  • chat.integration.ts (real Postgres + Redis): follow-up reuses the chat and appends to its transcript; another member's / other org's / deleted / Agent / malformed chat IDs are not found without running; a concurrent follow-up gets conflict and the lock frees after; a failed follow-up keeps an empty resumed chat
  • chat.test.ts, lib/knowledge/mcp tests; biome; check:api-validation:strict

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Nov 26, 2026 7:34pm UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 4 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; no actionable issues remain.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues remain.

Summary

Adds optional chatId support so MCP callers can continue a conversation.

  • Search MCP follow-ups continue the caller’s Assistant conversation.
  • A chat refuses another question while its current answer is running.

No new actionable issues were found. The earlier lock-expiry finding is addressed by starting the heartbeat and stopping it during cleanup.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[MCP chat request] --> B{chatId supplied?}
  B -->|Yes| C[Check owner, organization, type and mode]
  B -->|No| D[Create private chat]
  C --> E[Acquire chat lock]
  D --> E
  E -->|Busy| F[Return conflict]
  E -->|Acquired| G[Start heartbeat and run Assistant]
  G --> H[Append completed turn]
  H --> I[Return answer and chatId]
  G --> J[Always stop heartbeat and release lock]
  I --> J
Loading

Reviews (2) · Last reviewed commit: "fix(search-mcp): renew the chat lock thr..." · Reviewed by Greptile

@waleedlatif1
waleedlatif1 force-pushed the feat/search-mcp-chat-followups branch from 222b231 to 5544a30 Compare November 26, 2026 19:34
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit faef297 into staging Nov 26, 2026
84 checks passed
@waleedlatif1
waleedlatif1 deleted the feat/search-mcp-chat-followups branch November 26, 2026 21:31

This branch was previously deployed

1 inactive deployment
Preview — 5544a307 Deployed Nov 26, 2026 by vercel[bot]
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