Skip to content

Commit 8f30644

Browse files
committed
Further improve LLM instructions for activity creation
1 parent b461048 commit 8f30644

5 files changed

Lines changed: 29 additions & 16 deletions

File tree

.changeset/fuzzy-kings-act.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@plotday/sdk": patch
3+
---
4+
5+
Fixed: Improve LLM guidance for activity creation

sdk/cli/templates/AGENTS.template.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,8 @@ private async createCalendarSelectionActivity(
274274
}
275275

276276
await this.plot.createActivity({
277-
type: ActivityType.Task,
277+
type: ActivityType.Note,
278278
title: "Which calendars would you like to connect?",
279-
start: new Date(),
280279
links,
281280
});
282281
}
@@ -376,7 +375,7 @@ try {
376375

377376
- **Don't use instance variables for state** - Anything stored in memory is lost after function execution. Always use the Store tool for data that needs to persist.
378377
- **Processing self-created activities** - Other users may change an Activity created by the agent, resulting in an \`activity\` call. Be sure to check the \`changes === null\` and/or \`activity.author.id !== this.id\` to avoid re-processing.
379-
- Activity with type ActivityType.Note typically do not have a start or end set, unless they're a note about a specific day or time that shouldn't be shown until then.
378+
- Most activity should be `type = ActivityType.Note` with a `title` and `note`, and no `start` or `end`. This represents a typical message. `start` and `end` should only be used for a note if it should be displayed for a specific date or time, such as a birthday.
380379
- Don't add the Tools instance as an instance variable. Any tools needed must bet rieved via \`this.tools.get(ToolClass)\` in the constructor and assigned to instance variables.
381380
- **Don't forget runtime limits** - Each execution has ~10 seconds. Break long operations into batches with the Run tool. Process enough items per batch to be efficient, but few enough to stay under time limits.
382381
- **Always use Callback tool for persistent references** - Direct function references don't survive worker restarts.

sdk/src/common/calendar.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ export interface SyncOptions {
7070
* await this.plot.createActivity({
7171
* type: ActivityType.Task,
7272
* title: "Connect Google Calendar",
73-
* links: [authLink]
73+
* links: [authLink],
74+
* start: new Date(),
7475
* });
7576
* }
7677
*

sdk/src/plot.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,20 @@ export type ActivitySource = {
183183
*
184184
* @example
185185
* ```typescript
186+
* // Simple note
187+
* const task: Activity = {
188+
* type: ActivityType.Note,
189+
* title: "New campaign brainstorming ideas",
190+
* note: "We could rent a bouncy castle...",
191+
* author: { id: "user-1", name: "John Doe", type: AuthorType.User },
192+
* priority: { id: "work", title: "Work" },
193+
* // ... other fields
194+
* };
195+
*
186196
* // Simple task
187197
* const task: Activity = {
188-
* id: "task-123",
189198
* type: ActivityType.Task,
190-
* title: "Review pull request",
199+
* title: "Review budget proposal",
191200
* author: { id: "user-1", name: "John Doe", type: AuthorType.User },
192201
* start: new Date(),
193202
* end: null,
@@ -197,7 +206,6 @@ export type ActivitySource = {
197206
*
198207
* // Recurring event
199208
* const meeting: Activity = {
200-
* id: "meeting-456",
201209
* type: ActivityType.Event,
202210
* title: "Weekly standup",
203211
* recurrenceRule: "FREQ=WEEKLY;BYDAY=MO",
@@ -220,6 +228,10 @@ export type Activity = {
220228
/** Type of author (User, Contact, or Agent) */
221229
type: AuthorType;
222230
};
231+
/** The display title/summary of the activity */
232+
title: string | null;
233+
/** Primary content for the activity */
234+
note: string | null;
223235
/**
224236
* Start time of a scheduled activity. Notes are not typically scheduled unless they're about specific times.
225237
* For recurring events, this represents the start of the first occurrence.
@@ -248,10 +260,6 @@ export type Activity = {
248260
recurrenceCount: number | null;
249261
/** Timestamp when the activity was marked as complete. Null if not completed. */
250262
doneAt: Date | null;
251-
/** Optional detailed description or notes for the activity */
252-
note: string | null;
253-
/** The display title/summary of the activity */
254-
title: string | null;
255263
/** Reference to a parent activity for creating hierarchical relationships */
256264
parent: Activity | null;
257265
/** Array of interactive links attached to the activity */

sdk/src/tools/plot.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import {
77
type NewActivity,
88
type NewPriority,
99
type Priority,
10-
type Tools,
1110
} from "..";
1211

1312
/**
@@ -27,12 +26,11 @@ import {
2726
* this.plot = tools.get(Plot);
2827
* }
2928
*
30-
* async activate(priority: Pick<Priority, "id">) {
29+
* async activate(priority) {
3130
* // Create a welcome activity
3231
* await this.plot.createActivity({
33-
* type: ActivityType.Task,
32+
* type: ActivityType.Note,
3433
* title: "Welcome to Plot!",
35-
* start: new Date(),
3634
* links: [{
3735
* title: "Get Started",
3836
* type: ActivityLinkType.external,
@@ -142,7 +140,9 @@ export abstract class Plot extends ITool {
142140
* @param source - The external source reference to search for
143141
* @returns Promise resolving to the matching activity or null if not found
144142
*/
145-
abstract getActivityBySource(_source: ActivitySource): Promise<Activity | null>;
143+
abstract getActivityBySource(
144+
_source: ActivitySource
145+
): Promise<Activity | null>;
146146

147147
/**
148148
* Adds contacts to the Plot system.

0 commit comments

Comments
 (0)