: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(tasks): send slug tags from the task summary tool (#107835)
posthog[bot]8bf553b9ca3d
diff --git a/products/desktop/packages/harness/src/extensions/local-tools/task-tools-client.ts b/products/desktop/packages/harness/src/extensions/local-tools/task-tools-client.tsindex b6dfe3f7a69d..2afbce762427 100644--- a/products/desktop/packages/harness/src/extensions/local-tools/task-tools-client.ts+++ b/products/desktop/packages/harness/src/extensions/local-tools/task-tools-client.ts@@ -103,12 +103,13 @@ export class TaskToolsApiClient {taskId: string,runId: string,summary: string,+ tags: string[] | undefined,signal?: AbortSignal,): Promise<TaskRun> {const teamId = this.http.getTeamId();return this.http.request<TaskRun>(`/api/projects/${teamId}/tasks/${taskId}/runs/${runId}/set_summary/`,- { method: "PATCH", body: JSON.stringify({ summary }), signal },+ { method: "PATCH", body: JSON.stringify({ summary, tags }), signal },);}diff --git a/products/desktop/packages/harness/src/extensions/local-tools/tools/task-summary-update.test.ts b/products/desktop/packages/harness/src/extensions/local-tools/tools/task-summary-update.test.tsnew file mode 100644index 000000000000..c016e9e04c26--- /dev/null+++ b/products/desktop/packages/harness/src/extensions/local-tools/tools/task-summary-update.test.ts@@ -0,0 +1,49 @@+import { beforeEach, describe, expect, it, vi } from "vitest";+import { z } from "zod";++const setTaskRunSummary = vi.fn();++vi.mock("../signed-commit-artefacts", () => ({+ createSandboxPosthogClient: () => ({ setTaskRunSummary }),+ withReportDeadline: <T>(work: (signal: AbortSignal) => Promise<T>) =>+ work(new AbortController().signal),+}));++import { taskSummaryUpdateTool } from "./task-summary-update";++const ctx = { cwd: "/tmp", taskId: "task-1", taskRunId: "run-1" };++describe("taskSummaryUpdateTool", () => {+ beforeEach(() => {+ vi.clearAllMocks();+ setTaskRunSummary.mockResolvedValue({});+ });++ it.each([+ { name: "forwards tags when set", tags: ["feature-flags", "bug-fix"] },+ { name: "leaves tags out when absent", tags: undefined },+ ])("$name", async ({ tags }) => {+ const result = await taskSummaryUpdateTool.handler(ctx, {+ summary: " Fix the flag. ",+ tags,+ });+ expect(result.isError).toBeUndefined();+ expect(setTaskRunSummary).toHaveBeenCalledWith(+ "task-1",+ "run-1",+ "Fix the flag.",+ tags,+ expect.any(AbortSignal),+ );+ });++ it.each(["Feature-Flags", "bug_fix", "-lead", "a".repeat(51)])(+ "rejects the invalid tag %s",+ (tag) => {+ const schema = z.object(taskSummaryUpdateTool.schema);+ expect(schema.safeParse({ summary: "s", tags: [tag] }).success).toBe(+ false,+ );+ },+ );+});diff --git a/products/desktop/packages/harness/src/extensions/local-tools/tools/task-summary-update.ts b/products/desktop/packages/harness/src/extensions/local-tools/tools/task-summary-update.tsindex b817bd464bc0..8dbfe468e61f 100644--- a/products/desktop/packages/harness/src/extensions/local-tools/tools/task-summary-update.ts+++ b/products/desktop/packages/harness/src/extensions/local-tools/tools/task-summary-update.ts@@ -2,6 +2,9 @@ import { z } from "zod";import {TASK_SUMMARY_MAX_CHARS,TASK_SUMMARY_TOOL_NAME,+ TASK_TAG_MAX_CHARS,+ TASK_TAG_PATTERN,+ TASK_TAGS_MAX_COUNT,} from "../../task-system-prompt/task-summary";import { defineLocalTool, type LocalToolResult } from "../registry";import {@@ -26,6 +29,13 @@ export const taskSummaryUpdateTool = defineLocalTool({.describe("The complete summary, replacing any previous one. Plain text or short markdown.",),+ tags: z+ .array(z.string().max(TASK_TAG_MAX_CHARS).regex(TASK_TAG_PATTERN))+ .max(TASK_TAGS_MAX_COUNT)+ .optional()+ .describe(+ "The complete set of lowercase kebab-case slugs, for example `feature-flags` or `bug-fix`, replacing any previous tags. Omit to keep the current tags.",+ ),},alwaysLoad: true,// The summary is stored on the cloud task run, so a local session has nowhere to write it.@@ -52,6 +62,7 @@ export const taskSummaryUpdateTool = defineLocalTool({ctx.taskId as string,ctx.taskRunId as string,summary,+ args.tags,signal,),"task summary update",diff --git a/products/desktop/packages/harness/src/extensions/task-system-prompt/prompt.test.ts b/products/desktop/packages/harness/src/extensions/task-system-prompt/prompt.test.tsindex c98de652c155..890f2ae14a38 100644--- a/products/desktop/packages/harness/src/extensions/task-system-prompt/prompt.test.ts+++ b/products/desktop/packages/harness/src/extensions/task-system-prompt/prompt.test.ts@@ -60,5 +60,8 @@ describe("buildTaskSystemPrompt", () => {expect(prompt).toContain("## Keeping the task summary");expect(prompt).toContain("task_summary_update");expect(prompt).toContain("A turn that only answers a question counts.");+ expect(prompt).toContain(+ "Also send `tags`: up to 10 lowercase kebab-case slugs",+ );});});diff --git a/products/desktop/packages/harness/src/extensions/task-system-prompt/task-summary.ts b/products/desktop/packages/harness/src/extensions/task-system-prompt/task-summary.tsindex e3233d8f4573..34409038375f 100644--- a/products/desktop/packages/harness/src/extensions/task-system-prompt/task-summary.ts+++ b/products/desktop/packages/harness/src/extensions/task-system-prompt/task-summary.ts@@ -2,8 +2,13 @@ export const TASK_SUMMARY_TOOL_NAME = "task_summary_update";// Matches the server-side limit on the set_summary endpoint.export const TASK_SUMMARY_MAX_CHARS = 1500;+export const TASK_TAGS_MAX_COUNT = 10;+export const TASK_TAG_MAX_CHARS = 50;+export const TASK_TAG_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;export function buildTaskSummaryInstructions(): string {return `## Keeping the task summary-Call the \`${TASK_SUMMARY_TOOL_NAME}\` tool when the goal changes, when you stop one approach, about every ten turns, and before you end any turn. A turn that only answers a question counts. Each call replaces the prior summary. Write the current state and remove details that no longer matter. Keep the summary to a few sentences.`;+Call the \`${TASK_SUMMARY_TOOL_NAME}\` tool when the goal changes, when you stop one approach, about every ten turns, and before you end any turn. A turn that only answers a question counts. Each call replaces the prior summary. Write the current state and remove details that no longer matter. Keep the summary to a few sentences.++Also send \`tags\`: up to ${TASK_TAGS_MAX_COUNT} lowercase kebab-case slugs that name the product area and the kind of work, for example \`feature-flags\` or \`bug-fix\`. Each call replaces the prior tags. Omit \`tags\` to keep the current tags.`;}