Skip to content

fix(core): deduplicate websearch consent prompts - #40869

Merged
jlongster merged 1 commit into
v2from
websearch-consent-lock
Aug 6, 2026
Merged

fix(core): deduplicate websearch consent prompts#40869
jlongster merged 1 commit into
v2from
websearch-consent-lock

Conversation

@opencode-agent

@opencode-agentopencode-agentBot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • serialize web-search provider selection behind a process-wide semaphore
  • re-check the selected provider after acquiring the permit, then retry the search outside the semaphore
  • time out the locked provider-selection flow after one minute so an abandoned form cannot block other searches indefinitely
  • add a five-way concurrent regression test that verifies only one consent form is created

Checks

  • bun test test/tool-websearch.test.ts --only-failures (from packages/core)
  • GOMAXPROCS=2 bun typecheck (from packages/core)
  • bun run lint packages/core/src/tool/plugin/websearch.ts packages/core/test/tool-websearch.test.ts
  • git diff --check
  • OpenCode Drive: five parallel websearch calls displayed one form; one Enter completed all five

Requested by: @jlongster (James Long via Slack)

const stored = yield* kv.get("websearch:provider")
if (stored === false) return yield* new WebSearch.DisabledError()
if (typeof stored === "string" && providers.some((provider) => provider.id === stored))
return yield* Effect.void

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you add these lines

return yield* kv.set("websearch:provider", providerID)
}),
)
.pipe(Effect.andThen(ctx.websearch.query(input)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what happens if the first form is ignored? don't think NOT ask for the form again?

@opencode-agent
opencode-agentBotforce-pushed the websearch-consent-lock branch 5 times, most recently from a2c000e to 9c68c96CompareAugust 6, 2026 18:34
@opencode-agent
opencode-agentBotforce-pushed the websearch-consent-lock branch from 9c68c96 to 3207722CompareAugust 6, 2026 18:42
@jlongster
jlongster disabled auto-merge August 6, 2026 21:50
@jlongster
jlongster merged commit 727beae into v2Aug 6, 2026
1 check passed
@jlongster
jlongster deleted the websearch-consent-lock branch August 6, 2026 21:50
github-actionsBot pushed a commit to ReStranger/opencode that referenced this pull request Aug 7, 2026
* upstream/v2: (84 commits)
fix(core): align shell output limits (anomalyco#41007)
feat(core): bound tool output (anomalyco#40929)
refactor(app): remove legacy layout (anomalyco#40947)
refactor(core): simplify file tools to lexical paths (anomalyco#40962)
fix(core): default custom agents to primary (anomalyco#40880)
fix(core): migrate legacy small model (anomalyco#40966)
fix(tui): dismiss stale permission prompts (anomalyco#40960)
fix(tui): use tab layout setting (anomalyco#40952)
fix(tui): keep model selection session scoped (anomalyco#40913)
feat(ai): expose model compatibility options (anomalyco#40942)
feat(cli): add session import and export (anomalyco#40914)
fix(core): deduplicate websearch consent prompts (anomalyco#40869)
test(core): cover config precedence
feat(tui): enable cwd-scoped session tabs by default
feat(core): normalize mixed config formats (anomalyco#40919)
fix(tui): simplify MCP status rows (anomalyco#40916)
fix(tui): compact single-line prompts (anomalyco#40924)
fix(config): omit unset optional values (anomalyco#40918)
fix(tui): open authorization links (anomalyco#40912)
refactor(mcp): remove unused registration status (anomalyco#40904)
...
teknium1 added a commit to NousResearch/hermes-agent that referenced this pull request Aug 17, 2026
Port from anomalyco/opencode#40869: parallel tool calls hitting the same
dangerous-command gate each enqueued their own _ApprovalEntry and fired
their own notify_cb — the user got N identical prompts and had to
/approve N times while the agent sat wedged.
_await_gateway_decision now detects an already-pending identical
approval (same command text + pattern-key set) in the session queue and
waits on the leader's event via _await_coalesced_leader instead of
re-prompting. Followers adopt session/always (persistence would auto-pass
a re-check anyway) and deny/timeout (re-asking a just-declined command is
prompt spam); a single-use 'once' makes the follower issue a fresh
prompt. Pre/post approval hooks fire with coalesced=True for followers.
teknium1 added a commit to NousResearch/hermes-agent that referenced this pull request Aug 17, 2026
Port from anomalyco/opencode#40869: parallel tool calls hitting the same
dangerous-command gate each enqueued their own _ApprovalEntry and fired
their own notify_cb — the user got N identical prompts and had to
/approve N times while the agent sat wedged.
_await_gateway_decision now detects an already-pending identical
approval (same command text + pattern-key set) in the session queue and
waits on the leader's event via _await_coalesced_leader instead of
re-prompting. Followers adopt session/always (persistence would auto-pass
a re-check anyway) and deny/timeout (re-asking a just-declined command is
prompt spam); a single-use 'once' makes the follower issue a fresh
prompt. Pre/post approval hooks fire with coalesced=True for followers.
lisajlau pushed a commit to lisajlau/hermes-agent that referenced this pull request Aug 20, 2026
Port from anomalyco/opencode#40869: parallel tool calls hitting the same
dangerous-command gate each enqueued their own _ApprovalEntry and fired
their own notify_cb — the user got N identical prompts and had to
/approve N times while the agent sat wedged.
_await_gateway_decision now detects an already-pending identical
approval (same command text + pattern-key set) in the session queue and
waits on the leader's event via _await_coalesced_leader instead of
re-prompting. Followers adopt session/always (persistence would auto-pass
a re-check anyway) and deny/timeout (re-asking a just-declined command is
prompt spam); a single-use 'once' makes the follower issue a fresh
prompt. Pre/post approval hooks fire with coalesced=True for followers.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@jlongster