From 64a419831879abbf12a8f3c5c1c7f1cb4814c602 Mon Sep 17 00:00:00 2001 From: Dan Lynch Date: Tue, 15 Sep 2026 05:53:11 +0000 Subject: [PATCH] fix(agent-conversation): stop sending inherited databaseId on message/task creates agent_message and agent_task inherit database_id / entity_id and visibility from their thread via the agent module's BEFORE INSERT trigger; constructive-db now marks those fields -insert, so the create inputs no longer accept them. --- agentic/agent-conversation/README.md | 13 +++++++++---- .../__tests__/conversation.test.ts | 1 - .../agent-conversation/src/graphql-conversation.ts | 11 ++++++----- agentic/pi-host/__tests__/events.test.ts | 2 -- agentic/pi-host/__tests__/gate.test.ts | 3 --- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/agentic/agent-conversation/README.md b/agentic/agent-conversation/README.md index 723312eb3..db7d510f0 100644 --- a/agentic/agent-conversation/README.md +++ b/agentic/agent-conversation/README.md @@ -7,21 +7,26 @@ owns all of it. ```ts import { + createGraphQLConversationClient, + createHttpGraphQLClient, Inbox, isApprovalEvent, loadOrCreateThread, TaskWriter, - Transcript, - createHttpGraphQLClient + Transcript } from '@agentic-kit/agent-conversation'; const client = createHttpGraphQLClient({ url, token }); const thread = await loadOrCreateThread({ client, databaseId, threadId, title }); -const transcript = new Transcript(client, { databaseId, threadId: thread.id, model }); +// Messages and tasks inherit their scope from the thread; only the thread +// creation above names the database. +const conversation = createGraphQLConversationClient({ client, threadId: thread.id, actorId }); + +const transcript = new Transcript(conversation, { model }); await transcript.appendText('Reading the tests first.'); -const inbox = new Inbox({ client, threadId: thread.id, since: thread.createdAt! }); +const inbox = new Inbox({ client: conversation, since: thread.createdAt! }); const { event, cancelled } = await inbox.waitFor(isApprovalEvent, { timeoutMs: 900_000 }); ``` diff --git a/agentic/agent-conversation/__tests__/conversation.test.ts b/agentic/agent-conversation/__tests__/conversation.test.ts index 6601d6923..a3abbbcc5 100644 --- a/agentic/agent-conversation/__tests__/conversation.test.ts +++ b/agentic/agent-conversation/__tests__/conversation.test.ts @@ -14,7 +14,6 @@ const DATABASE_ID = '00000000-0000-0000-0000-0000000000db'; const conversation = (api: FakeAgentApi, threadId: string) => createGraphQLConversationClient({ client: api, - databaseId: DATABASE_ID, threadId, actorId: 'actor-1', }); diff --git a/agentic/agent-conversation/src/graphql-conversation.ts b/agentic/agent-conversation/src/graphql-conversation.ts index 2065962f6..82dee2fc9 100644 --- a/agentic/agent-conversation/src/graphql-conversation.ts +++ b/agentic/agent-conversation/src/graphql-conversation.ts @@ -49,8 +49,11 @@ const UPDATE_TASK = `mutation CodeTaskUpdateTask($input: UpdateAgentTaskInput!) export interface GraphQLConversationClientOptions { client: GraphQLClient; - databaseId: string; - /** The thread every write lands on. */ + /** + * The thread every write lands on. Scope (`database_id` / `entity_id`, + * `visibility`) is inherited from it by the agent module's insert triggers, + * so the client never names it. + */ threadId: string; /** The agent row the run speaks as, when the tenant has one. */ agentId?: string | null; @@ -68,7 +71,7 @@ export interface GraphQLConversationClientOptions { export function createGraphQLConversationClient( options: GraphQLConversationClientOptions ): ConversationClient { - const { client, databaseId, threadId } = options; + const { client, threadId } = options; const parent: TaskParent = options.taskParent ?? { column: 'threadId', id: threadId }; const attribution = { ...(options.agentId ? { agentId: options.agentId } : {}), @@ -82,7 +85,6 @@ export function createGraphQLConversationClient( }>(CREATE_MESSAGE, { input: { agentMessage: { - databaseId, threadId, authorRole: input.authorRole, ...attribution, @@ -123,7 +125,6 @@ export function createGraphQLConversationClient( { input: { agentTask: { - databaseId, [parent.column]: parent.id, description: input.description, status: input.status, diff --git a/agentic/pi-host/__tests__/events.test.ts b/agentic/pi-host/__tests__/events.test.ts index 655513467..376d66135 100644 --- a/agentic/pi-host/__tests__/events.test.ts +++ b/agentic/pi-host/__tests__/events.test.ts @@ -4,14 +4,12 @@ import { createGraphQLConversationClient, TaskWriter, Transcript } from '@agenti import { FakeAgentApi } from '../../agent-conversation/__tests__/fake-client'; import { parseTodos, TranscriptWriter } from '../src/events'; -const DATABASE_ID = '00000000-0000-0000-0000-0000000000db'; const THREAD_ID = '00000000-0000-0000-0000-0000000000ad'; function setup(withTasks = true) { const api = new FakeAgentApi(); const conversation = createGraphQLConversationClient({ client: api, - databaseId: DATABASE_ID, threadId: THREAD_ID }); const transcript = new Transcript(conversation); diff --git a/agentic/pi-host/__tests__/gate.test.ts b/agentic/pi-host/__tests__/gate.test.ts index 286a584a7..00094da89 100644 --- a/agentic/pi-host/__tests__/gate.test.ts +++ b/agentic/pi-host/__tests__/gate.test.ts @@ -3,7 +3,6 @@ import { createGraphQLConversationClient, Inbox, requestApproval, respondToAppro import { FakeAgentApi } from '../../agent-conversation/__tests__/fake-client'; import { createThreadGateHost } from '../src/gate'; -const DATABASE_ID = '00000000-0000-0000-0000-0000000000db'; const THREAD_ID = '00000000-0000-0000-0000-0000000000ad'; interface Harness { @@ -29,7 +28,6 @@ function harness(): Harness { const conversation = createGraphQLConversationClient({ client: api, - databaseId: DATABASE_ID, threadId: THREAD_ID }); @@ -128,7 +126,6 @@ describe('thread gate host', () => { const inbox = new Inbox({ client: createGraphQLConversationClient({ client: h.api, - databaseId: DATABASE_ID, threadId: THREAD_ID }), since: new Date(0).toISOString(),