Repository navigation
Description
Language Affected
- Python
- TypeScript
🐛 Describe the bug
sendAnalyticsEvent() is async and rejects when the analytics request fails: a non-ok response (throw new Error(`HTTP error! status: ${response.status}`)) or a network error from fetch. Its two callers start it without awaiting it or attaching a .catch():
WalletProvider.trackInitialization()(typescript/agentkit/src/wallet-providers/walletProvider.ts), run right after any wallet provider's constructor returns. The surroundingtry/catchonly sees synchronous throws.- The wrapper that
@CreateActioninstalls around every action (typescript/agentkit/src/action-providers/actionDecorator.ts,sendAnalyticsEvent({ name: "agent_action_invocation", ... })), run on every action invocation.
The rejection is unhandled, and Node (15+) terminates the process on an unhandled rejection. So when the analytics endpoint is unreachable (offline, a firewall or egress policy that blocks it) or answers with an error, the host process exits right after a wallet provider is created, or in the middle of the first action the agent runs. In a local run against a dev chain (chain id 31337), the endpoint answered 400.
Open PR #1408 fixes the first call site only. With the equivalent of its change applied to the compiled dist/wallet-providers/walletProvider.js of 0.10.4, a failing agent_action_invocation request still terminates the process (see below).
Reproduction (only @coinbase/agentkit; fetch is replaced to simulate a failing analytics endpoint, so nothing is sent, and the RPC URL points at a closed local port):
// repro.mjs, run with: FAIL=init node repro.mjs or FAIL=action node repro.mjs
import { ViemWalletProvider, walletActionProvider } from "@coinbase/agentkit";
import { createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { baseSepolia } from "viem/chains";
// Simulate a failing analytics endpoint for one event type; nothing leaves the machine.
const fail = process.env.FAIL;
globalThis.fetch = async (url, init) => {
const [event] = JSON.parse(JSON.parse(init.body).e);
const failing =
(fail === "init" && event.event_type === "agent_initialization") ||
(fail === "action" && event.event_type === "agent_action_invocation");
console.log(`analytics ${event.event_type} -> ${failing ? 400 : 200}`);
return new Response("{}", { status: failing ? 400 : 200 });
};
process.env.RPC_URL = "http://127.0.0.1:9";
// Well-known Hardhat/Anvil test key.
const account = privateKeyToAccount("0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80");
const walletProvider = new ViemWalletProvider(
createWalletClient({ account, chain: baseSepolia, transport: http("http://127.0.0.1:9") }),
);
console.log("wallet provider created");
await new Promise(resolve => setTimeout(resolve, 100));
const [getWalletDetails] = walletActionProvider().getActions(walletProvider);
const result = await getWalletDetails.invoke({});
console.log("action returned:", result.split("\n")[0]);
console.log("still running");Observed (exit codes from echo $?):
$ node repro.mjs # no failure
wallet provider created
analytics agent_initialization -> 200
analytics agent_action_invocation -> 200
action returned: Error getting wallet details: HttpRequestError: HTTP request failed.
still running
# exit 0
$ FAIL=init node repro.mjs
wallet provider created
analytics agent_initialization -> 400
.../node_modules/@coinbase/agentkit/dist/analytics/sendAnalyticsEvent.js:50
throw new Error(`HTTP error! status: ${response.status}`);
^
Error: HTTP error! status: 400
at sendAnalyticsEvent (.../node_modules/@coinbase/agentkit/dist/analytics/sendAnalyticsEvent.js:50:15)
Node.js v24.21.0
# exit 1
$ FAIL=action node repro.mjs
wallet provider created
analytics agent_initialization -> 200
analytics agent_action_invocation -> 400
.../node_modules/@coinbase/agentkit/dist/analytics/sendAnalyticsEvent.js:50
throw new Error(`HTTP error! status: ${response.status}`);
^
Error: HTTP error! status: 400
at sendAnalyticsEvent (.../node_modules/@coinbase/agentkit/dist/analytics/sendAnalyticsEvent.js:50:15)
Node.js v24.21.0
# exit 1: the process ends before the action returns
Replacing the 400 response with throw new TypeError("fetch failed"), to simulate the error Node's fetch raises when the host cannot be reached, gives the same result for FAIL=init and FAIL=action: TypeError: fetch failed as the uncaught error and exit code 1.
With the equivalent of #1408's .catch(...) added to dist/wallet-providers/walletProvider.js, FAIL=init logs Failed to track wallet provider initialization: Error: HTTP error! status: 400 and exits 0, but FAIL=action still exits 1 with the same uncaught error.
Expected: a failed analytics request never ends the process or the action; at most a warning, as trackInitialization intends.
Possible fix: handle the rejection at the action call site too (sendAnalyticsEvent(...).catch(...)), or make sendAnalyticsEvent itself never reject (catch inside it), which covers both call sites and any future one. Separately, I found no option or environment variable that turns the analytics off, which would also let users in restricted networks avoid the request.
Versions
$ node --version
v24.21.0
$ npm list @coinbase/agentkit
└── @coinbase/agentkit@0.10.4
Both call sites are unchanged on main (2e6dbaf) at the time of writing.
Activity
docs: trace AgentKit's smart wallet provider through getClient() (#185)
feat: research by contract or name, a Base example, and AgentKit 0.10…
hey-research-lab commentedon Nov 2, 2026
Confirming this on 0.10.4 as of 2026-11-02:
https://cca-lite.coinbase.com/ampanswers 400 to theagent_action_invocationevent, so the first action any agent runs ends a Node process. Until a release attaches a.catch()inactionDecorator.ts, hosts can install anunhandledRejectionlistener that ignores only rejections whose stack runs throughsendAnalyticsEventand re-raises everything else. We ship that as an opt-in helper,guardAgentKitAnalytics()in @hey-research-lab/agentkit, if it's useful to anyone:https://github.com/hey-research-lab/hey-agentkit/blob/main/src/agentkit-analytics.ts