Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(chat): withhold home tools when a visitor chats with an agent they do not own
nirholasab2266ce49c3
diff --git a/api/chat.js b/api/chat.jsindex bb6973fd7..919d5c633 100644--- a/api/chat.js+++ b/api/chat.js@@ -64,7 +64,7 @@ import {GROK_BUDGET_MODEL,routableGrokModelId,} from './_lib/chat-models.js';-import { computeContext, searchMemories } from './_lib/memory-store.js';+import { computeContext, searchMemories, isVisitorQaMemory } from './_lib/memory-store.js';import { HOME_TOOL_DEFS, isHomeTool, runHomeTool } from './_lib/home/tools.js';import {homeTurnGate,@@ -703,7 +703,7 @@ export default wrap(async (req, res) => {captureException(err, { route: 'chat', stage: 'home-membership' });}}- const toolSet = homeCount+ const toolSet = homeToolsOffered({ homeCount, agentId: body.agentId, isOwner })? {anthropic: [...ACTION_TOOLS, ...HOME_ANTHROPIC_TOOLS],openai: [...OPENAI_TOOLS, ...HOME_OPENAI_TOOLS],@@ -1558,6 +1558,17 @@ function keylessVertexAvailable(name) {return false;}+/**+ * Whether this turn may carry the visitor's smart-home tools. They run under the+ * visitor's authority, so they are withheld whenever another account's persona or+ * custom skills (untrusted text) share the prompt: only the agent's owner, or a+ * turn with no agent at all, gets them.+ * @param {{ homeCount: number, agentId: unknown, isOwner: boolean }} o+ */+export function homeToolsOffered({ homeCount, agentId, isOwner }) {+ return homeCount > 0 && (!agentId || isOwner);+}+/*** Whether this turn should default to the agent's own configured brain* (api/_lib/agent-model.js) instead of the platform's provider ladder: only@@ -2118,7 +2129,7 @@ function toViewerAction(call) {// memories. Returns the compact shape the `done` event and the client bus event// share — id, type, tier, salience, a display snippet, and how it surfaced.async function recallForChat(agentId, message, isOwner) {- const visible = (m) => isOwner || m.isPublic;+ const visible = (m) => !isVisitorQaMemory(m) && (isOwner || m.isPublic);const [ctx, search] = await Promise.all([computeContext(agentId).catch(() => ({ entries: [] })),searchMemories(agentId, message, { topK: 6 }).catch(() => ({ results: [] })),diff --git a/tests/chat-home-tools-third-party-persona.test.js b/tests/chat-home-tools-third-party-persona.test.jsnew file mode 100644index 000000000..db27aeed6--- /dev/null+++ b/tests/chat-home-tools-third-party-persona.test.js@@ -0,0 +1,20 @@+// A published agent's persona and custom skills are written by its owner. When a+// different, signed-in visitor chats with it, that text must never share a turn+// with the visitor's smart-home tools (they run under the visitor's authority).+import { describe, it, expect } from 'vitest';+import { homeToolsOffered } from '../api/chat.js';++describe('homeToolsOffered', () => {+ it('offers home tools in a plain turn with no agent', () => {+ expect(homeToolsOffered({ homeCount: 1, agentId: null, isOwner: false })).toBe(true);+ });+ it('offers home tools when the visitor owns the agent', () => {+ expect(homeToolsOffered({ homeCount: 1, agentId: 'a1', isOwner: true })).toBe(true);+ });+ it('withholds home tools when a third-party agent persona is in the prompt', () => {+ expect(homeToolsOffered({ homeCount: 1, agentId: 'a1', isOwner: false })).toBe(false);+ });+ it('offers nothing without a home membership', () => {+ expect(homeToolsOffered({ homeCount: 0, agentId: null, isOwner: false })).toBe(false);+ });+});