Asia/Shanghai
May 8, 2026

opencode-plugin-fixes now has a fourth guardrail

opencode-plugin-fixes 加上第四个护栏

Mingjian Shao
opencode-plugin-fixes now has a fourth guardrail
Archive note, July 2026: This repository is now read-only. The npm package was never published; the article is retained as a record of the final source implementation.
The annoying thing about long agent sessions is that the expensive failures are often tiny. A model does not need to misunderstand the task to break the run. It only has to stringify one nested field, flatten one array, or ask the same question again while the user is still answering.opencode-plugin-fixes started as a small source bundle for those edges. Its final source tree added a fourth guardrail: FixDcpCompressFlat.The final source tree covers four OpenCode runtime failure modes:
  • FixQuestionSchema repairs malformed question tool arguments.
  • FixMcpNestedObject parses only selected MCP schema fields, leaving file content untouched.
  • FixDcpCompressFlat restores DCP compress range payloads when a model preserves the data but breaks the nested array shape.
  • BlockRepeatQuestion prevents repeated prompt spam before the user replies.
The new DCP fix exists because range compression expects the native shape:
Json
{
  "topic": "Session summary",
  "content": [
    {
      "startId": "m0001",
      "endId": "m0008",
      "summary": "..."
    }
  ]
}
Some models were reliable with the same information as flat fields, but unreliable with content: [{ startId, endId, summary }]. The plugin accepts the flat form, repairs it before validation, and keeps native nested calls unchanged.This is the same design line as the earlier fixes: narrow repair, no broad magic. The plugin only touches the DCP compress tool. It does not parse arbitrary summaries, does not rewrite unrelated tools, and does not claim to change DCP's model-facing schema.That last limitation matters. If OpenCode rejects the call before hooks run, the proper long-term fix is still inside DCP itself: expose a flat schema and normalize inside the DCP tool implementation. But for the current OpenCode hook path, the local fix has already been verified in a real compression run.The final source tree contains four guardrails, but opencode-plugin-fixes was never published to npm. The package entry shown in the original article was therefore never valid and should not be added to OpenCode. The initial v0.1.0 tag contains three guardrails; FixDcpCompressFlat was added later to the final archived source.
2026 年 7 月归档说明: 本仓库现已只读。npm 包从未发布;本文仅作为最终源码实现的历史记录保留。
长上下文 agent 会话最烦人的地方是:真正昂贵的失败,往往不是模型完全不懂任务,而是一个很小的工具参数形状坏了。比如某个 nested field 被字符串化,某个 array 被 flatten,或者用户还没回答完,模型就根据 (no answer) 又问了一遍。opencode-plugin-fixes 本来就是为这些边缘情况做的小型源码合集。最终源码加入了第四个护栏:FixDcpCompressFlat最终源码覆盖四类 OpenCode runtime 故障:
  • FixQuestionSchema 修 question 工具参数形状。
  • FixMcpNestedObject 只解析少数 MCP schema 字段,不碰文件正文。
  • FixDcpCompressFlat 在模型保留了信息、但打坏 DCP compress nested array 形状时,把参数还原回来。
  • BlockRepeatQuestion 防止用户还没回答完时模型反复追问。
新的 DCP fix 是因为 range compression 期望的是这个原生形状:
Json
{
  "topic": "Session summary",
  "content": [
    {
      "startId": "m0001",
      "endId": "m0008",
      "summary": "..."
    }
  ]
}
有些模型能稳定给出同样的信息,但会把 content: [{ startId, endId, summary }] 这种 nested array 形状打坏。这个插件接受 flat 形式,在校验前修回 DCP 原生结构,同时不影响本来就正确的 nested 调用。它和前面几个插件遵守同一条线:只修窄问题,不做大魔法。它只碰 DCP 的 compress 工具;不解析任意 summary 字符串,不改无关工具,也不声称改变 DCP 暴露给模型看的 schema。最后这个限制很重要。如果 OpenCode 在 hook 运行之前就拒绝了调用,那长期正确修法还是进 DCP 内部:直接暴露 flat schema,然后在 DCP tool 实现里 normalize。但在当前 OpenCode hook 路径里,这个本地修复已经通过真实压缩会话验证。最终源码包含四个护栏,但 opencode-plugin-fixes 从未发布到 npm。原文中的 package entry 从未生效,不应加入 OpenCode 配置。初始 v0.1.0 tag 只有三个护栏;FixDcpCompressFlat 是后来加入最终归档源码的。
Share this post:
Enjoy this post? Subscribe via RSS: English | 中文