fix(clustering): drop TTL check from isUpToDate; task hash is the only signal
If tasks haven't changed, the output is valid forever. If they changed, always recompute regardless of age. TTL on focus-area restored to 24h — it only controls recommender eligibility, not recompute frequency. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -37,7 +37,7 @@ MANIFEST = AgentManifest(
|
|||||||
context_schema=["todoist.tasks"],
|
context_schema=["todoist.tasks"],
|
||||||
required_consents=["data:core", "data:todoist"],
|
required_consents=["data:core", "data:todoist"],
|
||||||
output_contract={"type": "snippet", "format": "free_text"},
|
output_contract={"type": "snippet", "format": "free_text"},
|
||||||
ttl_sec=3_600,
|
ttl_sec=86_400,
|
||||||
inferred_params=[
|
inferred_params=[
|
||||||
InferredParam(
|
InferredParam(
|
||||||
key="preferred_areas",
|
key="preferred_areas",
|
||||||
|
|||||||
@@ -165,17 +165,14 @@ function taskListHash(tasks: { content?: string }[]): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function isUpToDate(userId: string, agentId: string, currentHash: string): Promise<boolean> {
|
async function isUpToDate(userId: string, agentId: string, currentHash: string): Promise<boolean> {
|
||||||
const now = new Date().toISOString();
|
|
||||||
const rows = await db
|
const rows = await db
|
||||||
.select({ signalsSnapshot: agentOutputs.signalsSnapshot, expiresAt: agentOutputs.expiresAt })
|
.select({ signalsSnapshot: agentOutputs.signalsSnapshot })
|
||||||
.from(agentOutputs)
|
.from(agentOutputs)
|
||||||
.where(and(eq(agentOutputs.userId, userId), eq(agentOutputs.agentId, agentId)))
|
.where(and(eq(agentOutputs.userId, userId), eq(agentOutputs.agentId, agentId)))
|
||||||
.limit(1);
|
.limit(1);
|
||||||
if (!rows.length) return false;
|
if (!rows.length) return false;
|
||||||
const row = rows[0];
|
|
||||||
if (row.expiresAt <= now) return false;
|
|
||||||
try {
|
try {
|
||||||
const snapshot = JSON.parse(row.signalsSnapshot ?? '{}') as { _task_hash?: string };
|
const snapshot = JSON.parse(rows[0].signalsSnapshot ?? '{}') as { _task_hash?: string };
|
||||||
return snapshot._task_hash === currentHash;
|
return snapshot._task_hash === currentHash;
|
||||||
} catch { return false; }
|
} catch { return false; }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user