Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.
feat(routines): allow 100 Routines per room with no separate one-shot limit
muterC6e4d4877f205
diff --git a/apps/teamhub/AGENTS.md b/apps/teamhub/AGENTS.mdindex 39457ce6..88be69f9 100644--- a/apps/teamhub/AGENTS.md+++ b/apps/teamhub/AGENTS.md@@ -35,6 +35,9 @@ Go service owning Human HTTP/SSE, Agent callbacks, and active product state.## Important Conventions+- A Room permits 100 Routines: recurring ones count while they exist, and+ one-shot ones count until they fire. There is no separate one-shot limit.+- Room input acceptance: Runtime State validates canonicalconversation/targeted agent_runtime inputs atomically with Local Run and cursor.Document reads are live-latest and mutations retain CAS. CLI businessdiff --git a/apps/teamhub/internal/app/contract_server_agent_routines.go b/apps/teamhub/internal/app/contract_server_agent_routines.goindex ccb9ccfb..01b69a78 100644--- a/apps/teamhub/internal/app/contract_server_agent_routines.go+++ b/apps/teamhub/internal/app/contract_server_agent_routines.go@@ -166,18 +166,13 @@ func (a *App) writeAgentRoutineError(c *gin.Context, err error) bool {Path: "mention_actor_id", Code: "mention_unavailable",Message: "Use self, or the actor id of an Agent who is still in this room.",}})- case errors.Is(err, reminder.ErrPendingOnceLimit):- a.writeAgentAPIErrorWithIssues(c, http.StatusConflict, teamhubagentapi.AgentApiErrorCodeInvalidRequest, "This room already has 20 one-shot routines waiting", []teamhubagentapi.AgentApiErrorIssue{{- Path: "schedule.run_at", Code: "routine_once_limit",- Message: "Wait for a one-shot routine to fire, or delete one, before adding another.",- }})case errors.Is(err, reminder.ErrAppListener):a.writeAgentAPIErrorWithIssues(c, http.StatusConflict, teamhubagentapi.AgentApiErrorCodeInvalidRequest, "This routine listens to a connected app", []teamhubagentapi.AgentApiErrorIssue{{Path: "routine_id", Code: "routine_app_listener",Message: "An app listener can only be paused or enabled. It goes away when the Human revokes your access to that app.",}})case errors.Is(err, reminder.ErrLimitReached):- a.writeAgentAPIErrorWithIssues(c, http.StatusConflict, teamhubagentapi.AgentApiErrorCodeInvalidRequest, "This room already has 50 routines", []teamhubagentapi.AgentApiErrorIssue{{+ a.writeAgentAPIErrorWithIssues(c, http.StatusConflict, teamhubagentapi.AgentApiErrorCodeInvalidRequest, "This room already has 100 routines", []teamhubagentapi.AgentApiErrorIssue{{Path: "name", Code: "routine_limit",Message: "Delete a routine in this room before creating another.",}})diff --git a/apps/teamhub/internal/app/handlers_reminders.go b/apps/teamhub/internal/app/handlers_reminders.goindex 80029fad..7fab2e5d 100644--- a/apps/teamhub/internal/app/handlers_reminders.go+++ b/apps/teamhub/internal/app/handlers_reminders.go@@ -219,8 +219,6 @@ func (a *App) writeReminderError(c *gin.Context, action string, err error) boola.writeError(c, http.StatusConflict, "ROUTINE_AGENT_UNAVAILABLE", "The Agent this Routine belongs to is not active; try again after it is back")case errors.Is(err, reminder.ErrConflict):a.writeError(c, http.StatusConflict, "CONFLICT", "Reminder was updated by another request")- case errors.Is(err, reminder.ErrPendingOnceLimit):- a.writeError(c, http.StatusConflict, "REMINDER_LIMIT_REACHED", "this Room already has the maximum number of one-shot Reminders waiting")case errors.Is(err, reminder.ErrLimitReached):a.writeError(c, http.StatusConflict, "REMINDER_LIMIT_REACHED", "this Room already has the maximum number of Reminders")default:diff --git a/apps/teamhub/internal/reminder/service.go b/apps/teamhub/internal/reminder/service.goindex f8b41f5a..85f6e70c 100644--- a/apps/teamhub/internal/reminder/service.go+++ b/apps/teamhub/internal/reminder/service.go@@ -444,11 +444,9 @@ func appendChangedWithName(ctx context.Context, queries *store.Queries, authorit}// checkLimits bounds a Room's Routines when a write makes one count: a-// recurring Routine counts while it exists and a one-shot one until it fires,-// and at most maxPendingOncePerRoom one-shot Routines wait to fire.+// recurring Routine counts while it exists and a one-shot one until it fires.func checkLimits(ctx context.Context, queries *store.Queries, authority Authority, before *store.RoomReminder, kind string, enabled bool) error {counts := func(kind string, enabled bool) bool { return kind != "once" || enabled }- waits := func(kind string, enabled bool) bool { return kind == "once" && enabled }if counts(kind, enabled) && (before == nil || !counts(before.CadenceKind.String, before.Enabled)) {count, err := queries.CountRoomReminders(ctx, store.CountRoomRemindersParams{RoomID: authority.RoomID, TenantID: authority.TenantID,@@ -460,16 +458,5 @@ func checkLimits(ctx context.Context, queries *store.Queries, authority Authoritreturn ErrLimitReached}}- if waits(kind, enabled) && (before == nil || !waits(before.CadenceKind.String, before.Enabled)) {- pending, err := queries.CountEnabledOnceRoomReminders(ctx, store.CountEnabledOnceRoomRemindersParams{- RoomID: authority.RoomID, TenantID: authority.TenantID,- })- if err != nil {- return err- }- if pending >= maxPendingOncePerRoom {- return ErrPendingOnceLimit- }- }return nil}diff --git a/apps/teamhub/internal/reminder/types.go b/apps/teamhub/internal/reminder/types.goindex b9436c94..5c16266e 100644--- a/apps/teamhub/internal/reminder/types.go+++ b/apps/teamhub/internal/reminder/types.go@@ -9,13 +9,13 @@ import ()const (- maxNameRunes = 120- maxPromptRunes = 50000- maxRemindersPerRoom = 50- // maxPendingOncePerRoom bounds the one-shot checks an Agent can line up.- maxPendingOncePerRoom = 20- defaultListLimit = 50- maxListLimit = 100+ maxNameRunes = 120+ maxPromptRunes = 50000+ // maxRemindersPerRoom bounds a Room's Routines: recurring ones while they+ // exist and one-shot ones until they fire.+ maxRemindersPerRoom = 100+ defaultListLimit = 50+ maxListLimit = 100)var (@@ -26,8 +26,6 @@ var (ErrIdempotencyConflict = errors.New("reminder idempotency key reused")ErrLimitReached = errors.New("room reminder limit reached")ErrMentionInvalid = fmt.Errorf("%w: mention", ErrInvalid)- // ErrPendingOnceLimit is the limit on one-shot Routines still waiting to fire.- ErrPendingOnceLimit = fmt.Errorf("%w: pending one-shot", ErrLimitReached)// ErrTemplateAgentUnavailable is a template copy whose Agent is not active,// so the copy cannot run or be enabled now.ErrTemplateAgentUnavailable = fmt.Errorf("%w: template Agent unavailable", ErrConflict)diff --git a/apps/teamhub/internal/store/queries/reminder.sql b/apps/teamhub/internal/store/queries/reminder.sqlindex a4d248fa..0ab4d11d 100644--- a/apps/teamhub/internal/store/queries/reminder.sql+++ b/apps/teamhub/internal/store/queries/reminder.sql@@ -20,12 +20,6 @@ FROM room_remindersWHERE room_id=sqlc.arg(room_id)::text AND tenant_id=sqlc.arg(tenant_id)::textAND (cadence_kind<>'once' OR enabled);--- name: CountEnabledOnceRoomReminders :one-SELECT count(*)::bigint-FROM room_reminders-WHERE room_id=sqlc.arg(room_id)::text AND tenant_id=sqlc.arg(tenant_id)::text- AND cadence_kind='once' AND enabled;--- name: CreateRoomReminder :oneINSERT INTO room_reminders (id, tenant_id, room_id, created_by_actor_id, name, instruction, mention_actor_id,diff --git a/apps/teamhub/internal/store/reminder.sql.go b/apps/teamhub/internal/store/reminder.sql.goindex a7cc2b69..7a66ae40 100644--- a/apps/teamhub/internal/store/reminder.sql.go+++ b/apps/teamhub/internal/store/reminder.sql.go@@ -59,25 +59,6 @@ func (q *Queries) AdvanceRoomReminderSchedule(ctx context.Context, arg AdvanceRoreturn i, err}-const countEnabledOnceRoomReminders = `-- name: CountEnabledOnceRoomReminders :one-SELECT count(*)::bigint-FROM room_reminders-WHERE room_id=$1::text AND tenant_id=$2::text- AND cadence_kind='once' AND enabled-`--type CountEnabledOnceRoomRemindersParams struct {- RoomID string `json:"room_id"`- TenantID string `json:"tenant_id"`-}--func (q *Queries) CountEnabledOnceRoomReminders(ctx context.Context, arg CountEnabledOnceRoomRemindersParams) (int64, error) {- row := q.db.QueryRow(ctx, countEnabledOnceRoomReminders, arg.RoomID, arg.TenantID)- var column_1 int64- err := row.Scan(&column_1)- return column_1, err-}-const countRoomReminders = `-- name: CountRoomReminders :oneSELECT count(*)::bigintFROM room_remindersdiff --git a/apps/teamhub/internal/voice/voice_live_routines.go b/apps/teamhub/internal/voice/voice_live_routines.goindex 90a8fcb2..7dff91d5 100644--- a/apps/teamhub/internal/voice/voice_live_routines.go+++ b/apps/teamhub/internal/voice/voice_live_routines.go@@ -180,8 +180,6 @@ func voiceLiveRoutineError(err error) (string, bool) {return "", falsecase errors.Is(err, reminder.ErrAppListener):code = "listener_routine"- case errors.Is(err, reminder.ErrPendingOnceLimit):- code = "once_limit"case errors.Is(err, reminder.ErrLimitReached):code = "routine_limit"case errors.Is(err, reminder.ErrMentionInvalid), errors.Is(err, reminder.ErrTemplateAgentUnavailable):diff --git a/apps/teamhub/internal/voicelive/routines.go b/apps/teamhub/internal/voicelive/routines.goindex e9339586..d90a49ea 100644--- a/apps/teamhub/internal/voicelive/routines.go+++ b/apps/teamhub/internal/voicelive/routines.go@@ -33,7 +33,7 @@ var RoutineTools = []Tool{"instruction is what it says or does, in the user's language: for a reminder, the reminder itself; with agent_does_it=true it wakes the Agent to do the work, so write the work to do. " +"When it fires it posts in this chat; there is no phone or desktop notification, so never promise one. " +"This is a write: first call without confirmed; it returns needs_confirmation with when and what: say that and ask. Only after the user says yes in their next turn, call again with the same arguments and confirmed=true. " +- "invalid_schedule: a time is missing, past or malformed; ask or fix it. routine_limit or once_limit: too many routines here; offer to delete one.",+ "invalid_schedule: a time is missing, past or malformed; ask or fix it. routine_limit: too many routines here; offer to delete one.",Parameters: objectSchema([]string{"name", "instruction", "kind", "confirmed"}, map[string]any{"name": stringProperty("Short name, one line"),"instruction": stringProperty("What it says or does when it fires"),diff --git a/apps/teamhub/tests/integration/reminder_test.go b/apps/teamhub/tests/integration/reminder_test.goindex 043dadde..136ab145 100644--- a/apps/teamhub/tests/integration/reminder_test.go+++ b/apps/teamhub/tests/integration/reminder_test.go@@ -607,10 +607,10 @@ func TestReminderOccurrenceJobsAreStaleAfterEditOrDelete(t *testing.T) {}// Routine writes lock the Routine before comparing revisions and recheck the-// caller inside the write: a patch to one-shot respects the pending limit, a-// Human removed from the Room is refused, a repeated delete finds no Routine, a patch-// waiting on a fire keeps the fire's schedule, and a deleted Tracking Item-// takes its Routines with a recorded deletion.+// caller inside the write: a Human removed from the Room is refused, a+// repeated delete finds no Routine, a patch waiting on a fire keeps the fire's+// schedule, and a deleted Tracking Item takes its Routines with a recorded+// deletion.func TestRoutineWritesLockAndRecheck(t *testing.T) {allowParallelIntegrationTest(t)env, alice := newWorkItemAgentEnv(t)@@ -628,25 +628,6 @@ func TestRoutineWritesLockAndRecheck(t *testing.T) {return created}- t.Run("patch to one-shot respects the pending limit", func(t *testing.T) {- routine := create(t, "to-once")- if _, err := env.pool.Exec(t.Context(), `INSERT INTO room_reminders (id, tenant_id, room_id, created_by_actor_id, name, instruction, cadence_kind, timezone, run_at, enabled, next_run_at)- SELECT 'routine_pending_'||n, $1, $2, 'actor_acme_alice', 'Pending '||n, 'Pending', 'once', 'UTC', now()+interval '1 day', true, now()+interval '1 day'- FROM generate_series(1, 20) n`, acmeTenant, roomID); err != nil {- t.Fatal(err)- }- defer func() {- if _, err := env.pool.Exec(t.Context(), `DELETE FROM room_reminders WHERE id LIKE 'routine_pending_%'`); err != nil {- t.Fatal(err)- }- }()- once := map[string]any{"kind": "once", "timezone": "UTC", "run_at": time.Now().Add(time.Hour).UTC().Format(time.RFC3339)}- code, _, raw := env.request(alice, http.MethodPatch, "/v0/routines/"+routine.ID, map[string]any{"expected_revision": routine.Revision, "cadence": once}, "to-once-"+suffix)- if code != http.StatusConflict || !strings.Contains(string(raw), "REMINDER_LIMIT_REACHED") {- t.Fatalf("patch past the one-shot limit: %d %s", code, raw)- }- })-t.Run("a repeated delete finds no Routine", func(t *testing.T) {routine := create(t, "deleted")path := "/v0/routines/" + routine.ID + "?expected_revision=" + strconv.FormatInt(routine.Revision, 10)diff --git a/apps/teamhub/tests/integration/room_routine_mcp_test.go b/apps/teamhub/tests/integration/room_routine_mcp_test.goindex 9b5f9cb0..6cbdac9d 100644--- a/apps/teamhub/tests/integration/room_routine_mcp_test.go+++ b/apps/teamhub/tests/integration/room_routine_mcp_test.go@@ -243,7 +243,7 @@ func cloneRoutineMap(source map[string]any) map[string]any {// TestAgentOnceRoutine drives the Agent HTTP surface for one-shot checks: a// one-shot check is created and listed with its time, and a past time and the-// pending one-shot limit are refused.+// room limit are refused.func TestAgentOnceRoutine(t *testing.T) {allowParallelIntegrationTest(t)env, alice := newAgentRoutineEnv(t)@@ -278,10 +278,13 @@ func TestAgentOnceRoutine(t *testing.T) {}if _, err := env.pool.Exec(t.Context(), `INSERT INTO room_reminders (id, tenant_id, room_id, created_by_actor_id, name, instruction, cadence_kind, timezone, run_at, enabled, next_run_at)SELECT 'routine_pending_'||n, $1, $2, 'actor_acme_official', 'Pending '||n, 'x', 'once', 'UTC', now()+interval '1 day', true, now()+interval '1 day'- FROM generate_series(1,19) n`, acmeTenant, roomID); err != nil {+ FROM generate_series(1,98) n`, acmeTenant, roomID); err != nil {t.Fatal(err)}- if status, body := once("12", runAt.Format(time.RFC3339)); status != http.StatusConflict || !strings.Contains(string(body), "routine_once_limit") {- t.Fatalf("pending one-shot limit: %d %s", status, body)+ if status, body := once("12", runAt.Format(time.RFC3339)); status != http.StatusOK {+ t.Fatalf("100th Routine: %d %s", status, body)+ }+ if status, body := once("14", runAt.Format(time.RFC3339)); status != http.StatusConflict || !strings.Contains(string(body), "routine_limit") {+ t.Fatalf("room Routine limit: %d %s", status, body)}}