{"record":{"id":"92f3c8f2c42ebfcc","repo":"mastra-ai/mastra","slug":"this-id-cannot-send-notification-no-agent-co","errorCode":null,"errorMessage":"[${this.id}] Cannot send notification: no agent connected. Was this provider passed to Agent({ signals: [...] })?","messagePattern":"\\[(.+?)\\] Cannot send notification: no agent connected\\. Was this provider passed to Agent\\((.+?)\\)\\?","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/signals/signal-provider.ts","lineNumber":457,"sourceCode":"  stop(): void {\n    this.stopPolling();\n    this.#subscriptions.clear();\n    this.#subscriptionsByResource.clear();\n    this.#subscriptionsByThread.clear();\n  }\n\n  // ── Convenience ────────────────────────────────────────────────────\n\n  /**\n   * Send a notification signal to the connected agent.\n   * Convenience wrapper around `this.agent.sendNotificationSignal()`.\n   *\n   * @throws If no agent is connected\n   */\n  protected async notify(notification: SendNotificationSignalInput, target: SignalProviderTarget): Promise<void> {\n    const agent = this.#connectedAgent;\n    if (!agent) {\n      throw new Error(\n        `[${this.id}] Cannot send notification: no agent connected. Was this provider passed to Agent({ signals: [...] })?`,\n      );\n    }\n\n    await agent.sendNotificationSignal(notification, {\n      resourceId: target.resourceId,\n      threadId: target.threadId,\n      ...(target.ifIdle ? { ifIdle: target.ifIdle } : {}),\n    });\n  }\n\n  // ── Internal ───────────────────────────────────────────────────────\n\n  #subscriptionKey(target: SignalProviderTarget, externalResourceId: string): string {\n    return `${target.resourceId}:${target.threadId}:${externalResourceId}`;\n  }\n\n  #threadKey(target: SignalProviderTarget): string {","sourceCodeStart":439,"sourceCodeEnd":475,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/signals/signal-provider.ts#L439-L475","documentation":"Signal providers can only send notifications through an agent they are connected to. notify() reads the internal #connectedAgent reference, and if it is unset the provider throws. Connection happens when the provider instance is passed to an Agent via the Agent({ signals: [...] }) option; a bare-constructed provider has no agent and cannot notify.","triggerScenarios":"Calling provider.notify(notification, target) (directly or via doNotify/poll/handleWebhook) on a provider that was instantiated but never passed into an Agent's signals array.","commonSituations":"Using a signal provider standalone (e.g. calling poll() or invoking a webhook handler) without wiring it to an agent; creating a new provider instance in one module while the agent was configured with a different instance; tests instantiating a provider to call notify() without an Agent fixture.","solutions":["Pass the provider instance to Agent({ signals: [provider] }) so it gets connected, then use that same agent-backed flow.","Ensure you pass the SAME provider instance to the agent — a second `new MyProvider()` creates an unconnected clone.","If the notification must be sent without an agent, don't use notify(); use the provider's lower-level delivery mechanism directly instead."],"exampleFix":"// before\nconst provider = new SlackSignalProvider({ token });\nawait provider.notify(notification, target); // throws: no agent\n// after\nconst provider = new SlackSignalProvider({ token });\nconst agent = new Agent({ name: 'my-agent', signals: [provider], ... });\n// now provider.notify(...) (or poll/webhook) resolves through agent.sendNotificationSignal","handlingStrategy":"validation","validationCode":"function assertProviderConnected(provider) {\n  const connected = provider.notify !== undefined && provider['#connectedAgent'] !== undefined;\n  // prefer an exposed isConnected() if available:\n  // if (!provider.isConnected?.()) throw new Error('Signal provider not connected to an agent');\n  return connected;\n}\n// Otherwise, guarantee wiring at construction:\nconst provider = new MySignalProvider(opts);\nconst agent = new Agent({ name: 'a', signals: [provider] });\nif (agent !== null && provider == null) throw new Error('unreachable');","typeGuard":"function isAgentConnected(provider) {\n  return provider != null && typeof provider.notify === 'function' &&\n    // the provider stores its connected agent in a private field;\n    // expose/observe via a successful dry-run or an isConnected() API when available\n    Boolean(provider.isConnected?.());\n}","tryCatchPattern":"try {\n  await provider.notify(notification, target);\n} catch (e) {\n  if (String(e?.message).includes('no agent connected')) {\n    console.error('Provider not wired to an Agent — pass it to Agent({ signals: [...] }) using the SAME instance');\n  } else throw e;\n}","preventionTips":["Always construct providers and immediately pass the SAME instance to Agent({ signals: [...] }).","Avoid `new Provider()` in multiple modules — export a single provider instance.","In tests, assert the agent fixture is configured with the provider before calling notify/poll/webhook handlers.","Expose or check an isConnected() helper if your provider offers one."],"tags":["signals","wiring","initialization"],"backgroundTag":"not-connected-to-agent","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}