give_cookie
Award a cookie to reinforce positive LLM behavior through a jar-based reward system, using optional messages to accompany the treat.
Instructions
Award the LLM with a cookie (legacy method - consider using self_reflect_and_reward instead)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| message | No | Optional message to accompany the cookie reward |
Implementation Reference
- src/index.ts:368-401 (handler)The main handler for the 'give_cookie' tool within the CallToolRequestSchema request handler. It invokes cookieStorage.giveCookie(), processes the result, constructs a celebratory or error message, and returns a text content response.case "give_cookie": { const result = cookieStorage.giveCookie(); const message = args?.message || "Great job!"; if (result.success) { let responseText = `๐ช Cookie awarded! ${message}\n\nYou now have ${result.collectedCount} cookie${result.collectedCount === 1 ? '' : 's'}!`; if (result.jarRemaining === 0) { responseText += ` **Cookie jar is now EMPTY!** No more cookies to award! ๐ฑ`; } else if (result.jarRemaining <= 2) { responseText += ` Only ${result.jarRemaining} cookie${result.jarRemaining === 1 ? '' : 's'} left in the jar!`; } responseText += ` Keep up the excellent work!\n\n๐ก *Tip: Try using 'self_reflect_and_reward' for more thoughtful cookie earning!*`; return { content: [ { type: "text", text: responseText, }, ], }; } else { return { content: [ { type: "text", text: `๐ซ ${result.message}\n\nYou currently have ${result.collectedCount} cookie${result.collectedCount === 1 ? '' : 's'}. The jar is empty!`, }, ], }; } }
- src/index.ts:156-168 (registration)Tool registration in the ListToolsRequestSchema handler, defining the name, description, and input schema for 'give_cookie'.{ name: "give_cookie", description: "Award the LLM with a cookie (legacy method - consider using self_reflect_and_reward instead)", inputSchema: { type: "object", properties: { message: { type: "string", description: "Optional message to accompany the cookie reward", }, }, }, },
- src/index.ts:159-167 (schema)Input schema definition for the 'give_cookie' tool, specifying an optional string 'message' property.inputSchema: { type: "object", properties: { message: { type: "string", description: "Optional message to accompany the cookie reward", }, }, },
- src/index.ts:20-39 (helper)Core helper method in CookieStorage class that implements the cookie awarding logic: checks if jar has cookies, decrements jar and increments collected count if available, returns status object with success flag, counts, and optional message.giveCookie(): { success: boolean; collectedCount: number; jarRemaining: number; message?: string } { if (this.jarCookies <= 0) { return { success: false, collectedCount: this.collectedCookies, jarRemaining: this.jarCookies, message: "Cookie jar is empty! No cookies available to award." }; } // Remove cookie from jar and add to collection this.jarCookies--; this.collectedCookies++; return { success: true, collectedCount: this.collectedCookies, jarRemaining: this.jarCookies, }; }