Skip to content
This repository was archived by the owner on Feb 14, 2026. It is now read-only.
This repository was archived by the owner on Feb 14, 2026. It is now read-only.

[BUG]: skill loading resets agent to default one #28

@Doster-d

Description

@Doster-d

Problem

OpenCode automatically switches to the default agent, which leads to undesirable behavior.

Cause

When OpenCode uses skill_use, it does not set the original agent used when adding a skill to the prompt.

Evidence

Solution

Based on the information from this issue, the solution should be something like this:

import type { PluginInput } from '@opencode-ai/plugin';

export function createInstructionInjector(ctx: PluginInput) {
  // Message 1: Skill loading header (silent insertion - no AI response)
  const sendPrompt = async (text: string, props: { sessionId: string }) => {
    await ctx.client.session.prompt({
      path: { id: props.sessionId },
      body: {
        agent: props.agent
        noReply: true,
        parts: [{ type: 'text', text }],
      },
    });
  };
  return sendPrompt;
}

UPD1: context->props

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions