feat: enforce and optimise ToolMetadata sync flag#102
Conversation
🦋 Changeset detectedLatest commit: 8421658 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…d compiler - Core: callTool() checks fn.bridge.sync, enforces no-promise return, skips timeout race and OTel span wrapper for sync tools - Compiler: add __callSync() helper, use sync-aware branching at all call sites - Compiler: dual-path array map optimization (sync .map() vs async for...of) with runtime check on tool sync flags Co-authored-by: aarne <82001+aarne@users.noreply.github.com>
Co-authored-by: aarne <82001+aarne@users.noreply.github.com>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bridge | 8421658 | Commit Preview URL Branch Preview URL |
Mar 06 2026, 02:32 PM |
…st name Co-authored-by: aarne <82001+aarne@users.noreply.github.com>
sync flag
1. The Bug: Missing
|
…ion in sync tool path
1. Add withSyncSpan() to tracing.ts — synchronous span wrapper that
honours trace metadata without returning a Promise
2. Sync instrumented path now uses withSyncSpan + recordSpanError +
span?.end() — sync tools with {trace:true} produce OTel spans
3. Add missing AbortError → BridgeAbortError normalization in the
sync instrumented catch block
Co-authored-by: aarne <82001+aarne@users.noreply.github.com>
... Both issues fixed in 1383d20:
|
One Final (Extremely Minor) Performance TweakTake a look at how you are reading the const isSyncTool = (fnImpl as any).bridge?.sync === true;This works perfectly. However, remember that Currently, you are doing a dynamic property lookup on the function object ( Because you already built the Current: const timeoutMs = this.toolTimeoutMs;
const isSyncTool = (fnImpl as any).bridge?.sync === true;
// ── Fast path: no instrumentation configured ──────────────────
if (!tracer && !logger && !isOtelActive()) { ... }
// ── Instrumented path ─────────────────────────────────────────
const { doTrace, log } = resolveToolMeta(fnImpl);Suggested Optimization: const timeoutMs = this.toolTimeoutMs;
const { sync: isSyncTool, doTrace, log } = resolveToolMeta(fnImpl);
// ── Fast path: no instrumentation configured ──────────────────
if (!tracer && !logger && !isOtelActive()) { ... } |
Co-authored-by: aarne <82001+aarne@users.noreply.github.com>
... Done in c5a1e52. |
syncmetadata extraction intoresolveToolMetaExecutionTree.callToolto consumesyncfrom helper✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.