Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(tasks): enable MCP tools for agent instructions (#109958)

Georgiy Tarasovb6e76e6d6703
diff --git a/products/tasks/mcp/tools.yaml b/products/tasks/mcp/tools.yaml
index 46dc0c72c7f5..27481a96662d 100644
--- a/products/tasks/mcp/tools.yaml
+++ b/products/tasks/mcp/tools.yaml
@@ -459,7 +459,20 @@ tools:
enabled: false
tasks-config-agent-instructions-create:
operation: tasks_config_agent_instructions_create
- enabled: false
+ enabled: true
+ scopes:
+ - task:write
+ annotations:
+ readOnly: false
+ destructive: false
+ idempotent: true
+ title: Set project agent instructions
+ description: >
+ Set the project's agent instructions: markdown that PostHog cloud agents load as their user-level AGENTS.md
+ in every eligible Tasks run on the project, including autonomous runs such as loops and scouts. Requires
+ project admin. Replaces the stored text; send an empty string to clear. Read the current text with
+ tasks-config-list first, and send the full new text, not a diff.
+ feature_flag: tasks
tasks-config-create:
operation: tasks_config_create
enabled: true
@@ -489,6 +502,7 @@ tools:
description: >
Get the project-wide default AI run preferences (runtime adapter, model, reasoning effort) applied to task
runs created without an explicit runtime selection. All fields are null when no project default is stored.
+ Also returns the project's agent instructions (`agent_instructions`), empty when unset.
feature_flag: tasks
tasks-create:
operation: tasks_create
@@ -615,7 +629,21 @@ tools:
- updated_at
tasks-me-config-agent-instructions-create:
operation: tasks_me_config_agent_instructions_create
- enabled: false
+ enabled: true
+ scopes:
+ - task:write
+ annotations:
+ readOnly: false
+ destructive: false
+ idempotent: true
+ title: Set my agent instructions
+ description: >
+ Set the caller's personal agent instructions: markdown that PostHog cloud agents load after the project
+ instructions in Tasks runs the caller starts. Autonomous runs never load them. Anyone who continues a task
+ the caller started can see them, so they must not hold anything private. Replaces the stored text; send an
+ empty string to clear. Read the current text with tasks-me-config-list first, and send the full new text,
+ not a diff.
+ feature_flag: tasks
tasks-me-config-create:
operation: tasks_me_config_create
enabled: true
@@ -645,7 +673,8 @@ tools:
description: >
Get the caller's per-project default AI run preferences, plus the resolved defaults a new run will use when
no explicit runtime selection is sent (the caller's preference wins over the project default; `source` says
- which level supplied it).
+ which level supplied it). Also returns the caller's personal agent instructions (`agent_instructions`),
+ empty when unset.
feature_flag: tasks
tasks-models-retrieve:
operation: tasks_models_retrieve
diff --git a/services/mcp/schema/generated-tool-definitions.json b/services/mcp/schema/generated-tool-definitions.json
index 8904d0e83dd9..1bad64bc34df 100644
--- a/services/mcp/schema/generated-tool-definitions.json
+++ b/services/mcp/schema/generated-tool-definitions.json
@@ -12293,6 +12293,21 @@
},
"feature_flag": "context-layer"
},
+ "tasks-config-agent-instructions-create": {
+ "description": "Set the project's agent instructions: markdown that PostHog cloud agents load as their user-level AGENTS.md in every eligible Tasks run on the project, including autonomous runs such as loops and scouts. Requires project admin. Replaces the stored text; send an empty string to clear. Read the current text with tasks-config-list first, and send the full new text, not a diff.",
+ "category": "Tasks",
+ "feature": "tasks",
+ "summary": "Set project agent instructions",
+ "title": "Set project agent instructions",
+ "required_scopes": ["task:write"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_flag": "tasks"
+ },
"tasks-config-create": {
"description": "Set the project-wide default AI run preferences (runtime adapter, model, reasoning effort) applied to task runs created without an explicit runtime selection. Requires project admin. `runtime_adapter` and `model` must be set together; send all three fields as null to clear the project default. Use tasks-models-retrieve to list valid model identifiers.",
"category": "Tasks",
@@ -12309,7 +12324,7 @@
"feature_flag": "tasks"
},
"tasks-config-list": {
- "description": "Get the project-wide default AI run preferences (runtime adapter, model, reasoning effort) applied to task runs created without an explicit runtime selection. All fields are null when no project default is stored.",
+ "description": "Get the project-wide default AI run preferences (runtime adapter, model, reasoning effort) applied to task runs created without an explicit runtime selection. All fields are null when no project default is stored. Also returns the project's agent instructions (`agent_instructions`), empty when unset.",
"category": "Tasks",
"feature": "tasks",
"summary": "Get project task run defaults",
@@ -12368,6 +12383,21 @@
},
"feature_flag": "tasks"
},
+ "tasks-me-config-agent-instructions-create": {
+ "description": "Set the caller's personal agent instructions: markdown that PostHog cloud agents load after the project instructions in Tasks runs the caller starts. Autonomous runs never load them. Anyone who continues a task the caller started can see them, so they must not hold anything private. Replaces the stored text; send an empty string to clear. Read the current text with tasks-me-config-list first, and send the full new text, not a diff.",
+ "category": "Tasks",
+ "feature": "tasks",
+ "summary": "Set my agent instructions",
+ "title": "Set my agent instructions",
+ "required_scopes": ["task:write"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_flag": "tasks"
+ },
"tasks-me-config-create": {
"description": "Set the caller's per-project default AI run preferences (runtime adapter, model, reasoning effort). They override the project default wholesale. `runtime_adapter` and `model` must be set together; send all three fields as null to clear and inherit the project default. Returns the stored preferences plus the resolved defaults a new run will use. Use tasks-models-retrieve to list valid model identifiers.",
"category": "Tasks",
@@ -12384,7 +12414,7 @@
"feature_flag": "tasks"
},
"tasks-me-config-list": {
- "description": "Get the caller's per-project default AI run preferences, plus the resolved defaults a new run will use when no explicit runtime selection is sent (the caller's preference wins over the project default; `source` says which level supplied it).",
+ "description": "Get the caller's per-project default AI run preferences, plus the resolved defaults a new run will use when no explicit runtime selection is sent (the caller's preference wins over the project default; `source` says which level supplied it). Also returns the caller's personal agent instructions (`agent_instructions`), empty when unset.",
"category": "Tasks",
"feature": "tasks",
"summary": "Get my task run defaults",
diff --git a/services/mcp/schema/tool-definitions-all.json b/services/mcp/schema/tool-definitions-all.json
index f0e8539c534c..0e8bcb11ed40 100644
--- a/services/mcp/schema/tool-definitions-all.json
+++ b/services/mcp/schema/tool-definitions-all.json
@@ -12971,6 +12971,21 @@
"readOnlyHint": true
}
},
+ "tasks-config-agent-instructions-create": {
+ "description": "Set the project's agent instructions: markdown that PostHog cloud agents load as their user-level AGENTS.md in every eligible Tasks run on the project, including autonomous runs such as loops and scouts. Requires project admin. Replaces the stored text; send an empty string to clear. Read the current text with tasks-config-list first, and send the full new text, not a diff.",
+ "category": "Tasks",
+ "feature": "tasks",
+ "summary": "Set project agent instructions",
+ "title": "Set project agent instructions",
+ "required_scopes": ["task:write"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_flag": "tasks"
+ },
"tasks-config-create": {
"description": "Set the project-wide default AI run preferences (runtime adapter, model, reasoning effort) applied to task runs created without an explicit runtime selection. Requires project admin. `runtime_adapter` and `model` must be set together; send all three fields as null to clear the project default. Use tasks-models-retrieve to list valid model identifiers.",
"category": "Tasks",
@@ -12987,7 +13002,7 @@
"feature_flag": "tasks"
},
"tasks-config-list": {
- "description": "Get the project-wide default AI run preferences (runtime adapter, model, reasoning effort) applied to task runs created without an explicit runtime selection. All fields are null when no project default is stored.",
+ "description": "Get the project-wide default AI run preferences (runtime adapter, model, reasoning effort) applied to task runs created without an explicit runtime selection. All fields are null when no project default is stored. Also returns the project's agent instructions (`agent_instructions`), empty when unset.",
"category": "Tasks",
"feature": "tasks",
"summary": "Get project task run defaults",
@@ -13046,6 +13061,21 @@
},
"feature_flag": "tasks"
},
+ "tasks-me-config-agent-instructions-create": {
+ "description": "Set the caller's personal agent instructions: markdown that PostHog cloud agents load after the project instructions in Tasks runs the caller starts. Autonomous runs never load them. Anyone who continues a task the caller started can see them, so they must not hold anything private. Replaces the stored text; send an empty string to clear. Read the current text with tasks-me-config-list first, and send the full new text, not a diff.",
+ "category": "Tasks",
+ "feature": "tasks",
+ "summary": "Set my agent instructions",
+ "title": "Set my agent instructions",
+ "required_scopes": ["task:write"],
+ "annotations": {
+ "destructiveHint": false,
+ "idempotentHint": true,
+ "openWorldHint": true,
+ "readOnlyHint": false
+ },
+ "feature_flag": "tasks"
+ },
"tasks-me-config-create": {
"description": "Set the caller's per-project default AI run preferences (runtime adapter, model, reasoning effort). They override the project default wholesale. `runtime_adapter` and `model` must be set together; send all three fields as null to clear and inherit the project default. Returns the stored preferences plus the resolved defaults a new run will use. Use tasks-models-retrieve to list valid model identifiers.",
"category": "Tasks",
@@ -13062,7 +13092,7 @@
"feature_flag": "tasks"
},
"tasks-me-config-list": {
- "description": "Get the caller's per-project default AI run preferences, plus the resolved defaults a new run will use when no explicit runtime selection is sent (the caller's preference wins over the project default; `source` says which level supplied it).",
+ "description": "Get the caller's per-project default AI run preferences, plus the resolved defaults a new run will use when no explicit runtime selection is sent (the caller's preference wins over the project default; `source` says which level supplied it). Also returns the caller's personal agent instructions (`agent_instructions`), empty when unset.",
"category": "Tasks",
"feature": "tasks",
"summary": "Get my task run defaults",
diff --git a/services/mcp/src/generated/tasks/api.ts b/services/mcp/src/generated/tasks/api.ts
index e64d308a58bc..d8f4fde619e8 100644
--- a/services/mcp/src/generated/tasks/api.ts
+++ b/services/mcp/src/generated/tasks/api.ts
@@ -3,7 +3,7 @@
* MCP service uses these Zod schemas for generated tool handlers.
* To regenerate: hogli build:openapi
*
- * PostHog API - MCP 25 enabled ops
+ * PostHog API - MCP 27 enabled ops
* OpenAPI spec version: 1.0.0
*/
import * as zod from 'zod'
@@ -1912,6 +1912,30 @@ export const TasksMeConfigCreateBody = () => zod
'The default AI run selection stored at team or user level.\n\nWrite payload for the tasks config endpoints and the `ai_run_preferences` block of\ntheir responses. What a complete selection is depends on the harness: an ACP default\nsets `runtime_adapter` and `model` together, a Pi default sets `model` alone. Send\nevery field as null to clear a stored preference.'
)
+/**
+ * Set your personal instructions, which PostHog cloud agents load in Tasks runs you start, after the project instructions. Autonomous runs never get them. Anyone who continues a task you started can see them, so leave out anything private. Send an empty string to clear.
+ */
+export const TasksMeConfigAgentInstructionsCreateParams = () => zod.object({
+ project_id: zod
+ .string()
+ .describe(
+ "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
+ ),
+})
+
+export const tasksMeConfigAgentInstructionsCreateBodyAgentInstructionsMax = 20000
+
+export const TasksMeConfigAgentInstructionsCreateBody = () => zod
+ .object({
+ agent_instructions: zod
+ .string()
+ .max(tasksMeConfigAgentInstructionsCreateBodyAgentInstructionsMax)
+ .describe(
+ 'Markdown instructions that PostHog cloud agents read in every eligible Tasks run, the same way a local agent reads AGENTS.md. Send an empty string to clear.'
+ ),
+ })
+ .describe('Markdown instructions that PostHog cloud agents load as their user-level AGENTS.md in Tasks runs.')
+
/**
* Retrieve the project-wide default AI run preferences for task runs.
*/
@@ -1977,6 +2001,30 @@ export const TasksConfigCreateBody = () => zod
'The default AI run selection stored at team or user level.\n\nWrite payload for the tasks config endpoints and the `ai_run_preferences` block of\ntheir responses. What a complete selection is depends on the harness: an ACP default\nsets `runtime_adapter` and `model` together, a Pi default sets `model` alone. Send\nevery field as null to clear a stored preference.'
)
+/**
+ * Set the project instructions that PostHog cloud agents load as their user-level AGENTS.md in every eligible Tasks run, including autonomous runs. Send an empty string to clear.
+ */
+export const TasksConfigAgentInstructionsCreateParams = () => zod.object({
+ project_id: zod
+ .string()
+ .describe(
+ "Project ID of the project you're trying to access. To find the ID of the project, make a call to \/api\/projects\/."
+ ),
+})
+
+export const tasksConfigAgentInstructionsCreateBodyAgentInstructionsMax = 20000
+
+export const TasksConfigAgentInstructionsCreateBody = () => zod
+ .object({
+ agent_instructions: zod
+ .string()
+ .max(tasksConfigAgentInstructionsCreateBodyAgentInstructionsMax)
+ .describe(
+ 'Markdown instructions that PostHog cloud agents read in every eligible Tasks run, the same way a local agent reads AGENTS.md. Send an empty string to clear.'
+ ),
+ })
+ .describe('Markdown instructions that PostHog cloud agents load as their user-level AGENTS.md in Tasks runs.')
+
/**
* Return the models a task run may use, with the reasoning efforts each one supports. Derived from the live LLM gateway catalogue, so a newly released model appears without a client change. An empty list means the gateway is unreachable — clients should fall back to their own default rather than treating it as 'no models exist'.
* @summary List available models
diff --git a/services/mcp/src/tools/generated/tasks.ts b/services/mcp/src/tools/generated/tasks.ts
index ee340ed08b80..964597272446 100644
--- a/services/mcp/src/tools/generated/tasks.ts
+++ b/services/mcp/src/tools/generated/tasks.ts
@@ -533,6 +533,32 @@ const loopsRunsRetrieve = (): ToolBase<
},
})
+const TasksConfigAgentInstructionsCreateSchema = () => {
+ const TasksConfigAgentInstructionsCreateBody = orvalSchemas.TasksConfigAgentInstructionsCreateBody()
+ return TasksConfigAgentInstructionsCreateBody
+}
+
+const tasksConfigAgentInstructionsCreate = (): ToolBase<
+ ReturnType<typeof TasksConfigAgentInstructionsCreateSchema>,
+ Schemas.TasksAgentInstructions
+> => ({
+ name: 'tasks-config-agent-instructions-create',
+ schema: TasksConfigAgentInstructionsCreateSchema(),
+ handler: async (context: Context, params: z.infer<ReturnType<typeof TasksConfigAgentInstructionsCreateSchema>>) => {
+ const projectId = await context.stateManager.getProjectId()
+ const body: Record<string, unknown> = {}
+ if (params.agent_instructions !== undefined) {
+ body['agent_instructions'] = params.agent_instructions
+ }
+ const result = await context.api.request<Schemas.TasksAgentInstructions>({
+ method: 'POST',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/tasks/config/agent_instructions/`,
+ body,
+ })
+ return result
+ },
+})
+
const TasksConfigCreateSchema = () => {
const TasksConfigCreateBody = orvalSchemas.TasksConfigCreateBody()
return TasksConfigCreateBody
@@ -780,6 +806,35 @@ const tasksList = (): ToolBase<
},
})
+const TasksMeConfigAgentInstructionsCreateSchema = () => {
+ const TasksMeConfigAgentInstructionsCreateBody = orvalSchemas.TasksMeConfigAgentInstructionsCreateBody()
+ return TasksMeConfigAgentInstructionsCreateBody
+}
+
+const tasksMeConfigAgentInstructionsCreate = (): ToolBase<
+ ReturnType<typeof TasksMeConfigAgentInstructionsCreateSchema>,
+ Schemas.TasksAgentInstructions
+> => ({
+ name: 'tasks-me-config-agent-instructions-create',
+ schema: TasksMeConfigAgentInstructionsCreateSchema(),
+ handler: async (
+ context: Context,
+ params: z.infer<ReturnType<typeof TasksMeConfigAgentInstructionsCreateSchema>>
+ ) => {
+ const projectId = await context.stateManager.getProjectId()
+ const body: Record<string, unknown> = {}
+ if (params.agent_instructions !== undefined) {
+ body['agent_instructions'] = params.agent_instructions
+ }
+ const result = await context.api.request<Schemas.TasksAgentInstructions>({
+ method: 'POST',
+ path: `/api/projects/${encodeURIComponent(String(projectId))}/tasks/@me/config/agent_instructions/`,
+ body,
+ })
+ return result
+ },
+})
+
const TasksMeConfigCreateSchema = () => {
const TasksMeConfigCreateBody = orvalSchemas.TasksMeConfigCreateBody()
return TasksMeConfigCreateBody
@@ -1039,11 +1094,13 @@ export const GENERATED_TOOLS: Record<string, () => ToolBase<ZodObjectAny>> = {
'loops-retrieve': loopsRetrieve,
'loops-run-create': loopsRunCreate,
'loops-runs-retrieve': loopsRunsRetrieve,
+ 'tasks-config-agent-instructions-create': tasksConfigAgentInstructionsCreate,
'tasks-config-create': tasksConfigCreate,
'tasks-config-list': tasksConfigList,
'tasks-create': tasksCreate,
'tasks-create-and-run': tasksCreateAndRun,
'tasks-list': tasksList,
+ 'tasks-me-config-agent-instructions-create': tasksMeConfigAgentInstructionsCreate,
'tasks-me-config-create': tasksMeConfigCreate,
'tasks-me-config-list': tasksMeConfigList,
'tasks-models-retrieve': tasksModelsRetrieve,
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-config-agent-instructions-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-config-agent-instructions-create.json
new file mode 100644
index 000000000000..63ae4e03d2c6
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-config-agent-instructions-create.json
@@ -0,0 +1,13 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "description": "Markdown instructions that PostHog cloud agents load as their user-level AGENTS.md in Tasks runs.",
+ "properties": {
+ "agent_instructions": {
+ "description": "Markdown instructions that PostHog cloud agents read in every eligible Tasks run, the same way a local agent reads AGENTS.md. Send an empty string to clear.",
+ "maxLength": 20000,
+ "type": "string"
+ }
+ },
+ "required": ["agent_instructions"],
+ "type": "object"
+}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-me-config-agent-instructions-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-me-config-agent-instructions-create.json
new file mode 100644
index 000000000000..63ae4e03d2c6
--- /dev/null
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/tasks-me-config-agent-instructions-create.json
@@ -0,0 +1,13 @@
+{
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
+ "description": "Markdown instructions that PostHog cloud agents load as their user-level AGENTS.md in Tasks runs.",
+ "properties": {
+ "agent_instructions": {
+ "description": "Markdown instructions that PostHog cloud agents read in every eligible Tasks run, the same way a local agent reads AGENTS.md. Send an empty string to clear.",
+ "maxLength": 20000,
+ "type": "string"
+ }
+ },
+ "required": ["agent_instructions"],
+ "type": "object"
+}