Skip to content

fix: address Copilot review follow-ups from #56; docs: add n8n integration guide#58

Merged
KochC merged 1 commit into
devfrom
fix/tool-bridge-review-followups
Jul 5, 2026
Merged

fix: address Copilot review follow-ups from #56; docs: add n8n integration guide#58
KochC merged 1 commit into
devfrom
fix/tool-bridge-review-followups

Conversation

@KochC

@KochC KochC commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Summary

Addresses all four review comments left by copilot-pull-request-reviewer on #56, plus documents the n8n integration use case in the README.

Review follow-ups

  1. knownToolIDs grows unbounded (real issue): replaced the ever-growing Set with slotToolIDs, a Map keyed by slot name whose entries are replaced (not accumulated) every time that slot is reused. Bounded by pool size regardless of how many requests / unique tool schemas a long-lived process handles over its lifetime, instead of growing forever and bloating every subsequent turn's tools payload.
  2. Slot leak if registerToolBridge() throws after acquiring a slot (real issue, more serious): now releases its acquired slot back to the pool if anything after acquisition throws (e.g. client.mcp.add() failing to spawn/register the bridge). Previously such a slot was lost forever, since runAgentTurn() only releases a bridge once registerToolBridge() has already returned successfully — repeated failures would eventually exhaust the whole pool and hang every future tool-calling request in acquireBridgeSlot().
  3. Test leaks bridge slots without cleanup: the slot-isolation test now releases both bridges it acquires via releaseToolBridge() (now exported) in an after() hook instead of leaking them into the shared global pool for the rest of the test process.
  4. Second test doesn't reset global state: added general hygiene here too (see new regression test below), though the specific buildToolsMap(baseTools, null) case doesn't actually touch global state at all in this implementation (it returns early before calling getToolBridgeState()).

Also added a new regression test specifically for #2 (the slot-leak-on-failure fix): repeats a failing registration well beyond the pool size and confirms a subsequent registration still succeeds promptly, wrapped in a timeout race since node:test has no default per-test timeout and a regression would otherwise hang the suite instead of failing it cleanly.

Docs

README.md now documents using the proxy to pipe OpenCode's authenticated providers (GitHub Copilot, Anthropic, Bedrock, local Ollama, etc.) into n8n's native AI nodes — credential setup for both OpenAI/Anthropic node types, the model picker auto-populating from GET /v1/models, Basic LLM Chain vs. AI Agent + Tools, and the Docker-on-a-different-host + firewall caveat (learned the hard way testing this for real).

Testing

  • npm test — 141 passed (140 + 1 new)
  • npm run lint — clean

Related

…ation guide

Addresses all four review comments left on #56 by
copilot-pull-request-reviewer:

- knownToolIDs (an ever-growing Set) replaced with slotToolIDs, a Map
  keyed by slot name whose entries are replaced (not accumulated) on
  each reuse. Bounded by pool size regardless of how many
  requests/unique tool schemas a long-lived process handles over its
  lifetime, instead of growing forever and bloating every subsequent
  turn's tools payload.
- registerToolBridge() now releases its acquired slot back to the pool
  if anything after acquisition throws (e.g. client.mcp.add() failing
  to spawn/register the bridge). Previously such a slot was lost
  forever, since runAgentTurn() only releases a bridge once
  registerToolBridge() has already returned successfully - repeated
  failures would eventually exhaust the whole pool and hang every
  future tool-calling request in acquireBridgeSlot().
- index.test.js: the slot-isolation test now releases both bridges it
  acquires via releaseToolBridge() (now exported) in an after() hook,
  instead of leaking them into the shared global pool for the rest of
  the test process.
- New regression test for the slot-leak-on-failure fix: repeats a
  failing registration well beyond the pool size and confirms a
  subsequent registration still succeeds promptly (wrapped in a
  timeout race, since node:test has no default per-test timeout and a
  regression would otherwise hang the suite instead of failing it).

README.md: documents using the proxy to pipe OpenCode's authenticated
providers (GitHub Copilot, Anthropic, Bedrock, local Ollama, etc.)
into n8n's native AI nodes - credential setup for both OpenAI/Anthropic
node types, the model-picker auto-populating from GET /v1/models,
Basic LLM Chain vs AI Agent + Tools, and the Docker-on-a-different-host
+ firewall caveat.

Testing:
- npm test - 141 passed (140 + 1 new)
- npm run lint - clean
@KochC KochC self-assigned this Jul 5, 2026
@KochC KochC merged commit 55a38e0 into dev Jul 5, 2026
3 checks passed
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