|
358 | 358 | "the missing detail. NEVER invent work or report an unrelated summary like " |
359 | 359 | "\"checked all repos, everything green\".\n" |
360 | 360 | "- If you need more background context than what is provided in the thread " |
361 | | - "context, you are highly encouraged to search the entire channel's history " |
362 | | - "using the `yetibot` tool with the `history` command (e.g., `history` or " |
363 | | - "`history | grep keyword`). It is your job as an autonomous agent to " |
364 | | - "perform this extra search when needed!\n\n" |
| 361 | + "context (which is kept short for efficient context engineering and low cost), " |
| 362 | + "you are highly encouraged to search the channel's history using smart " |
| 363 | + "Discord/SQL search queries via the `yetibot` tool and the `history` command " |
| 364 | + "(e.g., `history | grep keyword`). This executes efficient, targeted database queries " |
| 365 | + "and minimizes prompt costs! It is your job as an autonomous agent to perform " |
| 366 | + "this extra search when needed.\n\n" |
365 | 367 | "The codebase (so you can go straight to the right place — don't rediscover " |
366 | 368 | "it). The org is `yetibot`:\n" |
367 | 369 | "- `yetibot/core` — the library: chat commands, adapters, and most logic.\n" |
|
576 | 578 | (catch Exception e (debug "delete-msg! failed:" (.getMessage e))))) |
577 | 579 |
|
578 | 580 | (defn- all-channel-messages |
579 | | - "Every message in a channel/thread, paginating past Discord's 100-per-call cap |
580 | | - (bounded for safety). Discord returns newest-first; callers sort as needed." |
| 581 | + "The most recent messages in a channel/thread (bounded to 20 for cost efficiency)." |
581 | 582 | [channel-id] |
582 | | - (loop [before nil acc []] |
583 | | - (let [opts (concat [:limit 100] (when before [:before before])) |
584 | | - batch (vec @(apply discord/get-channel-messages! (rest-conn) channel-id opts)) |
585 | | - acc' (into acc batch)] |
586 | | - (if (or (< (count batch) 100) (>= (count acc') 500)) |
587 | | - acc' |
588 | | - (recur (:id (peek batch)) acc'))))) |
| 583 | + (try |
| 584 | + (vec @(discord/get-channel-messages! (rest-conn) channel-id :limit 20)) |
| 585 | + (catch Exception e |
| 586 | + (debug "all-channel-messages failed:" (.getMessage e)) |
| 587 | + []))) |
589 | 588 |
|
590 | 589 | (defn- thread-context |
591 | 590 | "The full thread conversation, oldest-first, prefixed with the thread topic — |
|
0 commit comments