Skip to content

perf(server): scope paused-goal task lookup by goalId - #108

Open
kvnloo wants to merge 3 commits into
CopilotKit:mainfrom
kvnloo:perf/update-goal-scoped-tasks
Open

kvnloo wants to merge 3 commits into
CopilotKit:mainfrom
kvnloo:perf/update-goal-scoped-tasks

Conversation

@kvnloo

@kvnloo kvnloo commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

Problem

Pausing a goal currently loads every durable task for the owner, then filters by goalId in JavaScript. Terminal task history is retained, so this path gets slower as the workspace ages.

A downstream PGlite benchmark with 2,000 ~2KB task rows measured roughly:

  • full task list + JS filter: ~236ms / ~3.0MB
  • SQL goalId filter: ~6.9ms / ~78KB

Change

Add Store.listByGoalId() with the same updated_at DESC,id ordering as list(), and use it only for the paused-goal cascade.

The remaining predicates are unchanged:

  • terminal tasks are still ignored;
  • already-paused tasks are still ignored;
  • records with no goalId never match.

Regression

Persistence coverage compares the scoped query directly with the previous list().filter(item.goalId === id) semantics and checks owner/kind isolation.

No goal lifecycle or task-control behavior changes.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant