RapidDraft Integration Strategy¶
Status: Architecture recommendation; not implemented or approved as the permanent product runtime.
RapidDraft should remain the user-facing engineering workspace and owner of CAD, Agent, artifact, approval, and viewer contracts. LibreChat can be evaluated as a replaceable runtime behind a RapidDraft-owned backend gateway.
Recommended product shape¶
flowchart LR
Engineer["Engineer"] --> RD["RapidDraft workspace"]
RD --> Viewer["CAD viewer"]
RD --> Panel["RapidDraft Agent panel"]
Panel --> Gateway["RapidDraft Agent gateway"]
Gateway --> Remote["LibreChat Remote Agent API"]
Remote --> RAG["LibreChat file_search / RAG"]
Remote --> MCP["Curated RapidDraft MCP gateway"]
MCP --> Services["Authorized CAD, DFM, CNC, vision, and review services"]
Services --> Artifact["Compact results and AnalysisFocusPayload"]
Artifact --> Gateway
Gateway --> Panel
Panel --> Viewer
The browser should never call LibreChat with a shared Remote Agent key. The RapidDraft gateway validates the user, tenant, model, and requested operation, then translates LibreChat runtime events into stable RapidDraft contracts.
Current and proposed state¶
| Capability | Current state | Proposed vertical slice |
|---|---|---|
| LibreChat standalone UI | Deployed | Retained as knowledge administration and testing surface |
| Private file-search Agents | Deployed | One private RapidDraft Agent exposed through gateway |
| Protected MCP tool | Bauer proof deployed | Curated read-only RapidDraft MCP gateway |
| Remote Agents API | Not enabled in testing configuration | Enable for the selected private Agent only |
| RapidDraft native Agent panel | Existing product direction | Stream gateway events in the RapidDraft rail |
| Shared identity | Not available | Server-side scoped identity exchange or account linking |
| Viewer action | AnalysisFocusPayload exists in RapidDraft |
Return clickable focus/isolate actions from Agent results |
| Mutation approval | Product contract only | Add after read-only slice succeeds |
Stable RapidDraft contracts¶
LibreChat-specific IDs and events remain behind the gateway. RapidDraft retains ownership of:
AgentThread;AgentRun;ContextSnapshot;ToolRegistry;AgentEventLog;ArtifactEnvelope;- approval and intervention events;
- visual-context and viewer-focus actions.
This keeps the product replaceable if LibreChat's API, data model, licensing, or operational fit changes.
Curated tool boundary¶
Start with domain operations, not transport-level API routes:
model.get_context
model.get_current_selection
model.get_part_facts
model.list_components
model.resolve_selection
dfm.run_review
dfm.get_job_status
cnc.run_report
knowledge.get_rule_or_handbook
vision.run_review
issue.create # approval required
design_review.create # approval required
Every tool call must carry or resolve:
- authenticated RapidDraft user and tenant;
model_idand revision;- ownership, grant, or share-link scope;
- audit, run, and tool-call identifiers;
- idempotency key for mutations and long-running jobs.
Do not expose raw mesh arrays, arbitrary filesystem paths, provider keys, provider base URLs, global rule mutation, or the full RapidDraft OpenAPI document.
Viewer context¶
Each Agent turn receives a bounded, server-validated ContextSnapshot:
- active model and revision;
- selected component, face, and edge IDs;
- active review or finding IDs;
- visible workspace;
- user-requested screenshot reference when visual context is required.
Tool results can return AnalysisFocusPayload with component, position, bounding box, face/edge IDs, related locations, camera behaviour, and isolation level. The panel converts an explicit click or user request into a viewer command. Raw CAD geometry remains in RapidDraft.
Vertical slice¶
Phase 0: contract and runtime spike¶
- Enable Remote Agents only in the LibreChat testing environment.
- Create or adapt one private RapidDraft Agent.
- Put a RapidDraft-owned gateway in front of the Remote Agent endpoint.
- Implement four read-only capabilities:
model.get_context;model.get_part_facts;model.resolve_selection;dfm.run_reviewplus job status.- Add a narrow streaming Agent panel to RapidDraft.
- Return and apply an
AnalysisFocusPayloadfrom an answer or result card.
Acceptance prompt:
Check this selected pocket against the manufacturing knowledge base, explain the risk
with citations, run the DFM analysis, and show the affected faces.
The slice passes only when it produces:
- a server-authorized model context;
- a LibreChat RAG citation;
- a typed RapidDraft tool call and trace;
- a deterministic DFM result;
- a focus action that selects the correct geometry;
- no shared browser key or raw CAD geometry in the prompt.
Later phases¶
- unify or explicitly link identity;
- map streaming and tool events to stable
AgentEventobjects; - move long-running operations to durable jobs;
- add approval-gated issue, review, and report mutations;
- maintain pinned LibreChat/RAG overlays and automated upgrade tests;
- evaluate MCP UI cards only as small previews and actions, not as a replacement for the CAD workspace.
Rejected first choices¶
| Option | Reason |
|---|---|
| Whole LibreChat iframe inside RapidDraft | Duplicate authentication, cookies, layout, and context synchronization |
| Whole RapidDraft iframe inside LibreChat | Reverses product ownership and creates the same authentication/context problems |
| Heavy LibreChat frontend fork | Permanent upstream merge and upgrade cost |
| Complete RapidDraft viewer extracted into LibreChat | Highest coupling and maintenance cost |
An iframe may support a throwaway proof of concept but should not define the production boundary.
Decision gate¶
The vertical slice must determine whether LibreChat becomes:
- a temporary integration accelerator behind the RapidDraft Agent gateway;
- the maintained internal runtime behind that gateway; or
- only the standalone knowledge and administration interface.
The decision should use evidence from event and artifact fidelity, user-scoped authorization, fixed context overhead, multi-turn behaviour, image-upgrade cost, and support for RapidDraft approvals and viewer actions.
Open Questions¶
- Which RapidDraft branch is the implementation baseline?
- Can all required stream, tool, artifact, and error events be mapped without a LibreChat core fork?
- Will production use shared SSO, account linking, or a gateway-only service identity?
- Can the deployed batch file-search overlay be upstreamed or isolated behind a stable gateway contract before the vertical slice becomes production-critical?
Sources¶
D:\02_Code\00_Project_Management_n_skills\01_tracks\rapiddraft-studio\plans\260720_librechat-rapiddraft-integration\README.mdD:\02_Code\LibreChat_Setup\librechat.yamlD:\02_Code\LibreChat_Setup\services\bauer-twin-api\app.pyD:\02_Code\LibreChat_Setup\services\librechat-custom\fileSearch.js- RapidDraft Agent foundation decision records
DL-007andDL-008