third-party-and-sharp-edges
Third-party knowledge and sharp edges
These areas are where contributors most often need external documentation or careful debugging.
LangChain (@langchain/core messages)
Files: the SDK (packages/sdk) exposes langchainRegistration and remote RPC helpers; the web-ui host stores whatever Journey and interaction lines you send.
- The host does not turn invoke output into journeys automatically. After
invoke, map your message sequence (human, AI tool calls, tool results, final AI) into aJourney(public-typesin the SDK) and callrecordJourney. - Useful LangChain familiarity:
tool_callson AI messages, tool result messages, and normalizingcontentwhen building step text. - Sharp edge: Odd message ordering or multimodal
contentis your integration’s concern when buildingJourneysteps andrecordInteractiontext.
LangChain agents (langchain package)
Files: examples/*.ts, registration via langchainRegistration.
- Examples use
createAgent,ChatOpenAI, and Zod tool schemas — API surface follows LangChain v1 patterns. - Sharp edge: Tool names must include
chat_tooland anyassist_*tools you expose in the watch UI. Renaming tools breaks assist metadata until you re-register the agent. - @deprecated:
layoutStructuresFromToolsandsyncPlayerStructuresFromToolsare removed. Tool names do not spawn map structures; author spaces with owner metadata instead (see World map v3).
Next.js app and SSE
Files: packages/web-ui/src/app/api/agent-play/events/route.ts.
- SSE uses
ReadableStreamand validsidper request; whenREDIS_URLis set, clients subscribe to Redis Pub/Sub fanout so all instances see the same events. - Sharp edge: The watch UI expects
prebuildto copyplay-uiintoweb-ui/src/canvas/vendor; skipping the copy step yields a stale or missing bundle.
Pixi.js v8
Files: packages/play-ui/src/ — multiverse/canvas modules.
- Scene graph (
Container,Graphics,Text), render loop (ticker/ customonTick/onFrame), coordinate systems (screen vs world). - Sharp edge: World coordinates in the preview use a grid derived from
worldMap.boundsandcellScale; agent positions are continuous floats — mapping is inmain.ts(worldToScreen). - Sharp edge: Destroying containers and textures on hot reload or theme changes must match Pixi lifecycle to avoid WebGL leaks.
Browser: EventSource
Files: main.ts SSE connection.
- Reconnection behavior is browser-dependent; network drops may require page refresh in dev.
- Sharp edge: CORS and credentials if preview is on a different origin than the API.
Markdown in UI
Files: chat-related modules; marked + dompurify.
- Untrusted model output should stay sanitized; changes to rendering pipeline affect XSS surface.
World bounds and two runtimes
- Server:
play-world.tsclamps enriched paths withclampPathToBounds. - Browser:
world-bounds.tsimported into play-ui for client-side clamping and joystick behavior.
Sharp edge: Logic drift between server and client if only one side is updated — keep shared math in world-bounds.ts and test both packages when changing bounds rules.
Vitest (dual versions)
packages/sdkandpackages/web-uiuse Vitest 3;packages/play-uiuses Vitest 4. Run tests per workspace (npm run test -w @agent-play/sdk, etc.).