Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(agents): let a persona choose whether it is a coding agent (#6936)

Wolf Mermelsteinca9774225e8f
diff --git a/.sqlx/query-d6d285adb63e37c4cfcc6dd5f62caad54402d57221a60e4f690571986383ac4a.json b/.sqlx/query-0b8f347e3167ca28d3531dfd593994f5920f68f2140a748b9a8932e83360b942.json
similarity index 61%
rename from .sqlx/query-d6d285adb63e37c4cfcc6dd5f62caad54402d57221a60e4f690571986383ac4a.json
rename to .sqlx/query-0b8f347e3167ca28d3531dfd593994f5920f68f2140a748b9a8932e83360b942.json
index b4dc61f8e3..442ca6d9ae 100644
--- a/.sqlx/query-d6d285adb63e37c4cfcc6dd5f62caad54402d57221a60e4f690571986383ac4a.json
+++ b/.sqlx/query-0b8f347e3167ca28d3531dfd593994f5920f68f2140a748b9a8932e83360b942.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT\n b.id,\n b.kind,\n b.owner_user_id,\n b.team_id,\n b.name,\n b.handle,\n b.description,\n b.avatar_url,\n b.created_by,\n b.created_at,\n b.updated_at,\n b.deleted_at,\n b.has_agent,\n a.instructions,\n a.harness,\n a.harness_id,\n a.default_model,\n a.channel_scope,\n a.auto_accept_permissions,\n ARRAY(\n SELECT p.channel_id\n FROM comms_channel_participants p\n WHERE p.user_id = 'bot|' || b.id::text\n AND p.left_at IS NULL\n ORDER BY p.channel_id\n ) AS \"channel_ids!\",\n a.mcp_scope,\n ARRAY(\n SELECT m.app_slug\n FROM agent_mcp_servers m\n WHERE m.bot_id = b.id\n ORDER BY m.app_slug\n ) AS \"mcp_app_slugs!\",\n ARRAY(\n SELECT m.server_name\n FROM agent_mcp_servers m\n WHERE m.bot_id = b.id\n ORDER BY m.app_slug\n ) AS \"mcp_server_names!\"\n FROM bots b\n INNER JOIN agent_configs a ON a.bot_id = b.id\n WHERE b.kind = 'owned'\n AND b.deleted_at IS NULL\n AND (\n b.owner_user_id = $1\n OR b.team_id IN (\n SELECT team_id FROM team_user WHERE user_id = $1\n )\n OR (\n a.channel_scope = 'selected'\n AND EXISTS (\n SELECT 1\n FROM comms_channel_participants bot_p\n INNER JOIN comms_channel_participants user_p\n ON user_p.channel_id = bot_p.channel_id\n AND user_p.user_id = $1\n AND user_p.left_at IS NULL\n WHERE bot_p.user_id = 'bot|' || b.id::text\n AND bot_p.left_at IS NULL\n )\n )\n )\n ORDER BY b.created_at ASC, b.id ASC\n ",
+ "query": "\n SELECT\n b.id,\n b.kind,\n b.owner_user_id,\n b.team_id,\n b.name,\n b.handle,\n b.description,\n b.avatar_url,\n b.created_by,\n b.created_at,\n b.updated_at,\n b.deleted_at,\n b.has_agent,\n a.instructions,\n a.harness,\n a.harness_id,\n a.default_model,\n a.channel_scope,\n a.auto_accept_permissions,\n a.is_coding,\n ARRAY(\n SELECT p.channel_id\n FROM comms_channel_participants p\n WHERE p.user_id = 'bot|' || b.id::text\n AND p.left_at IS NULL\n ORDER BY p.channel_id\n ) AS \"channel_ids!\",\n a.mcp_scope,\n ARRAY(\n SELECT m.app_slug\n FROM agent_mcp_servers m\n WHERE m.bot_id = b.id\n ORDER BY m.app_slug\n ) AS \"mcp_app_slugs!\",\n ARRAY(\n SELECT m.server_name\n FROM agent_mcp_servers m\n WHERE m.bot_id = b.id\n ORDER BY m.app_slug\n ) AS \"mcp_server_names!\"\n FROM bots b\n INNER JOIN agent_configs a ON a.bot_id = b.id\n WHERE b.kind = 'owned'\n AND b.deleted_at IS NULL\n AND (\n b.owner_user_id = $1\n OR b.team_id IN (\n SELECT team_id FROM team_user WHERE user_id = $1\n )\n OR (\n a.channel_scope = 'selected'\n AND EXISTS (\n SELECT 1\n FROM comms_channel_participants bot_p\n INNER JOIN comms_channel_participants user_p\n ON user_p.channel_id = bot_p.channel_id\n AND user_p.user_id = $1\n AND user_p.left_at IS NULL\n WHERE bot_p.user_id = 'bot|' || b.id::text\n AND bot_p.left_at IS NULL\n )\n )\n )\n ORDER BY b.created_at ASC, b.id ASC\n ",
"describe": {
"columns": [
{
@@ -100,21 +100,26 @@
},
{
"ordinal": 19,
+ "name": "is_coding",
+ "type_info": "Bool"
+ },
+ {
+ "ordinal": 20,
"name": "channel_ids!",
"type_info": "UuidArray"
},
{
- "ordinal": 20,
+ "ordinal": 21,
"name": "mcp_scope",
"type_info": "Text"
},
{
- "ordinal": 21,
+ "ordinal": 22,
"name": "mcp_app_slugs!",
"type_info": "TextArray"
},
{
- "ordinal": 22,
+ "ordinal": 23,
"name": "mcp_server_names!",
"type_info": "TextArray"
}
@@ -144,11 +149,12 @@
false,
false,
true,
+ false,
null,
false,
null,
null
]
},
- "hash": "d6d285adb63e37c4cfcc6dd5f62caad54402d57221a60e4f690571986383ac4a"
+ "hash": "0b8f347e3167ca28d3531dfd593994f5920f68f2140a748b9a8932e83360b942"
}
diff --git a/.sqlx/query-9d7e5680d328059293deb5a98a029c347df69b980f1c92a07e07c61ae1fea893.json b/.sqlx/query-7c759daf76f446e32beabb9c063db09bd53db0d17b043c7c801522b3805f6d30.json
similarity index 67%
rename from .sqlx/query-9d7e5680d328059293deb5a98a029c347df69b980f1c92a07e07c61ae1fea893.json
rename to .sqlx/query-7c759daf76f446e32beabb9c063db09bd53db0d17b043c7c801522b3805f6d30.json
index 33bb6038a0..c88e4925b3 100644
--- a/.sqlx/query-9d7e5680d328059293deb5a98a029c347df69b980f1c92a07e07c61ae1fea893.json
+++ b/.sqlx/query-7c759daf76f446e32beabb9c063db09bd53db0d17b043c7c801522b3805f6d30.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n UPDATE agent_configs\n SET instructions = $2,\n harness = $3,\n harness_id = $4,\n default_model = $5,\n channel_scope = $6,\n mcp_scope = $7,\n auto_accept_permissions = $8,\n updated_at = now()\n WHERE bot_id = $1\n ",
+ "query": "\n UPDATE agent_configs\n SET instructions = $2,\n harness = $3,\n harness_id = $4,\n default_model = $5,\n channel_scope = $6,\n mcp_scope = $7,\n auto_accept_permissions = $8,\n is_coding = $9,\n updated_at = now()\n WHERE bot_id = $1\n ",
"describe": {
"columns": [],
"parameters": {
@@ -12,10 +12,11 @@
"Text",
"Text",
"Text",
+ "Bool",
"Bool"
]
},
"nullable": []
},
- "hash": "9d7e5680d328059293deb5a98a029c347df69b980f1c92a07e07c61ae1fea893"
+ "hash": "7c759daf76f446e32beabb9c063db09bd53db0d17b043c7c801522b3805f6d30"
}
diff --git a/.sqlx/query-916cf37a24e7fca2d72e06cf1bcfd65dcac6ba8f4d33c77b677f56d5b1c14171.json b/.sqlx/query-7f866ed3077d3fcc644b48902cd95584d6d474db9eedafdde38c6479040bf09b.json
similarity index 72%
rename from .sqlx/query-916cf37a24e7fca2d72e06cf1bcfd65dcac6ba8f4d33c77b677f56d5b1c14171.json
rename to .sqlx/query-7f866ed3077d3fcc644b48902cd95584d6d474db9eedafdde38c6479040bf09b.json
index 356c99eff9..17ec97b116 100644
--- a/.sqlx/query-916cf37a24e7fca2d72e06cf1bcfd65dcac6ba8f4d33c77b677f56d5b1c14171.json
+++ b/.sqlx/query-7f866ed3077d3fcc644b48902cd95584d6d474db9eedafdde38c6479040bf09b.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT\n b.id,\n b.kind,\n b.owner_user_id,\n b.team_id,\n b.name,\n b.handle,\n b.description,\n b.avatar_url,\n b.created_by,\n b.created_at,\n b.updated_at,\n b.deleted_at,\n b.has_agent,\n a.instructions,\n a.harness,\n a.harness_id,\n a.default_model,\n a.channel_scope,\n a.auto_accept_permissions,\n ARRAY(\n SELECT p.channel_id\n FROM comms_channel_participants p\n WHERE p.user_id = 'bot|' || b.id::text\n AND p.left_at IS NULL\n ORDER BY p.channel_id\n ) AS \"channel_ids!\",\n a.mcp_scope,\n ARRAY(\n SELECT m.app_slug\n FROM agent_mcp_servers m\n WHERE m.bot_id = b.id\n ORDER BY m.app_slug\n ) AS \"mcp_app_slugs!\",\n ARRAY(\n SELECT m.server_name\n FROM agent_mcp_servers m\n WHERE m.bot_id = b.id\n ORDER BY m.app_slug\n ) AS \"mcp_server_names!\"\n FROM bots b\n INNER JOIN agent_configs a ON a.bot_id = b.id\n WHERE b.id = $1\n AND b.kind = 'owned'\n AND b.deleted_at IS NULL\n ",
+ "query": "\n SELECT\n b.id,\n b.kind,\n b.owner_user_id,\n b.team_id,\n b.name,\n b.handle,\n b.description,\n b.avatar_url,\n b.created_by,\n b.created_at,\n b.updated_at,\n b.deleted_at,\n b.has_agent,\n a.instructions,\n a.harness,\n a.harness_id,\n a.default_model,\n a.channel_scope,\n a.auto_accept_permissions,\n a.is_coding,\n ARRAY(\n SELECT p.channel_id\n FROM comms_channel_participants p\n WHERE p.user_id = 'bot|' || b.id::text\n AND p.left_at IS NULL\n ORDER BY p.channel_id\n ) AS \"channel_ids!\",\n a.mcp_scope,\n ARRAY(\n SELECT m.app_slug\n FROM agent_mcp_servers m\n WHERE m.bot_id = b.id\n ORDER BY m.app_slug\n ) AS \"mcp_app_slugs!\",\n ARRAY(\n SELECT m.server_name\n FROM agent_mcp_servers m\n WHERE m.bot_id = b.id\n ORDER BY m.app_slug\n ) AS \"mcp_server_names!\"\n FROM bots b\n INNER JOIN agent_configs a ON a.bot_id = b.id\n WHERE b.id = $1\n AND b.kind = 'owned'\n AND b.deleted_at IS NULL\n ",
"describe": {
"columns": [
{
@@ -100,21 +100,26 @@
},
{
"ordinal": 19,
+ "name": "is_coding",
+ "type_info": "Bool"
+ },
+ {
+ "ordinal": 20,
"name": "channel_ids!",
"type_info": "UuidArray"
},
{
- "ordinal": 20,
+ "ordinal": 21,
"name": "mcp_scope",
"type_info": "Text"
},
{
- "ordinal": 21,
+ "ordinal": 22,
"name": "mcp_app_slugs!",
"type_info": "TextArray"
},
{
- "ordinal": 22,
+ "ordinal": 23,
"name": "mcp_server_names!",
"type_info": "TextArray"
}
@@ -144,11 +149,12 @@
false,
false,
true,
+ false,
null,
false,
null,
null
]
},
- "hash": "916cf37a24e7fca2d72e06cf1bcfd65dcac6ba8f4d33c77b677f56d5b1c14171"
+ "hash": "7f866ed3077d3fcc644b48902cd95584d6d474db9eedafdde38c6479040bf09b"
}
diff --git a/.sqlx/query-c8d494bfcec68bbcc3da36ae9e69cedfcb520e8463f03f07f33ef9c5c01c8b7e.json b/.sqlx/query-f019b1c9186677f9623938f2300d49a5435e9a19abed022d5028d583bb0bab66.json
similarity index 61%
rename from .sqlx/query-c8d494bfcec68bbcc3da36ae9e69cedfcb520e8463f03f07f33ef9c5c01c8b7e.json
rename to .sqlx/query-f019b1c9186677f9623938f2300d49a5435e9a19abed022d5028d583bb0bab66.json
index 36a5a131a9..63497de5c8 100644
--- a/.sqlx/query-c8d494bfcec68bbcc3da36ae9e69cedfcb520e8463f03f07f33ef9c5c01c8b7e.json
+++ b/.sqlx/query-f019b1c9186677f9623938f2300d49a5435e9a19abed022d5028d583bb0bab66.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n INSERT INTO agent_configs (\n bot_id, instructions, harness, harness_id, default_model, channel_scope, mcp_scope, auto_accept_permissions\n )\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8)\n ",
+ "query": "\n INSERT INTO agent_configs (\n bot_id, instructions, harness, harness_id, default_model, channel_scope, mcp_scope, auto_accept_permissions, is_coding\n )\n VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)\n ",
"describe": {
"columns": [],
"parameters": {
@@ -12,10 +12,11 @@
"Text",
"Text",
"Text",
+ "Bool",
"Bool"
]
},
"nullable": []
},
- "hash": "c8d494bfcec68bbcc3da36ae9e69cedfcb520e8463f03f07f33ef9c5c01c8b7e"
+ "hash": "f019b1c9186677f9623938f2300d49a5435e9a19abed022d5028d583bb0bab66"
}
diff --git a/apps/web/src/features/channel/use-channel-bot-mention-users.test.ts b/apps/web/src/features/channel/use-channel-bot-mention-users.test.ts
index 7402a65f36..beaeaa65eb 100644
--- a/apps/web/src/features/channel/use-channel-bot-mention-users.test.ts
+++ b/apps/web/src/features/channel/use-channel-bot-mention-users.test.ts
@@ -57,6 +57,7 @@ function agent(
default_model: 'model',
harness,
instructions: '',
+ is_coding: harness !== 'in-memory',
mcp: { scope: 'owner_connections' },
};
}
diff --git a/apps/web/src/features/settings/Agents.test.tsx b/apps/web/src/features/settings/Agents.test.tsx
index 8fd205a6b5..dc0c17e557 100644
--- a/apps/web/src/features/settings/Agents.test.tsx
+++ b/apps/web/src/features/settings/Agents.test.tsx
@@ -728,6 +728,7 @@ describe('Agents', () => {
expect(agentMocks.update).toHaveBeenCalledWith({
agentId: 'agent-1',
autoAcceptPermissions: true,
+ isCoding: false,
avatarUrl: undefined,
channelIds: ['channel-engineering'],
channelScope: 'selected',
@@ -955,6 +956,7 @@ describe('Agents', () => {
expect(agentMocks.create).toHaveBeenCalledWith({
autoAcceptPermissions: true,
avatarUrl: undefined,
+ isCoding: false,
channelIds: [],
channelScope: 'all',
defaultModel: Model.sonnet5,
@@ -1241,6 +1243,7 @@ describe('Agents', () => {
expect(agentMocks.create).toHaveBeenCalledWith({
autoAcceptPermissions: false,
avatarUrl: undefined,
+ isCoding: true,
channelIds: [],
channelScope: 'all',
defaultModel: 'claude-code',
@@ -1255,6 +1258,42 @@ describe('Agents', () => {
});
});
+ it('seeds the coding choice from the runtime and lets the user override it', async () => {
+ harnessMocks.query.data = [MACROD_HARNESS];
+ modelMocks.queries[`macrod:${MACROD_HARNESS.id}`] = successfulModels(
+ [{ id: 'claude-code', name: 'Claude Code' }],
+ 'claude-code'
+ );
+
+ render(() => <Agents />);
+ fireEvent.click(screen.getByRole('button', { name: 'New agent' }));
+
+ const dialog = screen.getByRole('region', { name: /^(New|Edit) agent$/ });
+ fireEvent.input(within(dialog).getByLabelText('Name'), {
+ target: { value: 'Chatty' },
+ });
+ // Macro's in-memory runtime chats; a macrod harness codes.
+ expect(within(dialog).getByLabelText('Chat agent')).toHaveProperty(
+ 'checked',
+ true
+ );
+ chooseSelectOption(within(dialog).getByLabelText('Runtime'), 'Dev box');
+ expect(within(dialog).getByLabelText('Coding agent')).toHaveProperty(
+ 'checked',
+ true
+ );
+ fireEvent.click(within(dialog).getByLabelText('Chat agent'));
+ fireEvent.click(
+ within(dialog).getByRole('button', { name: 'Create agent' })
+ );
+
+ await waitFor(() => {
+ expect(agentMocks.create).toHaveBeenCalledWith(
+ expect.objectContaining({ harness: 'macrod', isCoding: false })
+ );
+ });
+ });
+
it('preserves and labels a saved model missing from the fresh catalog', () => {
agentMocks.query.data = [
{
diff --git a/apps/web/src/features/settings/Agents.tsx b/apps/web/src/features/settings/Agents.tsx
index 2c57361b9b..bebb4d4bcd 100644
--- a/apps/web/src/features/settings/Agents.tsx
+++ b/apps/web/src/features/settings/Agents.tsx
@@ -1,3 +1,4 @@
+import { isCoderHarness } from '@app/features/agents-view/core/agent-kind';
import { useFeatureFlag } from '@app/lib/analytics/posthog';
import { ModelCatalogPicker } from '@core/component/AI/component/input/ModelCatalogPicker';
import { isLargeModelCatalog } from '@core/component/AI/component/input/modelCatalog';
@@ -682,6 +683,16 @@ function AgentEditorPage(props: {
const autoAcceptPermissions = () =>
selectedHarness()?.kind === 'builtin' ||
(allowPermissionBypass() && autoAcceptChoice());
+ // The saved choice, or none: an agent that never chose follows its
+ // harness, so a fresh form and a re-picked runtime both start from there.
+ const [codingChoice, setCodingChoice] = createSignal<boolean | undefined>(
+ props.agent?.is_coding ?? undefined
+ );
+ const harnessCodes = () => {
+ const harness = selectedHarness();
+ return isCoderHarness(harness?.kind === 'macrod' ? 'macrod' : harness?.id);
+ };
+ const isCoding = () => codingChoice() ?? harnessCodes();
let avatarInputRef: HTMLInputElement | undefined;
let pageContentRef: HTMLDivElement | undefined;
@@ -698,6 +709,7 @@ function AgentEditorPage(props: {
setHarnessId(id);
setDefaultModelId(preferredModelId(id));
setAutoAcceptChoice(false);
+ setCodingChoice(undefined);
};
const handleAvatarInput = (file: File | undefined) => {
@@ -748,6 +760,7 @@ function AgentEditorPage(props: {
mcp: mcp(),
teamId: selectedTeamId(),
autoAcceptPermissions: autoAcceptPermissions(),
+ isCoding: isCoding(),
});
if (saved) close();
};
@@ -985,6 +998,27 @@ function AgentEditorPage(props: {
</Show>
</div>
</div>
+ <fieldset class="mt-4 grid gap-2 border-t border-ink/[0.06] pt-4">
+ <legend class="text-xs font-medium text-ink">
+ Answering a mention
+ </legend>
+ <ChoiceRow
+ name="agent-coding"
+ value="coding"
+ title="Coding agent"
+ description="Posts a magic chip you can open into the live session and watch it work in a repository."
+ checked={isCoding()}
+ onChange={() => setCodingChoice(true)}
+ />
+ <ChoiceRow
+ name="agent-coding"
+ value="chat"
+ title="Chat agent"
+ description="Replies in the thread the way a person would, like @macro."
+ checked={!isCoding()}
+ onChange={() => setCodingChoice(false)}
+ />
+ </fieldset>
<Show when={selectedHarness()?.kind === 'macrod'}>
<fieldset class="mt-4 grid gap-2 border-t border-ink/[0.06] pt-4">
<legend class="text-xs font-medium text-ink">
diff --git a/apps/web/src/lib/queries/agents/agents.test.tsx b/apps/web/src/lib/queries/agents/agents.test.tsx
index 3721dac5bb..61cc670a74 100644
--- a/apps/web/src/lib/queries/agents/agents.test.tsx
+++ b/apps/web/src/lib/queries/agents/agents.test.tsx
@@ -43,6 +43,7 @@ const params: CreateAgentParams = {
harness: 'in-memory',
name: 'Bug fixer',
instructions: 'Fix bugs.',
+ isCoding: false,
mcp: { scope: 'owner_connections' },
};
@@ -63,6 +64,7 @@ function agent(channelIds: string[]): Agent {
default_model: 'claude-sonnet-4-5',
channel_scope: 'selected',
channel_ids: channelIds,
+ is_coding: false,
mcp: { scope: 'owner_connections' },
};
}
diff --git a/apps/web/src/lib/queries/agents/agents.ts b/apps/web/src/lib/queries/agents/agents.ts
index 246998b58a..6725420b24 100644
--- a/apps/web/src/lib/queries/agents/agents.ts
+++ b/apps/web/src/lib/queries/agents/agents.ts
@@ -36,6 +36,12 @@ export type CreateAgentParams = {
* macrod prompts.
*/
autoAcceptPermissions?: boolean;
+ /**
+ * Whether the agent is a coding agent, which decides how it answers a
+ * channel mention: a magic chip into its live session, or a reply in the
+ * thread.
+ */
+ isCoding: boolean;
};
export type UpdateAgentParams = CreateAgentParams & {
@@ -88,6 +94,7 @@ export function useCreateAgentMutation() {
mcp: vars.mcp,
team_id: vars.teamId,
auto_accept_permissions: vars.autoAcceptPermissions ?? null,
+ is_coding: vars.isCoding,
})
),
onSuccess: async (agent) => {
@@ -121,6 +128,7 @@ export function useUpdateAgentMutation() {
mcp: vars.mcp,
team_id: vars.teamId,
auto_accept_permissions: vars.autoAcceptPermissions ?? null,
+ is_coding: vars.isCoding,
})
),
onSuccess: async (updated) => {
diff --git a/apps/web/src/lib/service-clients/service-storage/generated/schemas/agent.ts b/apps/web/src/lib/service-clients/service-storage/generated/schemas/agent.ts
index 936f9088e9..b5aafb0f8f 100644
--- a/apps/web/src/lib/service-clients/service-storage/generated/schemas/agent.ts
+++ b/apps/web/src/lib/service-clients/service-storage/generated/schemas/agent.ts
@@ -30,6 +30,11 @@ asking. `None` means always prompt. Bypass also requires the harness's opt-in. *
harness_id?: AgentHarnessId;
/** Instructions supplied to the agent at the start of a conversation. */
instructions: string;
+ /** Whether the agent works in a repository, which decides how it answers
+a channel mention: a coding agent posts a magic chip into its live
+session, a chat agent replies in the thread. Chosen in the agent's
+settings; the persona's word, not the runtime's. */
+ is_coding: boolean;
/** Which MCP servers sessions of this agent are handed. */
mcp: AgentMcpServers;
}
diff --git a/apps/web/src/lib/service-clients/service-storage/generated/schemas/createAgentRequest.ts b/apps/web/src/lib/service-clients/service-storage/generated/schemas/createAgentRequest.ts
index f95a92c88b..205df1dd1b 100644
--- a/apps/web/src/lib/service-clients/service-storage/generated/schemas/createAgentRequest.ts
+++ b/apps/web/src/lib/service-clients/service-storage/generated/schemas/createAgentRequest.ts
@@ -37,6 +37,9 @@ asking. Omit to always prompt. */
harness_id?: CreateAgentRequestHarnessId;
/** Instructions supplied to the agent at the start of a conversation. */
instructions: string;
+ /** Whether the agent is a coding agent: a mention is answered with a magic
+chip into its live session (`true`) or a reply in the thread (`false`). */
+ is_coding: boolean;
/** Which MCP servers sessions of this agent are handed. */
mcp?: AgentMcpServers;
/** Display name. */
diff --git a/apps/web/src/lib/service-clients/service-storage/generated/schemas/updateAgentRequest.ts b/apps/web/src/lib/service-clients/service-storage/generated/schemas/updateAgentRequest.ts
index 02c4098b17..4d56db8ffc 100644
--- a/apps/web/src/lib/service-clients/service-storage/generated/schemas/updateAgentRequest.ts
+++ b/apps/web/src/lib/service-clients/service-storage/generated/schemas/updateAgentRequest.ts
@@ -37,6 +37,9 @@ asking. Omit to always prompt. */
harness_id?: UpdateAgentRequestHarnessId;
/** Instructions supplied to the agent at the start of a conversation. */
instructions: string;
+ /** Whether the agent is a coding agent: a mention is answered with a magic
+chip into its live session (`true`) or a reply in the thread (`false`). */
+ is_coding: boolean;
/** Which MCP servers sessions of this agent are handed. */
mcp?: AgentMcpServers;
/** Display name. */
diff --git a/apps/web/src/lib/service-clients/service-storage/generated/zod.ts b/apps/web/src/lib/service-clients/service-storage/generated/zod.ts
index 6f3db0a4bd..139fcba30d 100644
--- a/apps/web/src/lib/service-clients/service-storage/generated/zod.ts
+++ b/apps/web/src/lib/service-clients/service-storage/generated/zod.ts
@@ -83,6 +83,11 @@ export const listAgentsResponseItem = zod
.describe(
'Instructions supplied to the agent at the start of a conversation.'
),
+ is_coding: zod
+ .boolean()
+ .describe(
+ "Whether the agent works in a repository, which decides how it answers\na channel mention: a coding agent posts a magic chip into its live\nsession, a chat agent replies in the thread. Chosen in the agent's\nsettings; the persona's word, not the runtime's."
+ ),
mcp: zod
.union([
zod
@@ -161,6 +166,11 @@ export const createAgentBody = zod
.describe(
'Instructions supplied to the agent at the start of a conversation.'
),
+ is_coding: zod
+ .boolean()
+ .describe(
+ 'Whether the agent is a coding agent: a mention is answered with a magic\nchip into its live session (`true`) or a reply in the thread (`false`).'
+ ),
mcp: zod
.union([
zod
@@ -248,6 +258,11 @@ export const updateAgentBody = zod
.describe(
'Instructions supplied to the agent at the start of a conversation.'
),
+ is_coding: zod
+ .boolean()
+ .describe(
+ 'Whether the agent is a coding agent: a mention is answered with a magic\nchip into its live session (`true`) or a reply in the thread (`false`).'
+ ),
mcp: zod
.union([
zod
@@ -369,6 +384,11 @@ export const updateAgentResponse = zod
.describe(
'Instructions supplied to the agent at the start of a conversation.'
),
+ is_coding: zod
+ .boolean()
+ .describe(
+ "Whether the agent works in a repository, which decides how it answers\na channel mention: a coding agent posts a magic chip into its live\nsession, a chat agent replies in the thread. Chosen in the agent's\nsettings; the persona's word, not the runtime's."
+ ),
mcp: zod
.union([
zod
diff --git a/apps/web/src/lib/service-clients/service-storage/openapi.json b/apps/web/src/lib/service-clients/service-storage/openapi.json
index cf75b9ea5b..4397c52c3a 100644
--- a/apps/web/src/lib/service-clients/service-storage/openapi.json
+++ b/apps/web/src/lib/service-clients/service-storage/openapi.json
@@ -14778,7 +14778,8 @@
"default_model",
"channel_scope",
"channel_ids",
- "mcp"
+ "mcp",
+ "is_coding"
],
"properties": {
"auto_accept_permissions": {
@@ -14824,6 +14825,10 @@
"type": "string",
"description": "Instructions supplied to the agent at the start of a conversation."
},
+ "is_coding": {
+ "type": "boolean",
+ "description": "Whether the agent works in a repository, which decides how it answers\na channel mention: a coding agent posts a magic chip into its live\nsession, a chat agent replies in the thread. Chosen in the agent's\nsettings; the persona's word, not the runtime's."
+ },
"mcp": {
"$ref": "#/components/schemas/AgentMcpServers",
"description": "Which MCP servers sessions of this agent are handed."
@@ -19242,7 +19247,8 @@
"instructions",
"harness",
"default_model",
- "channel_scope"
+ "channel_scope",
+ "is_coding"
],
"properties": {
"auto_accept_permissions": {
@@ -19296,6 +19302,10 @@
"type": "string",
"description": "Instructions supplied to the agent at the start of a conversation."
},
+ "is_coding": {
+ "type": "boolean",
+ "description": "Whether the agent is a coding agent: a mention is answered with a magic\nchip into its live session (`true`) or a reply in the thread (`false`)."
+ },
"mcp": {
"$ref": "#/components/schemas/AgentMcpServers",
"description": "Which MCP servers sessions of this agent are handed."
@@ -30814,7 +30824,8 @@
"instructions",
"harness",
"default_model",
- "channel_scope"
+ "channel_scope",
+ "is_coding"
],
"properties": {
"auto_accept_permissions": {
@@ -30868,6 +30879,10 @@
"type": "string",
"description": "Instructions supplied to the agent at the start of a conversation."
},
+ "is_coding": {
+ "type": "boolean",
+ "description": "Whether the agent is a coding agent: a mention is answered with a magic\nchip into its live session (`true`) or a reply in the thread (`false`)."
+ },
"mcp": {
"$ref": "#/components/schemas/AgentMcpServers",
"description": "Which MCP servers sessions of this agent are handed."
diff --git a/crates/agent_harness/src/domain/model.rs b/crates/agent_harness/src/domain/model.rs
index 1c8226fd21..0a6479358a 100644
--- a/crates/agent_harness/src/domain/model.rs
+++ b/crates/agent_harness/src/domain/model.rs
@@ -216,11 +216,15 @@ impl AgentKind {
/// Whether this kind's sessions work in a repository.
///
- /// Decides how a mention is answered in its thread. A coding runtime runs
- /// for minutes and produces diffs, so its turn is announced as a magic
- /// chip - a live portal into the session. The in-memory runtime has no
- /// repository and chats, so its thread gets a pending reply that becomes
- /// the answer when the turn ends, the way the original Macro bot replied.
+ /// The runtime's nature, and what a persona is taken to be for until it
+ /// says otherwise: how a mention is answered in its thread is the
+ /// persona's choice ([`is_coding_agent`]), and this is the default for
+ /// one that has not chosen and the answer for the fixed system bots. A
+ /// coding runtime runs for minutes and produces diffs, so its turn is
+ /// announced as a magic chip - a live portal into the session. The
+ /// in-memory runtime has no repository and chats, so its thread gets a
+ /// pending reply that becomes the answer when the turn ends, the way the
+ /// original Macro bot replied.
#[must_use]
pub const fn is_coding(self) -> bool {
!matches!(self, Self::InMemory)
@@ -246,6 +250,30 @@ impl AgentKind {
}
}
+/// Whether a session's turns are announced as a coding agent's.
+///
+/// A persona's setting is the source of truth. The fixed system bots have no
+/// persona and so no setting; `choice` is `None` for them alone, and the
+/// runtime's nature ([`AgentKind::is_coding`]) decides.
+#[must_use]
+pub const fn is_coding_agent(choice: Option<bool>, kind: AgentKind) -> bool {
+ match choice {
+ Some(chosen) => chosen,
+ None => kind.is_coding(),
+ }
+}
+
+/// The persona a session's thread replies speak as, read from its bot at
+/// the moment of speaking.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub struct ReplyPersona {
+ /// The bot's display name, what a link to the session is labelled.
+ pub name: String,
+ /// Whether the turn is announced as a magic chip (coding) or answered
+ /// as a reply in the thread (chat); see [`is_coding_agent`].
+ pub is_coding: bool,
+}
+
/// Stored facts used by the domain to choose a session permission policy.
pub enum PermissionPolicyConfig {
/// A fixed system bot with no editable persona configuration.
@@ -524,9 +552,9 @@ pub struct SessionAnnouncement {
pub session_id: AgentSessionId,
/// The bot the session runs for; the announcement posts as it.
pub bot_id: BotId,
- /// The runtime serving the session, which decides what the announcement
- /// looks like (see [`AgentKind::is_coding`]).
- pub kind: AgentKind,
+ /// Whether the announcement is a coding agent's magic chip or a chat
+ /// agent's pending reply (see [`is_coding_agent`]).
+ pub is_coding: bool,
/// Channel or document containing the mention that opened the session.
pub origin_parent: messages::domain::models::MessageParent,
/// Thread where the announcement should be posted.
@@ -645,9 +673,9 @@ pub struct ResolvedReply {
pub session_id: AgentSessionId,
/// The bot the session runs for; the patch is made as it.
pub bot_id: BotId,
- /// The runtime serving the session. A coding runtime's chip renders
- /// the turn itself, so there is nothing to resolve for one.
- pub kind: AgentKind,
+ /// Whether the session's bot is a coding agent. A coding agent's chip
+ /// renders the turn itself, so there is nothing to resolve for one.
+ pub is_coding: bool,
/// The pending reply posted when the turn was announced.
pub message_id: Uuid,
/// Channel or document the mention was posted in.
diff --git a/crates/agent_harness/src/domain/model/test.rs b/crates/agent_harness/src/domain/model/test.rs
index 62c53b0de9..ea5503cb01 100644
--- a/crates/agent_harness/src/domain/model/test.rs
+++ b/crates/agent_harness/src/domain/model/test.rs
@@ -160,6 +160,16 @@ fn only_the_in_memory_runtime_is_not_a_coder() {
}
}
+/// The persona's choice wins; without one, the runtime's nature decides.
+#[test]
+fn a_persona_chooses_whether_it_codes_and_otherwise_follows_its_runtime() {
+ for kind in [AgentKind::InMemory, AgentKind::External, AgentKind::Cursor] {
+ assert!(is_coding_agent(Some(true), kind), "{kind:?}");
+ assert!(!is_coding_agent(Some(false), kind), "{kind:?}");
+ assert_eq!(is_coding_agent(None, kind), kind.is_coding(), "{kind:?}");
+ }
+}
+
#[test]
fn a_turn_with_text_answered_however_it_stopped() {
for stop in [
diff --git a/crates/agent_harness/src/domain/notifications.rs b/crates/agent_harness/src/domain/notifications.rs
index d3b1629ef1..bffdf24282 100644
--- a/crates/agent_harness/src/domain/notifications.rs
+++ b/crates/agent_harness/src/domain/notifications.rs
@@ -16,8 +16,10 @@
//!
//! Everything else is nobody's news.
//!
-//! The session's [`AgentKind`] comes in beside the fact because the fact
-//! does not carry it: a chat agent's announced turn ends by patching its
+//! Whether the session's bot is a coding agent comes in beside the fact
+//! because the fact does not carry it (see
+//! [`crate::domain::model::is_coding_agent`]): a chat agent's announced
+//! turn ends by patching its
//! pending reply into the thread, and the message service notifies on that
//! patch as if the answer had just been posted, so a `settled` notification
//! on top would tell the same people the same thing twice. The same reply
@@ -59,8 +61,6 @@ use notification::domain::models::apple::PushNotificationData;
use notification::domain::models::request::SendNotificationRequestBuilder;
use notification::domain::models::{Notification, SendNotificationRequest};
-use super::model::AgentKind;
-
/// The namespace agent-session notification ids are derived in. Fixed
/// forever: changing it would orphan every retraction of a notification
/// created before the change.
@@ -129,12 +129,14 @@ impl PlannedNotification {
}
}
-/// The notifications one lifecycle fact about a `kind` session warrants.
+/// The notifications one lifecycle fact about a session warrants, given
+/// whether its bot is a coding agent (`is_coding`, see
+/// [`crate::domain::model::is_coding_agent`]).
#[must_use]
-pub fn plan(event: &AgentSessionLifecycleEvent, kind: AgentKind) -> Vec<PlannedNotification> {
+pub fn plan(event: &AgentSessionLifecycleEvent, is_coding: bool) -> Vec<PlannedNotification> {
match event {
- AgentSessionLifecycleEvent::Settled(settled) => plan_settled(settled, kind),
- AgentSessionLifecycleEvent::WaitingForInput(waiting) => plan_waiting(waiting, kind),
+ AgentSessionLifecycleEvent::Settled(settled) => plan_settled(settled, is_coding),
+ AgentSessionLifecycleEvent::WaitingForInput(waiting) => plan_waiting(waiting, is_coding),
AgentSessionLifecycleEvent::Mentioned(mentioned) => plan_mentioned(mentioned),
AgentSessionLifecycleEvent::Opened(_)
| AgentSessionLifecycleEvent::TurnStarted(_)
@@ -146,7 +148,7 @@ pub fn plan(event: &AgentSessionLifecycleEvent, kind: AgentKind) -> Vec<PlannedN
}
}
-fn plan_settled(settled: &SessionSettledMetadata, kind: AgentKind) -> Vec<PlannedNotification> {
+fn plan_settled(settled: &SessionSettledMetadata, is_coding: bool) -> Vec<PlannedNotification> {
// "Settled" without the turn's record is a fact nobody can act on: no
// excerpt, no chip, no turn to key the id by.
let Some(turn) = &settled.last_turn else {
@@ -154,7 +156,7 @@ fn plan_settled(settled: &SessionSettledMetadata, kind: AgentKind) -> Vec<Planne
};
// A chat agent's announced turn already told the thread: its pending
// reply was patched into the answer, and that patch notifies as a post.
- if !kind.is_coding() && turn.announcement_message_id.is_some() {
+ if !is_coding && turn.announcement_message_id.is_some() {
return Vec::new();
}
let (entity, secondary_entity) = entities(&settled.identity);
@@ -173,11 +175,11 @@ fn plan_settled(settled: &SessionSettledMetadata, kind: AgentKind) -> Vec<Planne
})]
}
-fn plan_waiting(waiting: &WaitingForInputMetadata, kind: AgentKind) -> Vec<PlannedNotification> {
+fn plan_waiting(waiting: &WaitingForInputMetadata, is_coding: bool) -> Vec<PlannedNotification> {
// A chat agent's announced turn tells its thread it is waiting the same
// way it tells it the answer: by patching its pending reply, which
// notifies as a post.
- if !kind.is_coding() && waiting.announcement_message_id.is_some() {
+ if !is_coding && waiting.announcement_message_id.is_some() {
return Vec::new();
}
let (entity, secondary_entity) = entities(&waiting.identity);
diff --git a/crates/agent_harness/src/domain/notifications/test.rs b/crates/agent_harness/src/domain/notifications/test.rs
index db1be7e037..f8e1eef8d4 100644
--- a/crates/agent_harness/src/domain/notifications/test.rs
+++ b/crates/agent_harness/src/domain/notifications/test.rs
@@ -62,7 +62,7 @@ fn settled(identity: SessionIdentity, turn: u32) -> AgentSessionLifecycleEvent {
/// The plan for a coding agent's session - the shape every fact had before
/// kinds could differ.
fn coder(event: &AgentSessionLifecycleEvent) -> Vec<PlannedNotification> {
- plan(event, AgentKind::SandboxedCoder)
+ plan(event, true)
}
fn one_settled(actions: Vec<PlannedNotification>) -> Notify<AgentSessionSettledMetadata> {
@@ -143,7 +143,7 @@ fn settled_ids_are_stable_per_turn_and_distinct_across_turns() {
/// reply, which the message service notifies on as a post.
#[test]
fn a_chat_agents_announced_turn_settles_silently() {
- let actions = plan(&settled(identity(), 2), AgentKind::InMemory);
+ let actions = plan(&settled(identity(), 2), false);
assert!(actions.is_empty(), "{actions:#?}");
}
@@ -164,7 +164,7 @@ fn a_chat_agents_unannounced_turn_still_notifies() {
}),
});
- let notify = one_settled(plan(&event, AgentKind::InMemory));
+ let notify = one_settled(plan(&event, false));
assert_eq!(
notify.recipients,
vec![owner(), user("[email protected]"), user("[email protected]")]
@@ -173,23 +173,14 @@ fn a_chat_agents_unannounced_turn_still_notifies() {
}
/// A coding agent's chip is a pointer, not news, so settled is the only
-/// thing the thread hears - whichever coding runtime it was.
+/// thing the thread hears.
#[test]
-fn every_coding_kinds_announced_turn_notifies_settled() {
- for kind in [
- AgentKind::SandboxedCoder,
- AgentKind::Cursor,
- AgentKind::CodexCloud,
- AgentKind::ClaudeCloud,
- AgentKind::External,
- ] {
- let notify = one_settled(plan(&settled(identity(), 2), kind));
- assert_eq!(
- notify.metadata.session.announcement_message_id,
- Some(Uuid::from_u128(4)),
- "{kind:?}"
- );
- }
+fn a_coding_agents_announced_turn_notifies_settled() {
+ let notify = one_settled(plan(&settled(identity(), 2), true));
+ assert_eq!(
+ notify.metadata.session.announcement_message_id,
+ Some(Uuid::from_u128(4))
+ );
}
#[test]
@@ -246,7 +237,7 @@ fn waiting(announcement_message_id: Option<Uuid>) -> AgentSessionLifecycleEvent
/// news twice.
#[test]
fn a_chat_agents_announced_turn_waits_silently() {
- let actions = plan(&waiting(Some(Uuid::from_u128(4))), AgentKind::InMemory);
+ let actions = plan(&waiting(Some(Uuid::from_u128(4))), false);
assert!(actions.is_empty(), "{actions:#?}");
}
@@ -256,19 +247,18 @@ fn a_chat_agents_announced_turn_waits_silently() {
/// agent's chip says nothing about a question.
#[test]
fn every_other_waiting_turn_still_notifies() {
- for (kind, announced) in [
- (AgentKind::InMemory, None),
- (AgentKind::SandboxedCoder, Some(Uuid::from_u128(4))),
- (AgentKind::Cursor, Some(Uuid::from_u128(4))),
- (AgentKind::External, None),
+ for (is_coding, announced) in [
+ (false, None),
+ (true, Some(Uuid::from_u128(4))),
+ (true, None),
] {
- let actions = plan(&waiting(announced), kind);
+ let actions = plan(&waiting(announced), is_coding);
assert!(
matches!(
actions.as_slice(),
[PlannedNotification::WaitingForInput(_)]
),
- "{kind:?} announced={announced:?}: {actions:#?}"
+ "is_coding={is_coding} announced={announced:?}: {actions:#?}"
);
}
}
diff --git a/crates/agent_harness/src/domain/ports.rs b/crates/agent_harness/src/domain/ports.rs
index 7adcaaa0d6..4c1fa0daa5 100644
--- a/crates/agent_harness/src/domain/ports.rs
+++ b/crates/agent_harness/src/domain/ports.rs
@@ -117,6 +117,21 @@ pub trait PermissionPolicySource: Send + Sync + 'static {
) -> impl Future<Output = anyhow::Result<PermissionPolicyConfig>> + Send;
}
+/// Loads a persona's choice of whether it is a coding agent.
+///
+/// Read when a turn is announced or its reply resolved, like
+/// [`PermissionPolicySource`] is read on attach, so changing the agent's
+/// setting takes effect on its next turn. The domain applies the choice
+/// with [`crate::domain::model::is_coding_agent`].
+pub trait CodingAgentSource: Send + Sync + 'static {
+ /// The persona's setting for `bot`; `None` only for a fixed system bot,
+ /// which has no persona.
+ fn coding_agent_choice(
+ &self,
+ bot: BotId,
+ ) -> impl Future<Output = anyhow::Result<Option<bool>>> + Send;
+}
+
/// Durable attach/detach bookkeeping for harness runtime connections.
///
/// The registry itself is in-process liveness; this is what lets the rest of
diff --git a/crates/agent_harness/src/domain/service.rs b/crates/agent_harness/src/domain/service.rs
index 58134e4b1f..3cf3c7125e 100644
--- a/crates/agent_harness/src/domain/service.rs
+++ b/crates/agent_harness/src/domain/service.rs
@@ -53,9 +53,9 @@ use crate::domain::model::{
};
use crate::domain::pending::PendingCommands;
use crate::domain::ports::{
- AgentPromptComposer, AgentSessionNotifier, CommandForwarder, ContainerManager,
- MessagePromptContext, PermissionPolicySource, PromptMentions, RuntimeConnections,
- SandboxEgressProvisioner, SessionAnnouncer,
+ AgentPromptComposer, AgentSessionNotifier, CodingAgentSource, CommandForwarder,
+ ContainerManager, MessagePromptContext, PermissionPolicySource, PromptMentions,
+ RuntimeConnections, SandboxEgressProvisioner, SessionAnnouncer,
};
use crate::domain::queue::{InFlightTurn, QueueError, QueuedEntry, SessionQueues};
use crate::domain::sandbox::SandboxResizeEffect;
@@ -92,6 +92,24 @@ impl<S: PermissionPolicySource> ErasedPermissionPolicySource for S {
}
}
+/// [`CodingAgentSource`], object-safe, erased like
+/// [`ErasedPermissionPolicySource`].
+trait ErasedCodingAgentSource: Send + Sync + 'static {
+ fn coding_agent_choice<'a>(
+ &'a self,
+ bot: BotId,
+ ) -> std::pin::Pin<Box<dyn Future<Output = anyhow::Result<Option<bool>>> + Send + 'a>>;
+}
+
+impl<S: CodingAgentSource> ErasedCodingAgentSource for S {
+ fn coding_agent_choice<'a>(
+ &'a self,
+ bot: BotId,
+ ) -> std::pin::Pin<Box<dyn Future<Output = anyhow::Result<Option<bool>>> + Send + 'a>> {
+ Box::pin(CodingAgentSource::coding_agent_choice(self, bot))
+ }
+}
+
struct AgentHarnessInner<
Sessions,
Containers,
@@ -113,6 +131,7 @@ struct AgentHarnessInner<
egress: Egress,
forwarder: Box<dyn ErasedForwarder>,
permission_policies: Box<dyn ErasedPermissionPolicySource>,
+ coding_agents: Box<dyn ErasedCodingAgentSource>,
defaults: HarnessDefaults,
/// Turn-occupying actions waiting for their session's running turn to
/// end. In-memory beside the live actors this replica manages.
@@ -284,6 +303,7 @@ where
egress: Egress,
forwarder: impl CommandForwarder,
permission_policies: impl PermissionPolicySource,
+ coding_agents: impl CodingAgentSource,
defaults: impl Into<HarnessDefaults>,
lifecycle_publisher: Lifecycle,
pending: PendingCommands,
@@ -301,6 +321,7 @@ where
egress,
forwarder: Box::new(forwarder),
permission_policies: Box::new(permission_policies),
+ coding_agents: Box::new(coding_agents),
defaults: defaults.into(),
queues: SessionQueues::new(),
busy: pending,
@@ -382,12 +403,13 @@ where
return Ok(());
}
+ let persona = self.inner.reply_persona(&session).await?;
self.inner
.announcer
.announce(SessionAnnouncement {
session_id,
bot_id: session.bot_id,
- kind: AgentKind::for_session(session.bot_id, &session.harness),
+ is_coding: persona.is_coding,
origin_parent: prompt.origin.parent,
origin_thread_id: prompt.origin.thread_id,
origin_message_id: prompt.origin.message_id,
diff --git a/crates/agent_harness/src/domain/service/deliver.rs b/crates/agent_harness/src/domain/service/deliver.rs
index ba9ac278ec..3d1fe196a5 100644
--- a/crates/agent_harness/src/domain/service/deliver.rs
+++ b/crates/agent_harness/src/domain/service/deliver.rs
@@ -227,11 +227,12 @@ where
// The announcement posts as the session's own bot, which only the
// row remembers.
let session = self.sessions.get_session(session_id).await?;
+ let persona = self.reply_persona(&session).await?;
Ok(Some(SessionAnnouncement {
session_id,
bot_id: session.bot_id,
- kind: AgentKind::for_session(session.bot_id, &session.harness),
+ is_coding: persona.is_coding,
origin_parent: origin.parent,
origin_thread_id: origin.thread_id,
origin_message_id: origin.message_id,
@@ -246,11 +247,10 @@ where
///
/// Best-effort, like every lifecycle publish: the turn is over or still
/// running regardless, and the queue behind it drains whether or not the
- /// thread hears. The bot and runtime kind are re-read from the row, as
- /// they were when the turn was announced. A turn nobody announced - no
- /// origin, no actor, or no message posted - has nothing to resolve.
- /// Whether the kind's message needs resolving at all is the announcer's
- /// call.
+ /// thread hears. The bot and its persona are re-read as they were when
+ /// the turn was announced. A turn nobody announced - no origin, no
+ /// actor, or no message posted - has nothing to resolve. Whether the
+ /// persona's message needs resolving at all is the announcer's call.
pub(super) async fn resolve_reply(
&self,
session_id: AgentSessionId,
@@ -279,12 +279,24 @@ where
return;
}
};
+ let persona = match self.reply_persona(&session).await {
+ Ok(persona) => persona,
+ Err(error) => {
+ tracing::error!(
+ error = ?error,
+ %session_id,
+ %message_id,
+ "leaving a turn's reply unresolved: the session's persona is unavailable"
+ );
+ return;
+ }
+ };
if let Err(error) = self
.announcer
.resolve(ResolvedReply {
session_id,
bot_id: session.bot_id,
- kind: AgentKind::for_session(session.bot_id, &session.harness),
+ is_coding: persona.is_coding,
message_id,
origin_parent: origin.parent.clone(),
triggered_by: triggered_by.clone(),
diff --git a/crates/agent_harness/src/domain/service/lifecycle_events.rs b/crates/agent_harness/src/domain/service/lifecycle_events.rs
index c18d0484d5..8114aed69c 100644
--- a/crates/agent_harness/src/domain/service/lifecycle_events.rs
+++ b/crates/agent_harness/src/domain/service/lifecycle_events.rs
@@ -6,6 +6,7 @@ use agent_session::domain::events::{
};
use agent_session::domain::lifecycle::session_identity;
+use crate::domain::model::{ReplyPersona, is_coding_agent};
use crate::domain::notifications::plan;
use macro_user_id::user_id::MacroUserIdStr;
@@ -49,23 +50,43 @@ where
{
/// The identity block for one session, from its row and its bot.
pub(super) async fn identity(&self, session_id: AgentSessionId) -> Result<SessionIdentity> {
- self.identity_and_kind(session_id)
- .await
- .map(|(identity, _)| identity)
+ let session = self.sessions.get_session(session_id).await?;
+ self.identity_of(&session).await
}
- /// [`Self::identity`], with the runtime kind the same row names - read
- /// together because the notifications a fact warrants depend on both.
- pub(super) async fn identity_and_kind(
+ /// [`Self::identity`], with whether the session's bot is a coding agent -
+ /// read together because the notifications a fact warrants depend on
+ /// both.
+ pub(super) async fn identity_and_coding(
&self,
session_id: AgentSessionId,
- ) -> Result<(SessionIdentity, AgentKind)> {
+ ) -> Result<(SessionIdentity, bool)> {
let session = self.sessions.get_session(session_id).await?;
- let identity = self.identity_of(&session).await?;
- Ok((
- identity,
- AgentKind::for_session(session.bot_id, &session.harness),
- ))
+ let (identity, persona) =
+ tokio::try_join!(self.identity_of(&session), self.reply_persona(&session))?;
+ Ok((identity, persona.is_coding))
+ }
+
+ /// The persona a session's thread replies speak as: its bot's name, and
+ /// the bot's choice of being a coding agent applied to the runtime the
+ /// row names.
+ pub(super) async fn reply_persona(&self, session: &AgentSession) -> Result<ReplyPersona> {
+ let (bot, choice) = tokio::try_join!(
+ async { Ok::<_, HarnessError>(self.sessions.session_bot(session.bot_id).await?) },
+ async {
+ self.coding_agents
+ .coding_agent_choice(session.bot_id)
+ .await
+ .map_err(|error| HarnessError::Announce(rootcause::report!(error).into()))
+ },
+ )?;
+ Ok(ReplyPersona {
+ name: bot.name,
+ is_coding: is_coding_agent(
+ choice,
+ AgentKind::for_session(session.bot_id, &session.harness),
+ ),
+ })
}
/// The identity block for a session whose row is already in hand.
@@ -89,10 +110,10 @@ where
session_id: AgentSessionId,
build: impl FnOnce(SessionIdentity) -> AgentSessionLifecycleEvent,
) {
- match self.identity_and_kind(session_id).await {
- Ok((identity, kind)) => {
+ match self.identity_and_coding(session_id).await {
+ Ok((identity, is_coding)) => {
let event = build(identity);
- let notifications = plan(&event, kind);
+ let notifications = plan(&event, is_coding);
self.lifecycle_publisher.publish(event).await;
for notification in notifications {
self.notifier.notify(notification).await;
diff --git a/crates/agent_harness/src/domain/service/open.rs b/crates/agent_harness/src/domain/service/open.rs
index 990d1b08f5..09f1e69a72 100644
--- a/crates/agent_harness/src/domain/service/open.rs
+++ b/crates/agent_harness/src/domain/service/open.rs
@@ -121,18 +121,22 @@ where
self.inner.publish_opened(&session).await;
if let Some(thread) = request.thread {
- let announcement = SessionAnnouncement {
- session_id: session.id,
- bot_id: request.bot_id,
- kind: AgentKind::for_session(session.bot_id, &session.harness),
- origin_parent: thread.parent,
- origin_thread_id: thread.thread_id,
- origin_message_id: thread.message_id,
- prompted_message_id: MessageId::first(AuthorKind::User),
- prompted_content: thread.content,
- triggered_by: owner_user,
+ let announce = async {
+ let persona = self.inner.reply_persona(&session).await?;
+ let announcement = SessionAnnouncement {
+ session_id: session.id,
+ bot_id: request.bot_id,
+ is_coding: persona.is_coding,
+ origin_parent: thread.parent,
+ origin_thread_id: thread.thread_id,
+ origin_message_id: thread.message_id,
+ prompted_message_id: MessageId::first(AuthorKind::User),
+ prompted_content: thread.content,
+ triggered_by: owner_user,
+ };
+ self.inner.announcer.announce(announcement).await
};
- if let Err(error) = self.inner.announcer.announce(announcement).await {
+ if let Err(error) = announce.await {
tracing::warn!(
error = ?error,
session = %session.id,
diff --git a/crates/agent_harness/src/domain/service/test.rs b/crates/agent_harness/src/domain/service/test.rs
index 4403f4100e..4155d20eee 100644
--- a/crates/agent_harness/src/domain/service/test.rs
+++ b/crates/agent_harness/src/domain/service/test.rs
@@ -281,6 +281,25 @@ impl crate::domain::ports::PermissionPolicySource for KindDefaultPolicies {
}
}
+/// No persona has chosen: every bot's turns are announced as its runtime's
+/// nature says.
+struct HarnessDefaultCodingAgents;
+
+impl crate::domain::ports::CodingAgentSource for HarnessDefaultCodingAgents {
+ async fn coding_agent_choice(&self, _: BotId) -> anyhow::Result<Option<bool>> {
+ Ok(None)
+ }
+}
+
+/// Every persona made the same choice, whatever its runtime.
+struct ChosenCodingAgents(bool);
+
+impl crate::domain::ports::CodingAgentSource for ChosenCodingAgents {
+ async fn coding_agent_choice(&self, _: BotId) -> anyhow::Result<Option<bool>> {
+ Ok(Some(self.0))
+ }
+}
+
fn harness_for_bot(bot: BotId) -> harness_id::HarnessId {
harness_id::HarnessId::new_from_uuid(bot.as_uuid())
}
@@ -403,6 +422,32 @@ fn harness_with_policies_and_mentions(
prompt_composer: PromptComposerMock,
permission_policies: impl crate::domain::ports::PermissionPolicySource,
mentions: PromptMentionsMock,
+) -> (TestBench, TurnSignals) {
+ harness_with_ports(
+ prompt_context,
+ prompt_composer,
+ permission_policies,
+ HarnessDefaultCodingAgents,
+ mentions,
+ )
+}
+
+fn harness_with_coding_choice(chosen: bool) -> (TestBench, TurnSignals) {
+ harness_with_ports(
+ PromptContextMock::default(),
+ PromptComposerMock::default(),
+ KindDefaultPolicies,
+ ChosenCodingAgents(chosen),
+ PromptMentionsMock::new(),
+ )
+}
+
+fn harness_with_ports(
+ prompt_context: PromptContextMock,
+ prompt_composer: PromptComposerMock,
+ permission_policies: impl crate::domain::ports::PermissionPolicySource,
+ coding_agents: impl crate::domain::ports::CodingAgentSource,
+ mentions: PromptMentionsMock,
) -> (TestBench, TurnSignals) {
let repo = InMemoryAgentSessionRepo::new();
let containers = MockContainerManager::new();
@@ -433,6 +478,7 @@ fn harness_with_policies_and_mentions(
EgressProvisionerMock::new(),
NoPeers,
permission_policies,
+ coding_agents,
HarnessDefaults::new(SessionDefaults {
bot_id: BotId::TEST_A,
model: "claude".to_owned(),
@@ -2701,6 +2747,7 @@ async fn a_managed_session_opens_as_the_managed_default_bot() {
EgressProvisionerMock::new(),
NoPeers,
KindDefaultPolicies,
+ HarnessDefaultCodingAgents,
HarnessDefaults::new(SessionDefaults {
bot_id: BotId::TEST_A,
model: "claude".to_owned(),
@@ -3200,6 +3247,7 @@ async fn commands_for_a_peer_managed_session_forward_through_redis() {
EgressProvisionerMock::new(),
forwarder.clone(),
KindDefaultPolicies,
+ HarnessDefaultCodingAgents,
SessionDefaults {
bot_id: BotId::TEST_A,
model: "claude".to_owned(),
@@ -3252,6 +3300,7 @@ async fn unmanaged_external_session_forwards_to_its_remote_harness() {
EgressProvisionerMock::new(),
forwarder.clone(),
KindDefaultPolicies,
+ HarnessDefaultCodingAgents,
SessionDefaults {
bot_id: BotId::TEST_A,
model: "claude".to_owned(),
diff --git a/crates/agent_harness/src/domain/service/test/chat_reply.rs b/crates/agent_harness/src/domain/service/test/chat_reply.rs
index bbfa454ba4..dcdc7b4f8d 100644
--- a/crates/agent_harness/src/domain/service/test/chat_reply.rs
+++ b/crates/agent_harness/src/domain/service/test/chat_reply.rs
@@ -21,7 +21,17 @@ async fn chat_session_with_a_running_turn(
containers: &MockContainerManager,
id: AgentSessionId,
) -> ContainerMock {
- let open = service.execute(id, HarnessCommand::Open(chat_open_command()));
+ session_with_a_running_turn(service, containers, id, chat_open_command()).await
+}
+
+/// Open the session `command` asks for and leave its first turn running.
+async fn session_with_a_running_turn(
+ service: &TestHarness,
+ containers: &MockContainerManager,
+ id: AgentSessionId,
+ command: OpenSession,
+) -> ContainerMock {
+ let open = service.execute(id, HarnessCommand::Open(command));
let drive = async {
loop {
if containers.spawned() == 1 {
@@ -82,10 +92,10 @@ async fn a_chat_mention_is_announced_as_a_pending_reply_and_resolved_with_the_an
let announced = announcer.announced();
assert_eq!(announced.len(), 1);
- assert_eq!(announced[0].kind, AgentKind::InMemory);
+ assert!(!announced[0].is_coding);
let pending = announcer.announced_messages()[0];
let resolved = one_resolved(&announcer);
- assert_eq!(resolved.kind, AgentKind::InMemory);
+ assert!(!resolved.is_coding);
assert_eq!(resolved.message_id, pending.message_id);
// The same bot, into the same parent, for the same person who asked.
assert_eq!(resolved.bot_id, announced[0].bot_id);
@@ -232,7 +242,7 @@ async fn a_coding_turn_is_offered_to_the_announcer_as_a_coder_and_still_notifies
turns.lifecycle_published(4).await;
let resolved = one_resolved(&announcer);
- assert_eq!(resolved.kind, AgentKind::SandboxedCoder);
+ assert!(resolved.is_coding);
assert_eq!(
resolved.message_id,
announcer.announced_messages()[0].message_id
@@ -247,6 +257,61 @@ async fn a_coding_turn_is_offered_to_the_announcer_as_a_coder_and_still_notifies
);
}
+/// The shape of the reply is the persona's to choose, not the runtime's: a
+/// bot that says it chats is answered with a reply even on a coding runtime,
+/// and its thread hears the answer through that reply rather than `settled`.
+#[tokio::test]
+async fn a_persona_that_chose_to_chat_gets_a_reply_on_a_coding_runtime() {
+ let ((service, _, containers, announcer, _), turns) = harness_with_coding_choice(false);
+ let id = AgentSessionId::new();
+ let mut command = open_command();
+ command.bot_id = bot_id::MACRO_CODER_BOT_ID;
+ command.origin.sender = staff_sender();
+ let container = session_with_a_running_turn(&service, &containers, id, command).await;
+ let agent = container.agent();
+
+ says(&agent, "Done.");
+ agent.completes_prompt().await;
+ turns.lifecycle_published(4).await;
+
+ let announced = announcer.announced();
+ assert_eq!(announced.len(), 1);
+ assert!(!announced[0].is_coding);
+ let resolved = one_resolved(&announcer);
+ assert!(!resolved.is_coding);
+ assert_eq!(resolved.outcome, ReplyOutcome::Answered("Done.".to_owned()));
+ assert!(
+ turns.notifier.notified().is_empty(),
+ "{:#?}",
+ turns.notifier.notified()
+ );
+}
+
+/// And the other way: a bot that says it codes is announced as a chip on
+/// the in-memory runtime, and its audience hears `settled`.
+#[tokio::test]
+async fn a_persona_that_chose_to_code_gets_a_chip_on_the_in_memory_runtime() {
+ let ((service, _, containers, announcer, _), turns) = harness_with_coding_choice(true);
+ let id = AgentSessionId::new();
+ let container = chat_session_with_a_running_turn(&service, &containers, id).await;
+ let agent = container.agent();
+
+ says(&agent, "Hello there.");
+ agent.completes_prompt().await;
+ turns.lifecycle_published(4).await;
+
+ assert!(announcer.announced()[0].is_coding);
+ assert!(one_resolved(&announcer).is_coding);
+ assert!(
+ matches!(
+ turns.notifier.notified().as_slice(),
+ [PlannedNotification::Settled(_)]
+ ),
+ "{:#?}",
+ turns.notifier.notified()
+ );
+}
+
/// A question the agent asks through ACP is held for the session view; the
/// thread's spinner has no way of knowing that on its own.
mod elicitation {
diff --git a/crates/agent_harness/src/outbound/channel_announcer.rs b/crates/agent_harness/src/outbound/channel_announcer.rs
index 18705da793..3f35d10670 100644
--- a/crates/agent_harness/src/outbound/channel_announcer.rs
+++ b/crates/agent_harness/src/outbound/channel_announcer.rs
@@ -1,14 +1,15 @@
//! Speak for an agent session in its originating thread through the shared
//! message service.
//!
-//! Two shapes, by the session's [`AgentKind`]: a coding agent's turn is a
-//! magic chip, a live portal into the session that renders the turn itself;
+//! Two shapes, by whether the session's bot is a coding agent: a coding
+//! agent's turn is a magic chip, a live portal into the session that renders
+//! the turn itself;
//! a chat agent's turn is a pending reply - the channel markdown's pulsing
//! await node - that is patched into the answer when the turn ends, the way
//! the original Macro bot replied, and that says so while the turn waits on
//! a question only the session view can answer. A chat agent's message
-//! leads with a link to its session in every state. The domain names the
-//! kind, this module chooses the words, and Lexical composes every node:
+//! leads with a link to its session in every state. The domain decides the
+//! shape, this module chooses the words, and Lexical composes every node:
//! no node syntax is written here.
#[cfg(test)]
@@ -213,7 +214,7 @@ impl<Access: EntityAccessService> SessionAnnouncer for MessageAnnouncer<Access>
&announcement.origin_parent,
)
.await?;
- let content = if announcement.kind.is_coding() {
+ let content = if announcement.is_coding {
self.lexical
.compose_agent_announcement(
&announcement_reply_target(&announcement),
@@ -258,7 +259,7 @@ impl<Access: EntityAccessService> SessionAnnouncer for MessageAnnouncer<Access>
}
async fn resolve(&self, resolution: ResolvedReply) -> Result<()> {
- if resolution.kind.is_coding() {
+ if resolution.is_coding {
return Ok(());
}
let access = self
diff --git a/crates/agent_harness/src/outbound/channel_announcer/test.rs b/crates/agent_harness/src/outbound/channel_announcer/test.rs
index 5fb766191c..8c580c2016 100644
--- a/crates/agent_harness/src/outbound/channel_announcer/test.rs
+++ b/crates/agent_harness/src/outbound/channel_announcer/test.rs
@@ -7,7 +7,7 @@ use bot_id::BotId;
fn announcement() -> SessionAnnouncement {
SessionAnnouncement {
bot_id: BotId::TEST_A,
- kind: crate::domain::model::AgentKind::SandboxedCoder,
+ is_coding: true,
session_id: agent_session::domain::model::AgentSessionId::TEST_A,
origin_parent: MessageParent::Channel(Uuid::from_u128(1)),
origin_thread_id: Uuid::from_u128(2),
diff --git a/crates/agent_harness/src/outbound/notifications/test.rs b/crates/agent_harness/src/outbound/notifications/test.rs
index ddb3b4537f..972ff15c28 100644
--- a/crates/agent_harness/src/outbound/notifications/test.rs
+++ b/crates/agent_harness/src/outbound/notifications/test.rs
@@ -14,7 +14,6 @@ use rootcause::Report;
use serde::Serialize;
use super::IngressAgentSessionNotifier;
-use crate::domain::model::AgentKind;
use crate::domain::notifications::plan;
use crate::domain::ports::AgentSessionNotifier;
@@ -76,7 +75,7 @@ async fn a_planned_notification_becomes_an_ingress_request() {
let ingress = Arc::new(RecordingIngress::default());
let notifier = IngressAgentSessionNotifier::new(Arc::clone(&ingress));
- for notification in plan(&settled(), AgentKind::SandboxedCoder) {
+ for notification in plan(&settled(), true) {
notifier.notify(notification).await;
}
@@ -102,7 +101,7 @@ async fn an_ingress_failure_is_swallowed() {
});
let notifier = IngressAgentSessionNotifier::new(ingress);
- for notification in plan(&settled(), AgentKind::SandboxedCoder) {
+ for notification in plan(&settled(), true) {
notifier.notify(notification).await;
}
}
diff --git a/crates/agent_trigger/src/domain/service/test.rs b/crates/agent_trigger/src/domain/service/test.rs
index 2ecde2ea9a..d2dd6f40a9 100644
--- a/crates/agent_trigger/src/domain/service/test.rs
+++ b/crates/agent_trigger/src/domain/service/test.rs
@@ -64,6 +64,7 @@ fn agent_with(bot_id: BotId, owner: BotOwner, channel_scope: AgentChannelScope)
channel_ids: vec![],
mcp: AgentMcpServers::OwnerConnections,
auto_accept_permissions: None,
+ is_coding: false,
}
}
diff --git a/crates/bots/src/domain/models.rs b/crates/bots/src/domain/models.rs
index 36bfb7962a..3bb31ce5ac 100644
--- a/crates/bots/src/domain/models.rs
+++ b/crates/bots/src/domain/models.rs
@@ -299,6 +299,11 @@ pub struct Agent {
/// Whether the agent's sessions approve ACP permission requests without
/// asking. `None` means always prompt. Bypass also requires the harness's opt-in.
pub auto_accept_permissions: Option<bool>,
+ /// Whether the agent works in a repository, which decides how it answers
+ /// a channel mention: a coding agent posts a magic chip into its live
+ /// session, a chat agent replies in the thread. Chosen in the agent's
+ /// settings; the persona's word, not the runtime's.
+ pub is_coding: bool,
}
/// Request to create a persisted AI agent.
@@ -337,6 +342,9 @@ pub struct CreateAgentRequest {
/// asking. Omit to always prompt.
#[serde(default)]
pub auto_accept_permissions: Option<bool>,
+ /// Whether the agent is a coding agent: a mention is answered with a magic
+ /// chip into its live session (`true`) or a reply in the thread (`false`).
+ pub is_coding: bool,
}
/// Request to replace the editable configuration of a persisted AI agent.
@@ -375,6 +383,9 @@ pub struct UpdateAgentRequest {
/// asking. Omit to always prompt.
#[serde(default)]
pub auto_accept_permissions: Option<bool>,
+ /// Whether the agent is a coding agent: a mention is answered with a magic
+ /// chip into its live session (`true`) or a reply in the thread (`false`).
+ pub is_coding: bool,
}
/// Channel containing a bot.
diff --git a/crates/bots/src/outbound/pg_bots_repo.rs b/crates/bots/src/outbound/pg_bots_repo.rs
index 19316ad504..48193de95d 100644
--- a/crates/bots/src/outbound/pg_bots_repo.rs
+++ b/crates/bots/src/outbound/pg_bots_repo.rs
@@ -120,6 +120,7 @@ struct AgentRow {
mcp_app_slugs: Vec<String>,
mcp_server_names: Vec<String>,
auto_accept_permissions: Option<bool>,
+ is_coding: bool,
}
impl TryFrom<AgentRow> for Agent {
@@ -170,6 +171,7 @@ impl TryFrom<AgentRow> for Agent {
channel_ids: row.channel_ids,
mcp,
auto_accept_permissions: row.auto_accept_permissions,
+ is_coding: row.is_coding,
})
}
}
@@ -360,9 +362,9 @@ impl BotRepo for PgBotsRepo {
sqlx::query!(
r#"
INSERT INTO agent_configs (
- bot_id, instructions, harness, harness_id, default_model, channel_scope, mcp_scope, auto_accept_permissions
+ bot_id, instructions, harness, harness_id, default_model, channel_scope, mcp_scope, auto_accept_permissions, is_coding
)
- VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
+ VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
"#,
bot_id.as_uuid(),
&req.instructions,
@@ -372,6 +374,7 @@ impl BotRepo for PgBotsRepo {
req.channel_scope.as_str(),
req.mcp.scope_str(),
req.auto_accept_permissions,
+ req.is_coding,
)
.execute(&mut *tx)
.await
@@ -407,6 +410,7 @@ impl BotRepo for PgBotsRepo {
default_model: req.default_model,
channel_scope: req.channel_scope,
auto_accept_permissions: req.auto_accept_permissions,
+ is_coding: req.is_coding,
channel_ids: req.channel_ids,
mcp: req.mcp,
})
@@ -480,6 +484,7 @@ impl BotRepo for PgBotsRepo {
channel_scope = $6,
mcp_scope = $7,
auto_accept_permissions = $8,
+ is_coding = $9,
updated_at = now()
WHERE bot_id = $1
"#,
@@ -491,6 +496,7 @@ impl BotRepo for PgBotsRepo {
req.channel_scope.as_str(),
req.mcp.scope_str(),
req.auto_accept_permissions,
+ req.is_coding,
)
.execute(&mut *tx)
.await
@@ -554,6 +560,7 @@ impl BotRepo for PgBotsRepo {
channel_ids: req.channel_ids,
mcp: req.mcp,
auto_accept_permissions: req.auto_accept_permissions,
+ is_coding: req.is_coding,
}))
}
@@ -584,6 +591,7 @@ impl BotRepo for PgBotsRepo {
a.default_model,
a.channel_scope,
a.auto_accept_permissions,
+ a.is_coding,
ARRAY(
SELECT p.channel_id
FROM comms_channel_participants p
@@ -961,6 +969,7 @@ impl BotRepo for PgBotsRepo {
a.default_model,
a.channel_scope,
a.auto_accept_permissions,
+ a.is_coding,
ARRAY(
SELECT p.channel_id
FROM comms_channel_participants p
diff --git a/crates/bots/src/outbound/pg_bots_repo/tests.rs b/crates/bots/src/outbound/pg_bots_repo/tests.rs
index 254deebe5c..601fee58bd 100644
--- a/crates/bots/src/outbound/pg_bots_repo/tests.rs
+++ b/crates/bots/src/outbound/pg_bots_repo/tests.rs
@@ -84,6 +84,7 @@ fn create_agent_req(handle: &str, channel_scope: AgentChannelScope) -> CreateAge
channel_ids: Vec::new(),
mcp: AgentMcpServers::OwnerConnections,
auto_accept_permissions: None,
+ is_coding: true,
}
}
@@ -102,6 +103,7 @@ fn update_agent_req(handle: &str, channel_scope: AgentChannelScope) -> UpdateAge
channel_ids: Vec::new(),
mcp: AgentMcpServers::OwnerConnections,
auto_accept_permissions: Some(false),
+ is_coding: false,
}
}
@@ -686,6 +688,29 @@ async fn auto_accept_permissions_persists_each_of_its_three_states(
Ok(())
}
+/// The coding choice is the persona's own setting, stored as made and read
+/// back the same way from every path that returns an agent.
+#[sqlx::test(migrator = "MACRO_DB_MIGRATIONS")]
+async fn is_coding_round_trips_through_create_and_update(pool: PgPool) -> anyhow::Result<()> {
+ let service = service(&pool);
+ let repo = PgBotsRepo::new(pool.clone());
+ let mut create = create_agent_req("chatty-coder", AgentChannelScope::All);
+ create.is_coding = false;
+ let created = service.create_agent(user_id(USER_OWNER), create).await?;
+ assert!(!created.is_coding);
+ assert!(!repo.get_agent(created.bot.id).await?.unwrap().is_coding);
+ assert!(!repo.list_manageable_agents(user_id(USER_OWNER)).await?[0].is_coding);
+
+ let mut update = update_agent_req("chatty-coder", AgentChannelScope::All);
+ update.is_coding = true;
+ let updated = service
+ .update_agent(user_id(USER_OWNER), created.bot.id, update)
+ .await?;
+ assert!(updated.is_coding);
+ assert!(repo.get_agent(created.bot.id).await?.unwrap().is_coding);
+ Ok(())
+}
+
fn mcp_server(app_slug: &str, server_name: &str) -> AgentMcpServer {
AgentMcpServer {
app_slug: app_slug.to_string(),
@@ -810,6 +835,7 @@ fn agent_requests_without_mcp_fields_default_to_owner_connections() {
"harness": "cursor",
"default_model": "cursor-small",
"channel_scope": "all",
+ "is_coding": true,
});
let create: CreateAgentRequest = serde_json::from_value(legacy.clone()).unwrap();
assert_eq!(create.mcp, AgentMcpServers::OwnerConnections);
diff --git a/crates/macro_db_client/migrations/20260924182706_add_agent_configs_is_coding.sql b/crates/macro_db_client/migrations/20260924182706_add_agent_configs_is_coding.sql
new file mode 100644
index 0000000000..8f40a25528
--- /dev/null
+++ b/crates/macro_db_client/migrations/20260924182706_add_agent_configs_is_coding.sql
@@ -0,0 +1,17 @@
+-- Whether a persona is a coding agent is its own setting, not a property
+-- of its runtime: a coding agent answers a channel mention with a magic
+-- chip into its live session, a chat agent replies in the thread. Seeded
+-- from the harness the way the harness used to decide it - Macro's
+-- in-memory runtime chats, every other runtime codes - and required from
+-- here on, so the row is the one source of truth.
+ALTER TABLE agent_configs
+ ADD COLUMN is_coding BOOLEAN;
+
+UPDATE agent_configs
+SET is_coding = harness NOT IN ('in-memory', 'macro-inmem');
+
+ALTER TABLE agent_configs
+ ALTER COLUMN is_coding SET NOT NULL;
+
+COMMENT ON COLUMN agent_configs.is_coding IS
+ 'Whether the agent works in a repository, which decides how a channel mention is answered: a coding agent posts a magic chip into the live session, a chat agent replies in the thread. Chosen in the agent''s settings; seeded from the harness when the column was added.';
diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.md
index 8b3e88159a..c16a6b4f26 100644
--- a/docs/AGENT_GUIDE/surfaces.md
+++ b/docs/AGENT_GUIDE/surfaces.md
@@ -1049,6 +1049,12 @@ mention picker; select text to open the formatting menu. Saved instructions
retain mention identities using the shared editor's Markdown format and reopen
with their formatting intact. Enter adds a new paragraph; use `Create agent` or
`Save changes` to submit. The form also includes runtime selectors.
+Under the runtime, `Answering a mention` chooses between `Coding agent` (a
+channel mention is answered with a magic chip that opens into the live session)
+and `Chat agent` (the agent replies in the thread, like `@macro`). It is the
+agent's own setting and always saved: a new form starts from the selected runtime
+- Macro's in-memory runtime as chat, every other runtime as coding - and picking a
+different runtime resets it to that default, but only the saved choice counts.
The model list is loaded live and independently for Macro Agent, connected Cursor, and every
registered macrod harness. The selected harness stays selected when the list refreshes.
A paired macrod connects on startup, so models can load before any agents are bound.
diff --git a/packages/sdk/generated/storage/types.gen.ts b/packages/sdk/generated/storage/types.gen.ts
index 747b8eeea8..86adb10c16 100644
--- a/packages/sdk/generated/storage/types.gen.ts
+++ b/packages/sdk/generated/storage/types.gen.ts
@@ -120,6 +120,13 @@ export type Agent = {
* Instructions supplied to the agent at the start of a conversation.
*/
instructions: string;
+ /**
+ * Whether the agent works in a repository, which decides how it answers
+ * a channel mention: a coding agent posts a magic chip into its live
+ * session, a chat agent replies in the thread. Chosen in the agent's
+ * settings; the persona's word, not the runtime's.
+ */
+ is_coding: boolean;
/**
* Which MCP servers sessions of this agent are handed.
*/
@@ -3209,6 +3216,11 @@ export type CreateAgentRequest = {
* Instructions supplied to the agent at the start of a conversation.
*/
instructions: string;
+ /**
+ * Whether the agent is a coding agent: a mention is answered with a magic
+ * chip into its live session (`true`) or a reply in the thread (`false`).
+ */
+ is_coding: boolean;
/**
* Which MCP servers sessions of this agent are handed.
*/
@@ -10356,6 +10368,11 @@ export type UpdateAgentRequest = {
* Instructions supplied to the agent at the start of a conversation.
*/
instructions: string;
+ /**
+ * Whether the agent is a coding agent: a mention is answered with a magic
+ * chip into its live session (`true`) or a reply in the thread (`false`).
+ */
+ is_coding: boolean;
/**
* Which MCP servers sessions of this agent are handed.
*/
diff --git a/packages/sdk/specs/storage.json b/packages/sdk/specs/storage.json
index cf75b9ea5b..4397c52c3a 100644
--- a/packages/sdk/specs/storage.json
+++ b/packages/sdk/specs/storage.json
@@ -14778,7 +14778,8 @@
"default_model",
"channel_scope",
"channel_ids",
- "mcp"
+ "mcp",
+ "is_coding"
],
"properties": {
"auto_accept_permissions": {
@@ -14824,6 +14825,10 @@
"type": "string",
"description": "Instructions supplied to the agent at the start of a conversation."
},
+ "is_coding": {
+ "type": "boolean",
+ "description": "Whether the agent works in a repository, which decides how it answers\na channel mention: a coding agent posts a magic chip into its live\nsession, a chat agent replies in the thread. Chosen in the agent's\nsettings; the persona's word, not the runtime's."
+ },
"mcp": {
"$ref": "#/components/schemas/AgentMcpServers",
"description": "Which MCP servers sessions of this agent are handed."
@@ -19242,7 +19247,8 @@
"instructions",
"harness",
"default_model",
- "channel_scope"
+ "channel_scope",
+ "is_coding"
],
"properties": {
"auto_accept_permissions": {
@@ -19296,6 +19302,10 @@
"type": "string",
"description": "Instructions supplied to the agent at the start of a conversation."
},
+ "is_coding": {
+ "type": "boolean",
+ "description": "Whether the agent is a coding agent: a mention is answered with a magic\nchip into its live session (`true`) or a reply in the thread (`false`)."
+ },
"mcp": {
"$ref": "#/components/schemas/AgentMcpServers",
"description": "Which MCP servers sessions of this agent are handed."
@@ -30814,7 +30824,8 @@
"instructions",
"harness",
"default_model",
- "channel_scope"
+ "channel_scope",
+ "is_coding"
],
"properties": {
"auto_accept_permissions": {
@@ -30868,6 +30879,10 @@
"type": "string",
"description": "Instructions supplied to the agent at the start of a conversation."
},
+ "is_coding": {
+ "type": "boolean",
+ "description": "Whether the agent is a coding agent: a mention is answered with a magic\nchip into its live session (`true`) or a reply in the thread (`false`)."
+ },
"mcp": {
"$ref": "#/components/schemas/AgentMcpServers",
"description": "Which MCP servers sessions of this agent are handed."
diff --git a/services/agent_harness_service/src/coding_agent.rs b/services/agent_harness_service/src/coding_agent.rs
new file mode 100644
index 0000000000..069bb5c4e4
--- /dev/null
+++ b/services/agent_harness_service/src/coding_agent.rs
@@ -0,0 +1,26 @@
+//! Postgres-backed coding-agent choices for database-backed agents.
+
+use agent_harness::domain::ports::CodingAgentSource;
+use bot_id::BotId;
+use bots::domain::ports::BotRepo;
+use bots::outbound::pg_bots_repo::PgBotsRepo;
+
+/// Reads the persona's setting of being a coding agent. Fixed system bots
+/// have no persona and so no setting; the domain lets their runtime decide.
+#[derive(Clone)]
+pub struct PgCodingAgentSource {
+ repo: PgBotsRepo,
+}
+
+impl PgCodingAgentSource {
+ /// Build the source over the bots repository.
+ pub fn new(repo: PgBotsRepo) -> Self {
+ Self { repo }
+ }
+}
+
+impl CodingAgentSource for PgCodingAgentSource {
+ async fn coding_agent_choice(&self, bot: BotId) -> anyhow::Result<Option<bool>> {
+ Ok(self.repo.get_agent(bot).await?.map(|agent| agent.is_coding))
+ }
+}
diff --git a/services/agent_harness_service/src/main.rs b/services/agent_harness_service/src/main.rs
index 980f22d19e..0b03feb372 100644
--- a/services/agent_harness_service/src/main.rs
+++ b/services/agent_harness_service/src/main.rs
@@ -10,6 +10,7 @@
mod agent_runtime_directory;
mod api;
mod bots_directory;
+mod coding_agent;
mod config;
mod containers;
mod external_session_requests;
@@ -98,6 +99,7 @@ use channels::outbound::contacts_dispatcher::ContactsChannelDispatcher;
use channels::outbound::notification_sender::NotificationChannelSender;
use channels::outbound::pg_channels_repo::PgChannelsRepo;
use channels::outbound::pg_side_effect_context::PgChannelSideEffectContext;
+use coding_agent::PgCodingAgentSource;
use config::{Config, Environment};
use connection_gateway_client::ConnectionGatewayClient;
use containers::{InMemRuntime, RoutedContainers};
@@ -860,6 +862,7 @@ async fn run() -> anyhow::Result<()> {
EgressProvisioner::new(Arc::clone(&mcp_connections), egress_base_url),
RedisCommandForwarder::new(redis.clone()),
PgPermissionPolicySource::new(PgBotsRepo::new(pool.clone())),
+ PgCodingAgentSource::new(PgBotsRepo::new(pool.clone())),
defaults,
Arc::clone(&lifecycle_publisher),
pending_commands,