- 36tools in the integration
- 21reading and analysis tools
- 15action tools, each with an inverse
Routes chosen from measured behaviour
FAFOHive needed an X integration that AI agents could use for research and replies without burning a metered budget or posting twice. I built it behind the same governed tool gateway as every other tool, with the same identity, attribution and audit, on two programmatic routes: the official X API v2, and a third-party X data API that costs less for public research. A third route, the operator's own signed-in session, covers actions the official API does not allow here.
The official API goes through an allow-listed transport with OAuth 2.0 and PKCE for user context, and its Activity webhooks are checked before ingestion. Routing is fixed per action, chosen from measured platform behaviour. When the official API returned 403 for replies to some targets, I moved replies and quotes to the signed-in session and wrote the decision down, so behaviour never depends on which call happened to fail.
Tools shaped as jobs
Reading and acting sit on two separately authorised endpoints with separate credentials, so read access never grants the right to act. I generated a one-tool-per-endpoint surface first and threw it away. The read tools are jobs instead: find fresh conversations on a topic, profile a list of accounts in one batched call, find accounts similar to an audience through the cheap identifiers-first route, measure a hashtag's activity, report on one's own posts.
The action tools post, reply, quote, schedule, follow, like and send direct messages.
One owner for the budget and the send log
One service owns the shared rate limit, a monthly usage budget with reservations, the cache and a durable log of sends, so concurrent agents, the scheduler and the poller cannot each spend the full allowance. Every tool description states its cost formula and every result returns what it cost; the server enforces the budget. Every successful API response is kept, scrubbed of credentials, for later analysis without paying twice. The gateway itself is in Agents with real tools and no keys.
Each write is read back, and a write whose outcome cannot be established is never resent automatically.
A duplicated public post is worse than a missing one.
X's APIs and the data service are theirs; the workflow tools, routing, budget control and send durability are mine.