npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gotgenes/opencode-agent-identity

v3.0.1

Published

OpenCode plugins for agent self-identity and per-message agent attribution

Readme

@gotgenes/opencode-agent-identity

npm version CI License: MIT TypeScript Bun OpenCode Plugin

OpenCode plugins for agent self-identity and per-message agent attribution.

What it does

This package provides two plugins that improve agent identity awareness in OpenCode sessions:

  • AgentSelfIdentityPlugin — Injects a one-liner identity statement (e.g., You are currently operating as the "build" agent.) into the system prompt so the model knows which agent it's operating as. Addresses OpenCode #7492.

  • AgentAttributionToolPlugin — Exposes an agent_attribution tool that any agent can call to get per-message attribution for the current session. Returns which agent produced each assistant response and which model was used. Useful for agents that review multi-agent sessions, like a Retrospective agent. Addresses OpenCode #14930.

Installation

Add the plugin to your opencode.json:

{
  "plugin": ["@gotgenes/opencode-agent-identity"]
}

Both plugins are loaded automatically when the package is installed.

How it works

Agent Self-Identity

When a user switches agents mid-session (e.g., Plan → Build → Plan), the newly active agent has no built-in way to know its own name. This plugin uses two hooks with shared, session-scoped state:

  1. experimental.chat.messages.transform — Reads the current agent name from the last user message's info.agent field.
  2. experimental.chat.system.transform — Appends an identity statement to the system prompt.

State is keyed by session ID so concurrent sessions don't interfere.

Agent Attribution Tool

All agents in a session share one flat conversation history, but MessageV2.toModelMessages() strips the info.agent metadata when converting to the format sent to the LLM. This plugin exposes an agent_attribution tool that retrieves per-message attribution on demand via the OpenCode SDK.

When called, the tool returns a numbered list of every message in the session. User messages show only the role; assistant messages include the agent name and the provider and model that produced the response:

1. user
2. assistant (project-manager) [anthropic/claude-sonnet-4-6]
3. user
4. assistant (product-manager) [anthropic/claude-sonnet-4-6]
5. user
6. assistant (project-manager) [anthropic/claude-sonnet-4-6]

Why a tool instead of inline tags?

An earlier version of this package (v1) injected [agent: X] tags directly into assistant message text in the conversation history. This caused two problems:

  1. Identity confusion: When switching agents mid-session, the accumulated tags from the previous agent overwhelmed the system prompt identity, causing the model to identify as the wrong agent.
  2. Self-authoring: Models learned the [agent: X] pattern and started generating the tags themselves, creating a feedback loop that reinforced the wrong identity.

The tool-based approach keeps the conversation history clean and lets agents query attribution only when they need it.

Integrating with your agents

To use the attribution tool, mention it in the agent's system prompt. For example, a Retrospective agent that reviews multi-agent sessions could include:

## Multi-agent attribution

This session may involve multiple agents. To determine which agent produced
each response, call the `agent_attribution` tool. It returns a numbered list
of every message in the session. User messages show only the role; assistant
messages include the agent name and the provider and model that produced the
response.

Upgrading

See MIGRATION.md for upgrade guides between major versions.

Development

Prerequisites

  • Bun — runtime, package manager, and test runner
  • prek — pre-commit hook framework (brew install prek)

Setup

bun install
prek install

Commands

| Command | Description | | --- | --- | | bun run check | TypeScript type checking | | bun run lint | Biome linting + formatting check + import sorting | | bun run lint:fix | Auto-fix all Biome issues | | bun run lint:md | Markdown linting | | bun run lint:all | All linting checks | | bun run format | Format all files | | bun run test | Run tests | | bun run test:watch | Run tests in watch mode | | bun run build | Build the package |

Pre-commit hooks

After running prek install, the following checks run automatically before each commit:

  • Trailing whitespace trimming
  • End-of-file newline enforcement
  • Large file detection
  • Markdown linting
  • Biome linting and formatting

Related projects

  • opencode-model-announcer — Analogous to AgentSelfIdentityPlugin but for model identity: injects the current model name (e.g., anthropic/claude-sonnet-4-6) into the system prompt so the model knows which model it is operating as.

License

MIT