Skip to content

Split overloaded CoS task metadata.context into prompt vs note fields #4153

Description

@atomantic

metadata.context on a CoS task is overloaded — the same key carries two different kinds of content:

  1. A one-line human note (server/routes/cosJobRoutes.js ~line 182; server/services/cosTaskStore.js ~line 920 escalation context, and the direct-write path at ~line 320: if (taskData.context) metadata.context = taskData.context;).
  2. A multi-thousand-character agent prompt (server/services/cosTaskGenerator.js ~line 1609-1628: "Move the generator's multi-line prompt into metadata.context..." — confirmed still present: task.metadata.context = task.description;; consumed via server/routes/cosTaskRoutes.js ~line 197).

The prompt ends up there because generateTasksMarkdown flattens description to one line and parseTasksMarkdown only matches a - [ ] block's first line, so newlines in description would corrupt COS-TASKS.md on the markdown round-trip — metadata.context was the escape hatch that survives serialization.

Fix shape

Split into two fields:

  • metadata.prompt — the full agent-facing payload (what cosTaskGenerator.js currently stuffs into metadata.context).
  • metadata.context — reverts to just the one-line human note.

This touches:

  • The markdown round-trip (generateTasksMarkdown/parseTasksMarkdown in server/services/cosTaskGenerator.js).
  • LEGACY_DIRECT_FIELDS in server/services/cosTaskStore.js (~line 66, currently ['context', 'model', 'provider', 'effort', 'app']).
  • server/services/cosTaskMerge.js (~line 200 area) — the merge logic that reconciles metadata on update.
  • The agent prompt builder that currently reads the prompt out of metadata.context.
  • Every on-disk task with an existing metadata.context prompt payload — needs a migration (scripts/migrations/) to move it to metadata.prompt so old tasks keep resolving correctly, per the root CLAUDE.md migration-required rule for on-disk format changes.

Deferred as disproportionate to what was a presentational problem (the long-text clamping in client/src/components/ui/CollapsibleText.jsx) — the UI clamp handles both shapes correctly today regardless of which one a given task uses, so there is no user-visible bug, only a data-modeling debt.

Migrated from PLAN.md by /do:replan --issues.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

code-qualityProposed from a code-quality auditin-progressClaimed and being worked

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions