Skip to content

[FEATURE]: Enhance Input/Output Structure of "experimental.chat.system.transform" and "experimental.chat.messages.transform" Hooks for Better Usability #27364

Closed as not planned

Description

@FullStackPlayer

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Version

Current version: 1.14.48

Environment

Pure code logic, environment-agnostic.

Problem Description

While developing an OpenCode plugin, I discovered the experimental.chat.system.transform and experimental.chat.messages.transform hooks.

I was excited because they seemed perfect for fine-tuning system prompts and message history for each prompt. However, I quickly realized they didn't meet my expectations due to a shared limitation: the Input and Output data structures are insufficient. See the details below:

experimental.chat.system.transform

Parameters:

  • input: { sessionID?: string; model: Model }
  • output: { system: string[] }

Callers:

  • Caller 1: session/llm.ts:118-121 (Normal LLM call)
  • Caller 2: agent/agent.ts:451 (Agent generation, without session context)

experimental.chat.messages.transform

Parameters:

  • input: {}
  • output: { messages: { info: Message; parts: Part[] }[] }

Callers:

  • Caller 1: session/prompt.ts:1587 (Normal LLM call)
  • Caller 2: session/compaction.ts:411 (During compaction)

Common Issue

sessionID and messageID are important pieces of data for determining whether and how we should process the system prompt and message history for the current prompt. I suggest adding them to the input structure. (Of course, due to the differences in callers, it is acceptable for these fields to be optional/undefined in certain cases.)

Improvement Suggestions

experimental.chat.system.transform

Parameters:

  • input: { sessionID?: string; messageID?: string; model: Model }
  • output: { system: string[] }

experimental.chat.messages.transform

Parameters:

  • input: { sessionID?: string; messageID?: string; model: Model }
  • output: { messages: { info: Message; parts: Part[] }[] }

Feasibility Assessment

Since these are experimental hooks, the impact of the change is minimal. The proposed changes are backward compatible and require very little code modification, making them highly feasible.

Activity

  1. guillempuche commented on Jun 20, 2026

    @guillempuche

    Use case this blocks: after writing to apps/internal/src/*.tsx, check if the new content contains Lingui macros and conditionally inject "run i18n:extract before this turn ends" into the system prompt. Without file path or new content in system.transform, the injection has to be a standing rule in session.compacting that fires on every compaction regardless — coarse-grained and delayed. Access to recent tool output (at minimum the file path and new content from the preceding write/edit) would make this targeted and immediate.

    Reference: lingui-remind.sh

  2. github-actions commented on Aug 20, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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