β¨ feat: support agent tasks system#13289
Conversation
β¦ brief tool split support import md Major changes: - Split task CLI into modular files (task/, lifecycle, topic, doc, review, checkpoint, dep) - Split builtin-tool-task into task + brief tools (conditional injection) - Task review uses EvalBenchmarkRubric from @lobechat/eval-rubric - Task workspace: documents auto-pin via Notebook, tree view with folders - Task comments system (task_comments table) - Task topics: dedicated TaskTopicModel with userId, handoff fields, review results - Heartbeat timeout auto-detection in detail API - Run idempotency (reject duplicate runs) + error rollback - Topic cancel/delete by topicId only (no taskId needed) - Integration tests for task router (13 tests) - interruptOperation fix (string param, not object) - Global TRPC error handler in CLI Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> task document workflow task handoff loop ποΈ chore: consolidate task system migrations into single 0095 Merged 7 separate migrations (0095-0101) into one: - tasks, briefs, task_comments, task_dependencies, task_documents, task_topics tables - All fields including sort_order, resolved_action/comment, review fields - Idempotent CREATE TABLE IF NOT EXISTS, DROP/ADD CONSTRAINT, CREATE INDEX IF NOT EXISTS Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> fix interruptOperation topic auto review workflow topic handoff workflow finish run topic and brief workflow support task tool improve task schema update β¨ feat: add onComplete hook to task.run for completion callbacks When agent execution completes, the hook: - Updates task heartbeat - Creates a result Brief (on success) with assistant content summary - Creates an error Brief (on failure) with error message - Supports both local (handler) and production (webhook) modes Uses the new Agent Runtime Hooks system instead of raw stepCallbacks. LOBE-6160 LOBE-6208 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> β¨ feat: add Review system β LLM-as-Judge automated review Task review uses an independent LLM call to evaluate topic output quality against configurable criteria with pass/fail thresholds. - TaskReviewService: structured LLM review via generateObject, auto-resolves model/provider from user's system agent defaults - Model: getReviewConfig, updateReviewConfig on TaskModel - Router: getReview, updateReview, runReview procedures - CLI: `task review set/view/run` commands - Auto-creates Brief with review results LOBE-6165 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> β¨ feat: add TaskScheduler, multi-topic execution, and handoff context - TaskScheduler: interface + Local implementation (setTimeout-based), following QueueService dual-mode pattern - Multi-topic execution: `task run --topics N --delay S` runs N topics in sequence with optional delay between them - Handoff context: buildTaskPrompt() queries previous topics by metadata.taskId and injects handoff summaries into the next topic's prompt (sliding window: latest full, older summaries only) - Heartbeat auto-update between topics LOBE-6161 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> β¨ feat: add Heartbeat watchdog + heartbeat CLI Watchdog scans running tasks with expired heartbeats, marks them as failed, and creates urgent error Briefs. Heartbeat CLI allows manual heartbeat reporting for testing. - Model: refactored to use Drizzle operators (isNull, isNotNull, ne) instead of raw SQL where possible; fixed findStuckTasks to skip tasks without heartbeat data - Router: heartbeat (manual report), watchdog (scan + fail + brief) - Router: updateSchema now includes heartbeatInterval, heartbeatTimeout - CLI: `task heartbeat <id>`, `task watchdog`, `task edit` with --heartbeat-timeout, --heartbeat-interval, --description LOBE-6161 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> β»οΈ refactor: move CheckpointConfig to @lobechat/types Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> β¨ feat: add task run β trigger agent execution for tasks Task.run creates a topic, triggers AiAgentService.execAgent with task context, and streams results via SSE. Supports both agentId and slug. - Service: added taskId to ExecAgentParams, included in topic metadata - Router: task.run procedure β resolves agent, builds prompt, calls execAgent, updates topic count and heartbeat - CLI: `task run <id>` command with SSE streaming, --prompt, --verbose LOBE-6160 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> β¨ feat: add Checkpoint system for task review gates Checkpoint allows configuring pause points in task execution flow. Supports beforeIds (pause before subtask starts) and afterIds (pause after subtask completes) on parent tasks. - Model: CheckpointConfig type, getCheckpointConfig, updateCheckpointConfig, shouldPauseBeforeStart, shouldPauseAfterComplete - Router: getCheckpoint, updateCheckpoint procedures; integrated with updateStatus for automatic checkpoint triggering - CLI: `task checkpoint view/set` commands with --before, --after, --topic-before, --topic-after, --on-agent-request options - Tests: 3 new checkpoint tests (37 total) LOBE-6162 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> β¨ feat: add dependency unlocking on task completion When a task completes, automatically check and unlock blocked tasks whose dependencies are all satisfied (backlog β running). Also notify when all subtasks of a parent are completed. - Model: getUnlockedTasks, areAllSubtasksCompleted (Drizzle, no raw SQL) - Router: updateStatus hook triggers unlocking on completion - CLI: shows unlocked tasks and parent completion notification - Tests: 3 new tests (34 total) LOBE-6164 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> β¨ feat: add Brief system β schema, model, router, CLI Brief is a universal Agent-to-User reporting mechanism, not limited to Tasks. CronJobs, Agents, and future systems can all produce Briefs. - Schema: briefs table with polymorphic source (taskId, cronJobId, agentId) - Model: BriefModel with CRUD, listUnresolved (Daily Brief), markRead, resolve - Router: TRPC brief router with taskId identifier resolution - CLI: `lh brief` command (list/view/read/resolve) - Tests: 11 model tests - Migration: 0096_add_briefs_table.sql LOBE-6163 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> β¨ feat: add Task system β schema, model, router, CLI Implement the foundational Task system for managing long-running, multi-topic agent tasks with subtask trees and dependency chains. - Schema: tasks, task_dependencies, task_documents tables - Model: TaskModel with CRUD, tree queries, heartbeat, dependencies, document pinning - Router: TRPC task router with identifier/id resolution - CLI: `lh task` command (list/view/create/edit/delete/start/pause/resume/complete/cancel/tree/dep) - Tests: 31 model tests - Migration: 0095_add_task_tables.sql LOBE-6036 LOBE-6054 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Sorry @arvinxx, your pull request is larger than the review limit of 150000 diff characters
|
@nekomeowww @ONLY-yours - This PR introduces a new agent tasks system with significant backend/database changes (new task, brief, taskTopic models) and TRPC routers/services. Please coordinate on the backend architecture and general feature review. |
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
π‘ Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 699827d3d7
βΉοΈ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with π.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| await ctx.taskTopicModel.updateStatus(task.id, continueTopicId, 'running'); | ||
| await model.updateCurrentTopic(task.id, continueTopicId); |
There was a problem hiding this comment.
Persist new operationId when continuing a topic
In the continueTopicId branch we only set the topic status/current topic, but we never update task_topics.operationId with result.operationId. Subsequent operations like cancelTopic read operationId from task_topics, so after continuing a topic they can target an old finished operation instead of the currently running one.
Useful? React with πΒ / π.
| const taskId = task.id; | ||
| const taskIdentifier = task.identifier; | ||
| const { taskLifecycle } = ctx; | ||
| const db = ctx.serverDB; |
β¦erationId Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Reportβ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## canary #13289 +/- ##
==========================================
- Coverage 66.93% 66.72% -0.22%
==========================================
Files 1870 1879 +9
Lines 148122 150635 +2513
Branches 14897 17192 +2295
==========================================
+ Hits 99150 100504 +1354
- Misses 48861 50020 +1159
Partials 111 111
Flags with carried forward coverage won't be shown. Click here to find out more.
π New features to boost your workflow:
|
β¦n spread Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
β¦traint Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
β¦ mapping Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
β¦for FK constraints Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
β€οΈ Great PR @arvinxx β€οΈ The growth of project is inseparable from user feedback and contribution, thanks for your contribution! If you are interesting with the lobehub developer community, please join our discord and then dm @arvinxx or @canisminor1990. They will invite you to our private developer channel. We are talking about the lobe-chat development or sharing ai newsletter around the world. |
# π release: 20260326 This release includes **91 commits**. Key updates are below. - **Agent can now execute background tasks** β Agents can perform long-running operations without blocking your conversation. [#13289](#13289) - **Better error messages** β Redesigned error UI across chat and image generation with clearer explanations and recovery options. [#13302](#13302) - **Smoother topic switching** β No more full page reloads when switching topics while an agent is responding. [#13309](#13309) - **Faster image uploads** β Large images are now automatically compressed to 1920px before upload, reducing wait times. [#13224](#13224) - **Improved knowledge base** β Documents are now properly parsed before chunking, improving retrieval accuracy. [#13221](#13221) ### Bot Platform - **WeChat Bot support** β You can now connect LobeChat to WeChat, in addition to Discord. [#13191](#13191) - **Richer bot responses** β Bots now support custom markdown rendering and context injection. [#13294](#13294) - **New bot commands** β Added `/new` to start fresh conversations and `/stop` to halt generation. [#13194](#13194) - **Discord stability fixes** β Fixed thread creation issues and Redis connection drops. [#13228](#13228) [#13205](#13205) ### Models & Providers - **GLM-5** is now available in the LobeHub model list. [#13189](#13189) - **Coding Plan providers** β Added support for code planning assistant providers. [#13203](#13203) - **Tencent Hunyuan 3.0 ImageGen** β New image generation model from Tencent. [#13166](#13166) - **Gemini content handling** β Better handling when Gemini blocks content due to safety filters. [#13270](#13270) - **Claude token limits fixed** β Corrected max window tokens for Anthropic Claude models. [#13206](#13206) ### Skills & Tools - **Auto credential injection** β Skills can now automatically request and use required credentials. [#13124](#13124) - **Smarter tool permissions** β Built-in tools skip confirmation for safe paths like `/tmp`. [#13232](#13232) - **Model switcher improvements** β Quick access to provider settings and visual highlight for default model. [#13220](#13220) ### Memory - **Bulk delete memories** β You can now delete all memory entries at once. [#13161](#13161) - **Per-agent memory control** β Memory injection now respects individual agent settings. [#13265](#13265) ### Desktop App - **Gateway connection** β Desktop app can now connect to LobeHub Gateway for enhanced features. [#13234](#13234) - **Connection status indicator** β See gateway connection status in the titlebar. [#13260](#13260) - **Settings persistence** β Gateway toggle state now persists across app restarts. [#13300](#13300) ### CLI - **API key authentication** β CLI now supports API key auth for programmatic access. [#13190](#13190) - **Shell completion** β Tab completion for bash/zsh/fish shells. [#13164](#13164) - **Man pages** β Built-in manual pages for CLI commands. [#13200](#13200) ### Security - **XSS protection** β Sanitized search result image titles to prevent script injection. [#13303](#13303) - **Workflow hardening** β Fixed potential shell injection in release automation. [#13319](#13319) - **Dependency update** β Updated nodemailer to address security advisory. [#13326](#13326) ### Bug Fixes - Fixed skill page not redirecting correctly after import. [#13255](#13255) [#13261](#13261) - Fixed token counting in group chats. [#13247](#13247) - Fixed editor not resetting when switching to empty pages. [#13229](#13229) - Fixed manual tool toggle not working. [#13218](#13218) - Fixed Search1API response parsing. [#13207](#13207) [#13208](#13208) - Fixed mobile topic menus rendering issues. [#12477](#12477) - Fixed history count calculation for accurate context. [#13051](#13051) - Added missing Turkish translations. [#13196](#13196) ### Credits Huge thanks to these contributors: @bakiburakogun @hardy-one @Zhouguanyang @sxjeru @hezhijie0327 @arvinxx @cy948 @CanisMinor @Innei @lijian @lobehubbot @neko @rdmclin2 @rivertwilight @tjx666
π» Change Type
π Related Issue
π Description of Change
π§ͺ How to Test
πΈ Screenshots / Videos
π Additional Information