Skip to content

The open-source agent harness - the runtime layer that turns an LLM into a working agent.

Passthrough collaborators for truefoundry agents import (#722)

Chirag Jain5bc13d0bd1e2
diff --git a/.changeset/tfy-import-collaborators.md b/.changeset/tfy-import-collaborators.md
new file mode 100644
index 000000000..ab327e238
--- /dev/null
+++ b/.changeset/tfy-import-collaborators.md
@@ -0,0 +1,5 @@
+---
+"@truefoundry/trueforge": patch
+---
+
+Pass collaborators through TrueFoundry agent import.
diff --git a/.github/fern/openapi/openapi.json b/.github/fern/openapi/openapi.json
index 98ed0f80e..0a15995a4 100644
--- a/.github/fern/openapi/openapi.json
+++ b/.github/fern/openapi/openapi.json
@@ -1701,9 +1701,20 @@
],
"type": "object"
},
+ "ImportAgentCollaborator": {
+ "additionalProperties": {},
+ "properties": {},
+ "type": "object"
+ },
"ImportAgentItem": {
"additionalProperties": false,
"properties": {
+ "collaborators": {
+ "items": {
+ "$ref": "#/components/schemas/ImportAgentCollaborator"
+ },
+ "type": "array"
+ },
"created_by_subject": {
"allOf": [
{
diff --git a/.gitignore b/.gitignore
index 930b3e1e6..64431bd80 100644
--- a/.gitignore
+++ b/.gitignore
@@ -40,3 +40,5 @@ service-account*.json
.cursor/plans/
.vscode
+
+.certs/
\ No newline at end of file
diff --git a/docs/openapi.json b/docs/openapi.json
index 98ed0f80e..0a15995a4 100644
--- a/docs/openapi.json
+++ b/docs/openapi.json
@@ -1701,9 +1701,20 @@
],
"type": "object"
},
+ "ImportAgentCollaborator": {
+ "additionalProperties": {},
+ "properties": {},
+ "type": "object"
+ },
"ImportAgentItem": {
"additionalProperties": false,
"properties": {
+ "collaborators": {
+ "items": {
+ "$ref": "#/components/schemas/ImportAgentCollaborator"
+ },
+ "type": "array"
+ },
"created_by_subject": {
"allOf": [
{
diff --git a/packages/trueforge/src/apis/agentImport.ts b/packages/trueforge/src/apis/agentImport.ts
index 201677bf0..61816936d 100644
--- a/packages/trueforge/src/apis/agentImport.ts
+++ b/packages/trueforge/src/apis/agentImport.ts
@@ -50,6 +50,9 @@ export function createAgentImportRouter(deps: AgentImportRouterDeps) {
manifest: agent.manifest,
external_id: null,
created_by_subject: agent.created_by_subject,
+ custom: {
+ ...(agent.collaborators ? { collaborators: agent.collaborators } : {}),
+ },
});
results.push({
name: created.name,
diff --git a/packages/trueforge/src/db/agentStore.ts b/packages/trueforge/src/db/agentStore.ts
index ac2a796d4..8430680d8 100644
--- a/packages/trueforge/src/db/agentStore.ts
+++ b/packages/trueforge/src/db/agentStore.ts
@@ -71,6 +71,7 @@ export interface CreateAgentInput {
manifest: AgentSpec;
external_id: string | null;
created_by_subject: CreatedBySubject;
+ custom?: Record<string, unknown>;
}
/**
diff --git a/packages/trueforge/src/schemas/agentImport.ts b/packages/trueforge/src/schemas/agentImport.ts
index 81e8bfa62..61f563ad1 100644
--- a/packages/trueforge/src/schemas/agentImport.ts
+++ b/packages/trueforge/src/schemas/agentImport.ts
@@ -8,6 +8,9 @@ import { NameSchema } from './common';
const RESERVED_AGENT_NAMES = new Set(['tfg', 'trueforge']);
+/** Opaque collaborator grant forwarded to ServiceFoundry on import. */
+export const ImportAgentCollaboratorSchema = z.object({}).loose().openapi('ImportAgentCollaborator');
+
/** One import row: same fields as create-agent, plus explicit tenant and creator. */
export const ImportAgentItemSchema = z
.object({
@@ -18,6 +21,7 @@ export const ImportAgentItemSchema = z
manifest: AgentSpecSchema,
tenant_id: z.string().min(1).describe('Tenant to create the agent under.'),
created_by_subject: CreatedBySubjectSchema.describe('Original creator to persist on the agent.'),
+ collaborators: z.array(ImportAgentCollaboratorSchema).optional(),
})
.strict()
.openapi('ImportAgentItem');
diff --git a/packages/trueforge/src/truefoundry/TrueFoundryAgentStore.ts b/packages/trueforge/src/truefoundry/TrueFoundryAgentStore.ts
index 46cec6cde..73c163847 100644
--- a/packages/trueforge/src/truefoundry/TrueFoundryAgentStore.ts
+++ b/packages/trueforge/src/truefoundry/TrueFoundryAgentStore.ts
@@ -30,16 +30,19 @@ function toPutRemoteAgentPayload({
name,
description,
manifest,
+ collaborators,
}: {
name: string;
description: string;
manifest: AgentSpec;
+ collaborators?: Record<string, unknown>[];
}): Omit<PutRemoteAgentInput, 'accessToken'> {
return {
name,
description: (description || name).slice(0, AGENT_DESCRIPTION_MAX_LENGTH),
model: manifest.model.name,
mcp_servers: (manifest.mcp_servers ?? []).map(server => server.name),
+ ...(collaborators ? { collaborators } : {}),
};
}
@@ -135,12 +138,14 @@ export class TrueFoundryAgentStore implements IAgentStore<Transaction<Database>>
let externalId: string | undefined;
try {
+ const collaborators = input.custom?.['collaborators'] as Record<string, unknown>[] | undefined;
({ externalId } = await this.#client.putRemoteAgent({
accessToken: await this.#resolveAccessToken(),
...toPutRemoteAgentPayload({
name: input.name,
description: input.description,
manifest: input.manifest,
+ ...(collaborators ? { collaborators } : {}),
}),
}));
const updated = await this.#inner.updateAgent(
diff --git a/packages/trueforge/src/truefoundry/TrueFoundryServiceFoundryServerClient.ts b/packages/trueforge/src/truefoundry/TrueFoundryServiceFoundryServerClient.ts
index 0fa3f4289..b5fdf72e1 100644
--- a/packages/trueforge/src/truefoundry/TrueFoundryServiceFoundryServerClient.ts
+++ b/packages/trueforge/src/truefoundry/TrueFoundryServiceFoundryServerClient.ts
@@ -97,6 +97,7 @@ export interface PutRemoteAgentInput {
description: string;
model: string;
mcp_servers: string[];
+ collaborators?: Record<string, unknown>[];
}
export interface PutRemoteAgentResult {
@@ -245,6 +246,7 @@ export class TrueFoundryServiceFoundryServerClient {
/** PUT `/internal/tfg/agents` — create/reuse remote agent + sync model/MCP grants. */
async putRemoteAgent(input: PutRemoteAgentInput): Promise<PutRemoteAgentResult> {
+ const hasCollaborators = input.collaborators && input.collaborators.length > 0;
const payload = await this.#requestJson({
url: this.#url(TFG_AGENTS_PATH),
accessToken: input.accessToken,
@@ -255,6 +257,7 @@ export class TrueFoundryServiceFoundryServerClient {
description: input.description,
model: input.model,
mcp_servers: input.mcp_servers,
+ ...(hasCollaborators ? { collaborators: input.collaborators } : {}),
},
});
const parsed = PutRemoteAgentResponseSchema.safeParse(payload);
diff --git a/packages/trueforge/tests/unit/truefoundry/TrueFoundryAgentStore.test.ts b/packages/trueforge/tests/unit/truefoundry/TrueFoundryAgentStore.test.ts
index 9d66285fe..e34047494 100644
--- a/packages/trueforge/tests/unit/truefoundry/TrueFoundryAgentStore.test.ts
+++ b/packages/trueforge/tests/unit/truefoundry/TrueFoundryAgentStore.test.ts
@@ -204,6 +204,44 @@ describe('TrueFoundryAgentStore', () => {
expect(firstInvocationOrder(putRemoteAgent)).toBeLessThan(firstInvocationOrder(updateAgent));
});
+ it('createAgent forwards collaborators from custom into putRemoteAgent', async () => {
+ const collaborators = [{ subject: 'user:[email protected]', role_id: 'agent-manager' }];
+ const local = record({ external_id: null });
+ const linked = record({ external_id: 'sf-1' });
+ const putRemoteAgent = jest.fn(async (input: PutRemoteAgentInput) => {
+ expect(input.collaborators).toEqual(collaborators);
+ return { externalId: 'sf-1' };
+ });
+ const store = tfStore({
+ inner: mockInner({
+ createAgent: jest.fn(async () => local),
+ updateAgent: jest.fn(async () => linked),
+ }),
+ client: mockClient({ putRemoteAgent }),
+ });
+
+ await expect(
+ store.createAgent(
+ {
+ tenant_id: TENANT,
+ created_by_subject: CREATED_BY_SUBJECT,
+ name: 'research',
+ description: 'research',
+ manifest: manifest(),
+ external_id: null,
+ custom: { collaborators },
+ },
+ TXN,
+ ),
+ ).resolves.toBe(linked);
+ expect(putRemoteAgent).toHaveBeenCalledWith(
+ expect.objectContaining({
+ name: 'research',
+ collaborators,
+ }),
+ );
+ });
+
it('createAgent rejects a duplicate local name before calling ServiceFoundry', async () => {
const createAgent = jest.fn(async () => {
throw new AgentNameConflictError({ tenant_id: TENANT, name: 'research' });