Skip to content

[FEATURE]: Make agent lifecycle message injection extensible for custom agents #25753

Closed as not planned

Description

@botias-bot

Problem

The insertReminders function in packages/opencode/src/session/prompt.ts contains hardcoded agent.name === "plan" / agent.name === "build" checks that give these two built-in agents privileged message-injection behavior unavailable to custom agents:

// prompt.ts:241-282
if (input.agent.name === "plan") { ... }           // inject plan-mode reminder
if (wasPlan && input.agent.name === "build") { ... } // inject build-switch reminder
if (input.agent.name !== "plan" && assistantMessage?.info.agent === "plan") { ... }

This means custom agents cannot replicate the same lifecycle behaviors:

Behavior Built-in Agents Custom Agents
Enter-mode reminder injection Yes (hardcoded) No
Exit-mode transition reminder Yes (hardcoded) No
Synthetic context parts Yes No

Related Issues

Both issues identified the same gap and were closed for inactivity, not because the feature was implemented or rejected.

Proposed Solution

Add lifecycle hooks to the agent config schema so any agent can declare message injection behavior:

// opencode.jsonc or agent markdown frontmatter
{
  "agent": {
    "review": {
      "mode": "primary",
      "lifecycle": {
        "on_enter": "<system-reminder>You are now in review mode. Focus on finding bugs...</system-reminder>",
        "on_exit": "<system-reminder>Review mode deactivated.</system-reminder>",
        "on_enter_from": ["plan"]  // optional: only inject when switching from these agents
      }
    }
  }
}

This would replace the hardcoded name checks in insertReminders with a data-driven approach that works for any agent.

Impact

  • Custom agents could implement their own mode-like behaviors (review, debug, test, etc.)
  • Built-in plan/build agents would become first-class config entries rather than special cases
  • The insertReminders function would become a generic lifecycle dispatcher

Activity

  1. github-actions commented on May 4, 2026

    @github-actions
    Contributor

    This issue doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • The feature request template was not used — the required verification checkbox ("I have verified this feature I'm about to request hasn't been suggested before") is missing from the issue body.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


    This issue might be a duplicate of existing issues. Please check:

    (Note: #12498 and #14210 are already referenced in your issue body as prior closed issues — if this is a revival of those requests, please clarify that explicitly.)

    If you believe this was flagged incorrectly, please let a maintainer know.

  2. github-actions commented on May 4, 2026

    @github-actions
    Contributor

    This issue has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

    Feel free to open a new issue that follows our issue templates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions