Tasks: the bot writes the reply that started a task again, with files for the chat #9

Merged
kubus merged 4 commits from t3/deduplicate-task-results into main 2026-10-14 22:56:55 +00:00
Owner

Summary

  • When a task you started from the chat ends, the bot that started it rewrites that reply with the task's result, instead of writing a separate message. This eliminates duplicate messaging—the reply and the "here's what happened" are now one.
  • send_to_chat lets a task hand the bot in the chat a file (JSON, CSV, images) to show you how it went: data for a chart, a table, or raw output. The file goes to the task that reports to the chat, not to you as a download.
  • Bots now have a fixed icon and colour from packages/shared lists; Hatbot defaults to hat/amber, new bots get the first free colour.
  • Database migrations: bots table gains icon and color columns; attachments table gains for_chat to mark files the chat gets (not shown as message attachments).
  • resultText() formats a task's result for display: "Didn't finish. " on failure, or the summary alone on success.

Testing

  • Task started from chat ends: bot rewrites the reply with resultText(), not a new message. Reply shows as edited.
  • Task started from chat with send_to_chat: file marked forChat=true is handed to the reporting bot, not shown under the message.
  • Multiple tasks with files: at most 5 files per reporting task.
  • Bot creation: icon defaults to "hat", colour to the first unused one from BOT_COLORS.
  • Desktop and agent tasks both support send_to_chat; agent version works with sandbox files, both with content or path.
  • Migration 22 backfills task results into replies where the task is now done/failed.
  • Group chats and nudged bots: reply is not rewritten if the bot wasn't the one speaking.
  • Files with forChat=true don't appear in the attachments query for messages; only forChat=false files do.
## Summary - When a task you started from the chat ends, the bot that started it rewrites that reply with the task's result, instead of writing a separate message. This eliminates duplicate messaging—the reply and the "here's what happened" are now one. - `send_to_chat` lets a task hand the bot in the chat a file (JSON, CSV, images) to show you how it went: data for a chart, a table, or raw output. The file goes to the task that reports to the chat, not to you as a download. - Bots now have a fixed icon and colour from `packages/shared` lists; Hatbot defaults to hat/amber, new bots get the first free colour. - Database migrations: bots table gains `icon` and `color` columns; attachments table gains `for_chat` to mark files the chat gets (not shown as message attachments). - `resultText()` formats a task's result for display: "**Didn't finish.** <summary>" on failure, or the summary alone on success. ## Testing - Task started from chat ends: bot rewrites the reply with `resultText()`, not a new message. Reply shows as edited. - Task started from chat with `send_to_chat`: file marked `forChat=true` is handed to the reporting bot, not shown under the message. - Multiple tasks with files: at most 5 files per reporting task. - Bot creation: icon defaults to "hat", colour to the first unused one from `BOT_COLORS`. - Desktop and agent tasks both support `send_to_chat`; agent version works with sandbox files, both with `content` or path. - Migration 22 backfills task results into replies where the task is now done/failed. - Group chats and nudged bots: reply is not rewritten if the bot wasn't the one speaking. - Files with `forChat=true` don't appear in the attachments query for messages; only `forChat=false` files do.
When a task shown under a reply ended, its result replaced the reply and the chat model then
answered in a message of its own: the same news twice. Now the task only tells the chat model, which
writes that reply again with the conversation in mind; the message shows as being written until it
does, and is marked edited and unread after.

- message.rewrite tells the apps a reply is being written again (iOS and web).
- If the bot won't rewrite it (a routine result, your message told it first, or its turn failed), the
  task's result takes the reply's place as its text, so the model's context reads it too.
- Migration 22 does the same for replies whose tasks ended before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A background task can hand over data for the chat's reply: written out (content) or from the
sandbox (path), up to 5 files. They're stored on the task, marked for_chat (migration 23), and
don't show under the reply. When the bot is told how the task ended, <task_updates> names them and
they follow as documents or images, so it can draw a chart block from a JSON series. Bigger files
reach its sandbox by id. Files a task sent the owner are now named in the update too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The tool moves to tasks/send-to-chat.ts, shared by both runners. A desktop task can hand over what it
writes out, a desktop_shell file or a finished browser download. A file from a task another task
started goes on the task that reports to the chat, so it arrives with that one's result; the chat
gets at most 5 files per task it hears about.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Past CHART_MAX_POINTS a chart isn't drawn, only its JSON shows, and every value is an output token.
The chat prompt now says so, and to average or take the max per hour or day with code_run (or a
coarser step without it), aiming for about 200. Tasks' summaries, send_to_chat and the desktop
prompt say to reduce long data before handing it over. The limit comes from the shared constant.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kubus merged commit 7b4693c98f into main 2026-10-14 22:56:55 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
kubus/hatbot!9
No description provided.