fix(cloudflare): fetch tunnel connections from dedicated endpoint after API removal - #8623
The-AarushiSingh wants to merge 4 commits into
Conversation
…he-top-options-compare (simstudioai#8612) * docs(library): update agentic-ai-coding-tools-what-they-are-and-how-the-top-options-compare * Pi Babysit: address PR simstudioai#8612 feedback --------- Co-authored-by: Sim Pi Agent <pi@sim.ai>
…imstudioai#8613) * feat(library): How do you build an AI bot for Discord without code? * Pi Babysit: address PR simstudioai#8613 feedback --------- Co-authored-by: Sim Pi Agent <pi@sim.ai>
…ead of extra E2B round trips (simstudioai#8621) * perf(sandbox): grant the run_code session lease in the reconnect instead of extra E2B round trips Reused Mothership workbench calls made five E2B control-plane requests: list, connect, getInfo + setTimeout on acquire (the set always fired), and getInfo on release. Connect now asks for max(5 min, remaining, lease), the handle records the deadline it requested, and acquisition/release skip the provider while that lower bound covers the request. Final deadlines are unchanged; unrequested deadlines are still read back. * test(sandbox): model connect as setting the deadline so a dropped preserve is caught
|
@The-AarushiSingh is attempting to deploy a commit to the Sim Team on Vercel. A member of the Team first needs to authorize it. |
|
| const connectionsRes = await fetch(connectionsUrl, { | ||
| method: 'GET', | ||
| headers: cloudflareHeaders(params.apiKey), | ||
| }) |
There was a problem hiding this comment.
Connections request ignores cancellation
If a workflow is cancelled or its deadline expires while Cloudflare's connections request is pending, this new fetch has neither the execution signal nor a timeout. Unlike the initial tunnel request, it can keep cloudflare_get_tunnel pending after cancellation. Pass the signal supplied to transformResponse and bound the request.
| const connectionsData = await connectionsRes.json() | ||
| if (connectionsData?.success && Array.isArray(connectionsData.result)) { | ||
| connections = connectionsData.result.flatMap( | ||
| (connector: { conns?: unknown[] }) => connector.conns ?? [] | ||
| ) | ||
| } | ||
| } catch { | ||
| connections = null | ||
| } |
There was a problem hiding this comment.
Connection failures are hidden
If Cloudflare rejects the connections request or it fails, the tool still reports success with connections: null and provides no reason. That makes a permissions or API failure hard to distinguish from unavailable connection data. Preserve a warning or error for the secondary lookup so users can diagnose it.
| 4. Filter out bot-authored messages, empty requests, disallowed users, and message IDs that have already been processed. | ||
| 5. Add the model step and write a system instruction defining the bot's role, boundaries, tone, and escalation policy. | ||
| 6. Add approved context or retrieval when the bot must answer from private or specialized information. | ||
| 7. Add safety and routing checks after generation. | ||
| 8. Add the Discord Send Message action and map the answer to the approved channel or thread. | ||
| 9. Record the source message ID only after the response path reaches its intended result, with a recovery policy for failures. |
There was a problem hiding this comment.
Deduplication storage is unspecified
These steps require processed message IDs to survive between scheduled runs, but the guide does not say where to store them. Sim's Variables block lasts only for one execution, while each poll retrieves recent messages again. Readers following the steps with workflow variables could therefore send repeated replies to the same message. Specify a durable store and how to read and update it.
| if (connectionsData?.success && Array.isArray(connectionsData.result)) { | ||
| connections = connectionsData.result.flatMap( | ||
| (connector: { conns?: unknown[] }) => connector.conns ?? [] | ||
| ) |
There was a problem hiding this comment.
Connection parsing lacks tests
The new flattening of connector responses has no regression test, and the existing Cloudflare tests cover block parameter defaults rather than this response. A response-shape mistake or silently empty connections result could go unnoticed. Add focused tests for successful connector data and a failed secondary request.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
Superseded by #8624, retargeted to staging with only the Cloudflare fix. |
fixes #8616
Cloudflare removed the
connectionsarray from cfd_tunnel get/list responses (EOL 2026-10-05).get_tunnel: secondary GET.../cfd_tunnel/{id}/connectionsand flatMapconnector.connslist_tunnels: stop promising connections (always null) to avoid N+1 and stay honest