Skip to content

Conversation

@IgorWarzocha
Copy link
Owner

@IgorWarzocha IgorWarzocha commented Jan 7, 2026

Summary of Changes

This pull request significantly enhances the agent's capability by introducing asynchronous execution for subagent tasks. This allows the main agent to continue its work while subtasks run in the background, improving efficiency and responsiveness. The user interface has been updated to provide clear visibility into the status and outcomes of these background tasks, ensuring a seamless user experience. Additionally, the system now intelligently manages session creation and deletion in the context of these new asynchronous workflows, and provides new configuration options for fine-grained control.

Highlights

  • Asynchronous Subagent Tasks: Introduced a 'fire-and-forget' mechanism for subagent tasks, allowing them to run in the background without blocking the main session. This includes background sessions, completion notifications, and configurable limits for concurrent tasks.
  • Enhanced TUI Support: The Terminal User Interface (TUI) now provides comprehensive support for background tasks, including displaying task summaries, showing their status in the sidebar, and providing compaction reminders for running tasks. Navigation to subagent sessions has also been streamlined.
  • Improved Session Management: Added checks to prevent starting new sessions if background tasks are still active. The session deletion logic has been refined to navigate to the parent session upon a child session's deletion, improving user flow.
  • Configurable Permissions and Limits: New configuration options (async_task_limit, async_task_permissions) have been added to control the maximum number of concurrent asynchronous background tasks and their specific permissions.
  • Agent Description Updates: The descriptions for the 'general' and 'explore' agents have been updated to highlight their suitability for asynchronous execution, guiding users on when to leverage this new capability.
Changelog
  • packages/opencode/src/agent/agent.ts
    • Updated descriptions for 'general' and 'explore' agents to explicitly mention their suitability for async execution.
  • packages/opencode/src/cli/cmd/tui/app.tsx
    • Implemented a check to prevent new session creation if active child background tasks are running, displaying a warning toast.
    • Modified session deletion logic to navigate to the parent session when a child session is deleted.
  • packages/opencode/src/cli/cmd/tui/context/sync.tsx
    • Refactored message.part.updated event handling for improved clarity.
  • packages/opencode/src/cli/cmd/tui/routes/session/index.tsx
    • Added Identifier import.
    • Implemented toast notifications for child session completion or failure.
    • Introduced SubtaskReminderMessage component to display subtask summaries within user messages.
    • Added several helper functions for subtask data handling and navigation (isSubtaskReminder, readTaskSummary, useSubagentNavigation, etc.).
    • Modified UserMessage and AssistantMessage components to correctly render and handle subtask parts.
    • Added SubtaskPartComp component for displaying individual subtask statuses.
    • Updated PART_MAPPING to include subtask parts.
    • Adjusted InlineTool to accept and handle SubtaskPart types.
  • packages/opencode/src/cli/cmd/tui/routes/session/sidebar.tsx
    • Added a 'Background Tasks' section to the sidebar, displaying running child sessions with their status and allowing expansion/collapse.
  • packages/opencode/src/config/config.ts
    • Added task_async permission rule.
    • Introduced async_task_limit and async_task_permissions to the experimental configuration.
  • packages/opencode/src/session/compaction.ts
    • Modified compaction logic to include information about running background tasks in the prompt, guiding the agent to summarize them.
  • packages/opencode/src/session/index.ts
    • Added runningChildren function to retrieve currently busy or retrying child sessions.
  • packages/opencode/src/session/message-v2.ts
    • Extended SubtaskPart type with subagentSessionID, status, error, and summary fields.
    • Added buildSubtaskSystemText to generate system messages for subtask completions/errors.
    • Modified toModelMessage to insert system messages for subtask status updates.
  • packages/opencode/src/session/prompt.ts
    • Modified SessionPrompt.prompt to only process pending subtasks.
    • Integrated taskToolAgentsSystem into the system prompt to inform the agent about async subagent sessions.
    • Added taskToolAgentsSystem and related helper functions for managing async task information in the system prompt.
  • packages/opencode/src/tool/task.ts
    • Defined TaskMetadata type for session metadata.
    • Updated TaskTool input schema to include async and name parameters.
    • Added permission checks for task_async and enforced async_task_limit for concurrent tasks.
    • Revised permission handling for subagent sessions, incorporating asyncPermissions.
    • Refactored event subscription for subtask summary updates.
    • Implemented extensive logic for async task execution, including parent notification, metadata updates, and error handling.
    • Ensured async: false is explicitly set for synchronous tasks in metadata.
  • packages/opencode/src/tool/task.txt
    • Updated the Task tool description to include details about async mode.
    • Added detailed usage notes for async mode, including when to use it and how completion notifications work.
  • packages/sdk/js/src/v2/gen/types.gen.ts
    • Updated Part and SubtaskPartInput type definitions to include new fields for subagent session ID, status, error, and summary.
    • Added async_task_limit to Config.experimental type.

@gemini-code-assist
Copy link

Summary of Changes

Hello @IgorWarzocha, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the agent's capability by introducing asynchronous execution for subagent tasks. This allows the main agent to continue its work while subtasks run in the background, improving efficiency and responsiveness. The user interface has been updated to provide clear visibility into the status and outcomes of these background tasks, ensuring a seamless user experience. Additionally, the system now intelligently manages session creation and deletion in the context of these new asynchronous workflows.

Highlights

  • Asynchronous Subagent Tasks: Implemented a 'fire-and-forget' mechanism for subagent tasks, allowing them to run in the background without blocking the main session. This includes background sessions and completion notifications.
  • TUI Enhancements for Async Tasks: Added comprehensive TUI support for background tasks, including displaying task summaries, showing status in the sidebar, and providing compaction reminders for running tasks.
  • Session Management Improvements: Introduced checks to prevent starting new sessions if background tasks are still active and refined session deletion logic to navigate to the parent session upon child session deletion.
  • Configurable Async Task Limit: Added a new configuration option (async_task_limit) to control the maximum number of concurrent asynchronous background tasks per parent session.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant new feature: asynchronous, fire-and-forget subagent tasks. The changes are comprehensive, spanning backend logic for task management, TUI components for displaying task status and results, and configuration options.

My review focuses on the implementation of the async flow and the new UI components. The core logic for async tasks, including concurrency limiting and completion notifications, is well-implemented. The UI additions, such as the background task list in the sidebar and toast notifications, provide good visibility into running tasks.

I've identified a few areas for improvement, primarily related to code duplication and type safety. There's an opportunity to refactor duplicated handleClick logic into a reusable hook. I also found some confusing error handling logic in the async task implementation that could be simplified. Finally, strengthening some types would improve maintainability.

Overall, this is a solid implementation of a complex feature. Addressing the suggested refactorings will enhance the code's robustness and clarity.

@IgorWarzocha
Copy link
Owner Author

/gemini review the current state of the pr and suggest improvements to the code against the standards of the rest of the repo (if any).

@IgorWarzocha
Copy link
Owner Author

/gemini summary suggest a more comprehensive pr description, up do date with the current state

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant and well-implemented feature for running subagent tasks asynchronously. The changes span across tool definitions, session management, TUI components, and configuration, all of which appear robust and thoughtfully designed. The core logic for fire-and-forget tasks, including progress updates and completion notifications, is solid. The TUI enhancements, such as the new background tasks section in the sidebar and completion toasts, will greatly improve user experience. The prompt engineering updates are also excellent, providing clear instructions to the LLM on how to use the new async capabilities. I have one suggestion to improve type safety.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a significant new feature for running subagent tasks asynchronously. The implementation is comprehensive, covering core logic, UI updates for task tracking, configuration options, and permission handling. My review includes a few suggestions to improve code efficiency, type safety, and maintainability in the new logic.

@IgorWarzocha IgorWarzocha changed the title feat(async-agents): fire-and-forget subagent tasks feat(tui): fire-and-forget async subagent tasks Jan 7, 2026
Repository owner deleted a comment from gemini-code-assist bot Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants