diff --git a/src/bot/PlannerBot.ts b/src/bot/PlannerBot.ts index 5b3c076..4c97ae7 100644 --- a/src/bot/PlannerBot.ts +++ b/src/bot/PlannerBot.ts @@ -170,6 +170,11 @@ export class PlannerBot extends TeamsActivityHandler { return; } + // listPlansWithBuckets already drops "Deprecated" plans; mirror that for tasks + // so the LLM can't try to update a task in a hidden plan. + const validPlanIds = new Set(plans.map((p) => p.planId)); + recentTasks = recentTasks.filter((t) => validPlanIds.has(t.planId)); + const action = await this.classifier.classify({ utterance, plans, diff --git a/src/graph/plannerClient.ts b/src/graph/plannerClient.ts index e48ee0b..2a629a9 100644 --- a/src/graph/plannerClient.ts +++ b/src/graph/plannerClient.ts @@ -11,12 +11,17 @@ import { PlanContext, Progress, RecentTaskContext } from "../llm/types"; export class PlannerClient { constructor(private readonly graph: Client) {} - /** All plans the signed-in user can see, with their buckets pre-fetched. */ + /** All plans the signed-in user can see, with their buckets pre-fetched. + * Plans whose title contains "deprecated" (case-insensitive) are filtered out + * so old/archived plans don't pollute the LLM context. + */ async listPlansWithBuckets(): Promise { // Plans this user can access via the groups they belong to. // Graph exposes /me/planner/plans which returns plans for groups the user is a member of. const plansResp = await this.graph.api("/me/planner/plans").get(); - const plans: Array<{ id: string; title: string }> = plansResp.value ?? []; + const plans: Array<{ id: string; title: string }> = (plansResp.value ?? []).filter( + (p: { title?: string }) => !/deprecated/i.test(p.title ?? ""), + ); const result: PlanContext[] = []; for (const p of plans) {