Skip to content

Add QUIET_TOOL_CALLS option to mute per-tool and reasoning echoes to Slack - #15

Draft
mike2194 wants to merge 2 commits into
leecoder:mainfrom
mike2194:feat/quiet-tool-calls
Draft

mike2194 wants to merge 2 commits into
leecoder:mainfrom
mike2194:feat/quiet-tool-calls

Conversation

@mike2194

@mike2194 mike2194 commented Nov 3, 2026 •

Copy link
Copy Markdown

Summary

Adds a QUIET_TOOL_CALLS plugin option (and SLACK_QUIET_TOOL_CALLS env fallback) that silences the two most chatty event-stream echoes to Slack:

  • 🔧 _<tool> <args>_ — the per-tool progress line
  • 💭 <snippet> — reasoning blocks from models that expose them

A typical OpenCode session runs dozens of shell/read/grep/edit tool calls; forwarded one-per-line to a Slack thread, this drowns out the actually useful output. In Slack threads an engineer is watching passively (not driving the session), only the final assistant reply, question prompts, permission prompts, and background-task notices matter — and all four of those are preserved.

Default is "false", so existing installs see no behavior change.

Dependency

This PR is stacked on #14 (OpenCode V2 plugin API compatibility). It branches from fix/opencode-v2-plugin-compatibility because the quiet-mode gates live in the shared event loop that #14 feeds from both the V1 and V2 backends. Please merge #14 first; GitHub will auto-rebase this PR's diff view against main once #14 lands, and the commit here will apply cleanly on its own.

Until #14 merges, the diff on this PR shows both #14's changes and the quiet-mode change. The feat: add QUIET_TOOL_CALLS… commit (e48730e) is the only change new to this PR.

What changed

  • src/plugin.ts:
    • New module-level quietToolCalls boolean (defaults to false).
    • initializeRuntime reads options?.QUIET_TOOL_CALLS first, then process.env.SLACK_QUIET_TOOL_CALLS, accepting \"true\" or \"1\". Logs a one-line notice when quiet mode is on, matching the style of the attach timeout/default agent/allowed users log lines.
    • The two slackSend calls in the event loop that produce the 🔧 and 💭 messages are now gated on !quietToolCalls. seenParts.add(evt.id) still runs either way, so dedupe keys stay consistent across runtime flips.
    • Flows left untouched: question-tool forwarding, permission.asked prompts, collectBackgroundTaskIds / 🧵 bg-task notices, syncAssistantMessagesSinceCursor (final assistant reply).
  • README.md:
    • New row in the options table for `QUIET_TOOL_CALLS`, following the same default/fallback/accepted-value convention as the other rows.
    • The "Real-time Streaming" feature bullets for 🔧 and 💭 now note `(disable with QUIET_TOOL_CALLS)` so a reader skimming Features sees the escape hatch too.
  • `dist/plugin.js`: rebuilt (this repo tracks `dist/`, same as Support OpenCode V2 plugin API (dual V1/V2 default export, ported session/event backend) #14).

Testing

  • `npx tsc --noEmit` — clean.
  • `npm run build` — clean.
  • Live against a real OpenCode 2.2.5 server with this branch loaded as a local plugin path:
    • With `QUIET_TOOL_CALLS: "true"`, plugin log shows `quiet mode: suppressing 🔧 tool-call and 💭 reasoning echoes to Slack` at setup, and subsequent agent sessions post only final replies/questions/permissions to Slack. No 🔧 or 💭 lines.
    • Removing the option (or setting it to `"false"`) restores the previous streaming behavior with no code change.

Summary by cubic

Adds OpenCode V2 support alongside the existing V1 plugin API, and introduces a QUIET_TOOL_CALLS option to mute per-tool and reasoning echoes in Slack.

OpenCode V2 support

  • The plugin now exports both V1 server and V2 setup entrypoints, following OpenCode's dual-support pattern.
  • A shared SlackAgentBackend interface translates each version's wire shapes into a common turn-event stream; handleMessage, handleCommand, and sync logic use it instead of calling pluginClient directly.
  • Added a slack_test_prompt debug tool that exercises session creation and turn handling without a Slack connection, logging to /tmp/slack-agent-plugin.log.
  • Known gaps on V2: replying to the agent's question tool from Slack is unsupported, and plan/todo updates render as generic tool lines instead of a formatted checklist.
  • Removed the unused better-sqlite3 dependency, which was blocking npm install on newer Node versions.

QUIET_TOOL_CALLS

  • New option (with SLACK_QUIET_TOOL_CALLS env fallback) suppresses the 🔧 tool-call progress lines and 💭 reasoning snippets posted to Slack threads.
  • Final assistant replies, question prompts, permission requests, and background-task notices still post as before.
  • Defaults to off, so existing installs see no behavior change; accepts "true" or "1" to enable.

Written for commit e48730e. Summary will update on new commits.

View guided diff

OpenCode V2 requires a plugin's default export to have an `id` plus a
`setup` (or `effect`) function. This package only exported the V1
`{ id, server }` shape, so it failed to load on V2 with:

  Plugin must export a default definition with an id and an effect or
  setup function.

V2 also renamed or restructured every server endpoint this plugin
uses (session creation/messages/prompt, the permission reply
endpoint, and the SSE event stream), so a V2 `setup()` cannot just
call the existing V1 `server()` body unchanged.

This adds a `createV2Backend`/`createV1Backend` pair implementing a
shared `SlackAgentBackend` interface, and ports `handleMessage`,
`syncAssistantMessagesSinceCursor`, and `handleCommand` to it instead
of calling `pluginClient` directly. The package now default-exports
both a V2 `setup()` and the original V1 `server()`, following
OpenCode's documented dual-support pattern, so it keeps working on V1
hosts.

Known gaps on V2 (see README "OpenCode V2" section):
- Replying to the agent's `question` tool from Slack is not supported;
  the V2 plugin API has no reachable way to answer it.
- Plan/todo updates render as a generic tool-progress line instead of
  a formatted checklist (V2 removed the `todo.updated` event).
- `!agent`/`@agent` overrides switch the session's agent going
  forward instead of applying to one message only.

Also:
- Added a `slack_test_prompt` debug tool that exercises session
  creation, prompting, and turn-event handling without a Slack
  connection, for verifying this plugin against a real server.
- Removed the unused `better-sqlite3` dependency (not referenced
  anywhere in `src/`); its native build fails under newer Node
  versions and was blocking `npm install` for development.

Fixes leecoder#13
By default, the plugin forwards every OpenCode tool call to Slack as a
`🔧 _<tool> <args>_` progress line, and every reasoning block as a
`💭 <snippet>` message, so a chatty session (lots of shell/read/grep
calls, or a thinking model) floods the Slack thread. Users have asked
for a way to silence these without losing the actually useful messages:
final assistant replies, the agent's `question` prompts, permission
requests, and background-task notices.

This adds a `QUIET_TOOL_CALLS` plugin option (and `SLACK_QUIET_TOOL_CALLS`
env var fallback, matching the convention of the other options). When
set to `"true"` or `"1"`, `initializeRuntime` flips a module-level
`quietToolCalls` flag, and the two `slackSend` calls in the event loop
that produce the 🔧 and 💭 messages are gated on `!quietToolCalls`. All
other flows are untouched:

- `question`-tool forwarding to Slack still happens
- `permission.asked` prompts still forward
- `collectBackgroundTaskIds` / 🧵 bg-task notices still fire
- Final assistant messages still post via the normal
  syncAssistantMessagesSinceCursor path
- `seenParts` dedupe keys are still added, so flipping the option at
  runtime (next initialize) behaves predictably

Default is off (`false`), so existing installs see no behavior change.

README's options table has a new row for `QUIET_TOOL_CALLS`, and the
"Real-time Streaming" feature bullets now note the option.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant