From ce58d390c79f49df64d0545ff6014b8de766a76a Mon Sep 17 00:00:00 2001 From: Eric Juta Date: Fri, 23 Oct 2026 18:15:48 +0000 Subject: [PATCH 1/3] docs(predictions): push prediction events into Claude Code routines Replaces the claim that a webhook cannot start a Claude turn. Adds the routine push recipe, delivery semantics, token rotation, limits, safety, and a scheduled-routine pull alternative. Describes behavior from the implementation brief for t-y-b-b/nextjs-ai-chatbot#2690 and is not proven in production yet. --- docs/connect/claude.mdx | 55 ++++++++++++++++++++++++- docs/predictions-mcp/events.mdx | 73 ++++++++++++++++++++++++++++----- docs/predictions-mcp/tools.mdx | 24 +++++------ tools/docs/venue-tools.json | 10 ++--- 4 files changed, 132 insertions(+), 30 deletions(-) diff --git a/docs/connect/claude.mdx b/docs/connect/claude.mdx index 36856198..3a30254f 100644 --- a/docs/connect/claude.mdx +++ b/docs/connect/claude.mdx @@ -83,11 +83,62 @@ Prediction trading and prediction events use a second connector, separate from G - **Claude web and Desktop:** open **Customize → Connectors → + → Add custom connector**, enter **Ask Gina Predictions** and `https://askgina.ai/ai/predictions/mcp`, add it, choose **Connect** and complete Gina OAuth. - **Claude Code:** the [Predictions client setup](/predictions-mcp/client-setup#claude-code) has the `claude mcp add` command for the `predictions` server. -Ask Gina does not push events into a Claude conversation. Claude can create a pull subscription with `createPredictionEventSubscription` and no `destinationId`, then call `getPredictionEvents` with the returned `subscriptionId` and `cursor` when you ask it to check. Always pass the `subscriptionId`, because without it the call reads the whole retained account log instead of the subscription's events. Save the returned `cursor`, call again while `hasMore` is `true`, dedupe on `eventId`, and read your account state again when `truncated` is `true`. A pull subscription that nobody reads for 7 days pauses. Resume it with `updatePredictionEventSubscription`, passing its `id` and `patch.enabled: true`. +Ask Gina cannot push events into a Claude chat or a Claude Code session that is already open. A Claude Code routine can receive them instead, as described in [Push events into Claude Code (routine)](#push-events-into-claude-code-routine). To read events inside a chat, Claude can create a pull subscription with `createPredictionEventSubscription` and no `destinationId`, then call `getPredictionEvents` with the returned `subscriptionId` and `cursor` when you ask it to check. Always pass the `subscriptionId`, because without it the call reads the whole retained account log instead of the subscription's events. Save the returned `cursor`, call again while `hasMore` is `true`, dedupe on `eventId`, and read your account state again when `truncated` is `true`. A pull subscription that nobody reads for 7 days pauses. Resume it with `updatePredictionEventSubscription`, passing its `id` and `patch.enabled: true`. In Claude Code, `/loop 5m` followed by that read prompt checks on an interval while the session is open. The [Prediction events](/predictions-mcp/events#poll-from-claude-code) page has the prompt and its limits. -A Claude agent can now create its own webhook destination with `createWebhookDestination` and test it with `sendWebhookTestEvent`, without a browser step. Delivering events to that URL does not start a Claude turn by itself, so a receiver you run has to do something with them. See [Prediction events](/predictions-mcp/events). +A Claude agent can create its own webhook destination with `createWebhookDestination` and test it with `sendWebhookTestEvent`, without a browser step. A plain webhook URL does not start a Claude turn by itself, so a receiver you run has to act on the events. A routine's fire URL is the exception, because Claude Code starts a session for each call. See [Prediction events](/predictions-mcp/events). + +## Push events into Claude Code (routine) + +A Claude Code routine is a saved prompt that runs as a cloud session. Its API trigger is a URL that starts a new session when called. Register that URL as an Ask Gina destination and Ask Gina starts a session whenever your Polymarket orders or trades change. You run no receiver. Anthropic's docs now call routines scheduled tasks and label them a research preview, so their behavior and limits can change. See [Automate work with scheduled tasks](https://code.claude.com/docs/en/routines). + +You need a Claude plan with Claude Code on the web (Pro, Max, Team or Enterprise), the [Predictions connector](#add-the-predictions-connector) in the Claude session where you create the subscription, and a finished Predictions account in Ask Gina. + +1. **Create the routine.** Open [claude.ai/code/routines](https://claude.ai/code/routines), choose **New task** and write the prompt. Claude hands the fired text to the routine as untrusted data, so the prompt has to tell Claude to read it. For example: + + ```text + Ask Gina sent prediction events in the routine-fire-payload block, as a JSON array. List each distinct eventId once with the event name and the order or trade it describes. Do not place, change or cancel any order. If the block holds no events, say so and stop. + ``` + +2. **Choose its connectors.** A new routine includes every connector on your Claude account. Remove the ones it does not need. Keep the Predictions connector out unless the routine must read your account, because that connector also carries the trading tools. See [Safety](#safety-for-routine-push). +3. **Add an API trigger.** Edit the routine, click **+** in the **Trigger** row and choose **API**. Copy the **Fire URL**. Click **Generate token** and copy the token straight away. Claude shows it once and cannot show it again. +4. **Register it with Ask Gina.** On the [settings page](https://askgina.ai/profile/webhooks), choose **Add destination**, enter a label, paste the Fire URL as the **Webhook URL** and paste the token as the **Signing secret**. The Fire URL looks like `https://api.anthropic.com/v1/claude_code/routines/trig_.../fire` and the token starts with `sk-ant-oat01-`. The settings page is the better path because the token goes from you to Ask Gina without passing through a chat. A Claude agent can instead call `createWebhookDestination` with the same URL as `url` and the token as `secret`. Then the token sits in that conversation's transcript, and anyone who can read it can start your routine until you regenerate the token. Ask Gina cannot generate this token for you, so a create call with no `secret` is refused. +5. **Subscribe.** Ask Claude to call `createPredictionEventSubscription` with the `destinationId` from step 4. Add a filter if the routine should only hear about some markets or orders. +6. **Send a test.** Press **Send test event** on the settings page or ask Claude to call `sendWebhookTestEvent`. It starts a real session, so expect a new run in the routine's history. A test uses one of the routine's fires for the hour. + +### What the routine receives + +Ask Gina fires a routine at most once every 150 seconds per destination. Each fire carries every event waiting at that moment, as a JSON array of the [event envelopes](/predictions-mcp/events#what-you-get) in order, behind a short note. The note tells Claude that events can repeat, that it should dedupe on `eventId` and that the message is not your approval to trade. Events that do not fit in one fire wait for the next one. Delivery is at least once. + +Each fire is a new session with no memory of earlier ones. The routine can drop repeats inside one fire, but it cannot know that an earlier fire carried the same `eventId`. A repeated notification is usually harmless. If it is not for your use, keep the ids you have handled somewhere the routine can write. + +The [Prediction events](/predictions-mcp/events#claude-code-routines) page lists what happens on each Anthropic error, how to rotate the token and the limits. In short, a regenerated token stops working at once, so rotate it in Ask Gina right after you regenerate it. A routine you paused or deleted pauses delivery. + +### Safety for routine push + +A fire is a notification. It is not approval to trade, and Claude runs a routine without you in the loop. Anthropic starts the session in auto mode, where a classifier decides which actions proceed, so no prompt appears for you to answer unless an ask rule or repeated blocks stop the run. Ask Gina's trading tools are marked destructive, which makes a normal client ask you first, but a routine that holds the Predictions connector can reach them. + +The only limit that does not depend on the prompt is the connector list. Leave the Predictions connector off a routine that should only notify you, and let it report through another connector such as email or chat. If the routine does need the Predictions connector, say in the prompt that it must never place, change or cancel orders, and treat that as a request, not a guarantee. Ask the routine to tell you what it found and let you place the order in Gina yourself. + +Each fire uses your Claude subscription, like an interactive session. Ask Gina does not charge for deliveries. Anthropic limits fires per routine and per account each hour, and Ask Gina keeps one destination under the routine limit. See [Limits and billing](/predictions-mcp/events#claude-code-routines). + +### No push: poll from a scheduled routine + +A routine can instead run on a schedule and read the event log with a pull subscription. This needs no destination, no token and no browser step. + +1. Ask Claude to call `createPredictionEventSubscription` without a `destinationId`, and note the `subscriptionId` and `cursor`. +2. Create a routine with a **Schedule** trigger and the Predictions connector. For example: + + ```text + Call getPredictionEvents with subscriptionId and the cursor stored at . If hasMore is true, call again with the new cursor until it is false. Store the latest cursor. List each new eventId once with the event name and the order or trade it describes. If truncated is true, say so and read my account state again before you report. Do not place, change or cancel any order. + ``` + +3. Pick a schedule. Anthropic rejects cron expressions that run more often than once per hour, so the shortest interval is hourly. A run at the top of the hour can start several minutes late, so pick a few minutes past it. + +Every run starts with no memory, so the cursor has to live somewhere the routine can read and write, such as a file in a repository the routine clones or a note in another connector. Without a stored cursor, each run would read from the subscription's start. Reading the subscription counts as activity, so an hourly routine also keeps it from pausing after 7 days unread. + +Anthropic says routines can call the connectors on your Claude account, and that servers added at [claude.ai/customize/connectors](https://claude.ai/customize/connectors) count. A server you added only with `claude mcp add` is stored on your machine and does not. Ask Gina has not run a routine against the Predictions connector, so open the first run and check that the `getPredictionEvents` call succeeded before you rely on it. ## Verify your first result diff --git a/docs/predictions-mcp/events.mdx b/docs/predictions-mcp/events.mdx index 3203eafa..626de963 100644 --- a/docs/predictions-mcp/events.mdx +++ b/docs/predictions-mcp/events.mdx @@ -1,9 +1,9 @@ --- title: "Prediction events" -description: "Subscribe an agent to order and trade events on your Polymarket account and receive them as signed webhooks or by cursor pull." +description: "Subscribe an agent to order and trade events on your Polymarket account and receive them as signed webhooks, in a Claude Code routine or by cursor pull." --- -Prediction events let an agent find out what happened to an order without asking again. Ask Gina watches your Polymarket account and records each order and trade transition in an event log. Your agent either reads that log with a cursor or has Ask Gina push each event to a webhook you registered. +Prediction events let an agent find out what happened to an order without asking again. Ask Gina watches your Polymarket account and records each order and trade transition in an event log. Your agent either reads that log with a cursor or has Ask Gina push events to a webhook you registered. A Claude Code routine can also receive them, and Ask Gina starts a session for it. ## Connect the Predictions connector @@ -57,10 +57,10 @@ These tools are native tools on the Predictions connector. The [native tools ref | Tool | Use it for | | ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `listWebhookDestinations` | Read the destinations you registered: id, label, host, status and last test. It never returns a URL or a secret. | -| `createWebhookDestination` | Register a destination. Returns a generated secret once when you pass none. | -| `rotateWebhookDestinationSecret` | Replace the secret of an active destination. | +| `createWebhookDestination` | Register a destination. Returns a generated secret once when you pass none. A Claude routine's fire URL needs the routine's token as `secret`. | +| `rotateWebhookDestinationSecret` | Replace the secret of an active destination. A Claude routine destination needs its new token. | | `disableWebhookDestination` | End a destination for good. This cannot be undone. | -| `sendWebhookTestEvent` | Send one signed test event and return the HTTP `status` and an `outcome`. | +| `sendWebhookTestEvent` | Send one test event and return the HTTP `status` and an `outcome`. A signed event for a webhook, a real session for a Claude routine. | | `createPredictionEventSubscription` | Subscribe to order and trade events, optionally filtered, with a `destinationId` for webhook delivery or without one to pull. | | `listPredictionEventSubscriptions` | Read subscriptions, their filter, status and why one is paused. | | `updatePredictionEventSubscription` | Change the name, filter, destination or pause state with one partial patch. `patch.enabled: true` resumes a paused subscription. It cannot change a subscription an MCP Events client created; delete that one instead. | @@ -90,7 +90,7 @@ Each call to an event tool is metered like a read tool. Deliveries to your webho ## Register a webhook destination -A destination is the HTTPS endpoint that receives your events, plus the secret Ask Gina signs them with. You can register one in two ways. Both make the same kind of destination, and both share one pool: the same cap, the same rate limits, and each destination shows up in `listWebhookDestinations` and on the settings page. +A destination is the HTTPS endpoint that receives your events, plus the secret Ask Gina signs them with. For a Claude routine, the endpoint is the routine's fire URL and the secret is its token, which Ask Gina sends as a bearer token in place of a signature. You can register one in two ways. Both make the same kind of destination, and both share one pool: the same cap, the same rate limits, and each destination shows up in `listWebhookDestinations` and on the settings page. Create the receiver first. For Grok, that is a webhook trigger on an automation. Copy its endpoint and signing secret. Grok shows the secret only when the trigger is created or rotated. @@ -134,15 +134,15 @@ These rules apply the same way on both paths. - The URL must be `https`, use the default port, carry no credentials and name a public DNS host. IP addresses, `localhost` and internal names are refused, and so is a host that resolves to a private, loopback, link-local or metadata address. Redirects are never followed, and a `3xx` answer counts as a failed delivery. - The secret is stored encrypted and is never shown again. Tools and the page show the host, not the full URL, because a trigger URL can itself be a bearer credential. - Limits: 5 active destinations per account, shared by the settings page and the tools. Past it, `createWebhookDestination` fails with `WEBHOOK_DESTINATION_LIMIT_REACHED` and `details.limit`. Adding destinations and sending test events are each limited to 10 per hour, shared the same way. A refused call names the `action` and the `limit`. -- To replace a secret, use **Rotate secret** on the row or `rotateWebhookDestinationSecret`. The previous secret keeps signing alongside the new one for 24 hours, so you can update the receiver without losing deliveries. +- To replace a secret, use **Rotate secret** on the row or `rotateWebhookDestinationSecret`. The previous secret keeps signing alongside the new one for 24 hours, so you can update the receiver without losing deliveries. A Claude routine destination has no such overlap. See [Rotate the routine token](#rotate-the-routine-token). - Disabling ends the destination and cannot be reversed. Register a new destination instead. It pauses the subscriptions that use it, and it works from the page (**Disable**) or from `disableWebhookDestination`. -- A test event signs `prediction.subscription.health.v1` with `kind: "test"`. Ask Gina sends it once, retries nothing and does not store it in the event log. It starts a real automation on receivers such as Grok, so expect it to run. +- A test event signs `prediction.subscription.health.v1` with `kind: "test"`. Ask Gina sends it once, retries nothing and does not store it in the event log. It starts a real automation on receivers such as Grok, so expect it to run. A Claude routine gets a short test message instead of a signed event, and that also starts a real session. Then ask your agent to list the destinations and create a subscription with the `destinationId`. The agent sees labels and ids only. ## Verify Standard Webhooks signatures -Ask Gina signs every delivery with the [Standard Webhooks](https://www.standardwebhooks.com) scheme and sends one event per request. +Ask Gina signs every webhook delivery with the [Standard Webhooks](https://www.standardwebhooks.com) scheme and sends one event per request. A Claude routine destination works differently and is covered in [Claude Code routines](#claude-code-routines). | Header | Value | | ----------------------- | ---------------------------------------------------------------------------------------------------------- | @@ -198,7 +198,7 @@ Claude Code can run the read on an interval while a session is open. The `/loop` /loop 5m Call getPredictionEvents with subscriptionId and the cursor you saved last. If hasMore is true, call again with the new cursor. Save the latest cursor to .gina-events-cursor. Report each new eventId once and say nothing if there are none. ``` -A `/loop` task runs only while Claude Code is running and idle, so closing the session stops it. A recurring task also expires on its own, so check the expiry on that page and recreate the task before it ends. If Claude Code stops, start a new `/loop` that reads the saved cursor. For polling that does not depend on an open session, the same page points to cloud scheduled tasks. Polling is a read only. It does not place orders, and an event that arrives is not approval to act on it. +A `/loop` task runs only while Claude Code is running and idle, so closing the session stops it. A recurring task also expires on its own, so check the expiry on that page and recreate the task before it ends. If Claude Code stops, start a new `/loop` that reads the saved cursor. For polling that does not depend on an open session, a scheduled routine can run the same read. See [No push: poll from a scheduled routine](/connect/claude#no-push-poll-from-a-scheduled-routine). Polling is a read only. It does not place orders, and an event that arrives is not approval to act on it. ## Grok webhook triggers @@ -211,6 +211,57 @@ Grok Bot starts an automation from a webhook trigger, so it receives events by p The signing secret appears in the Grok conversation when Grok passes it to `createWebhookDestination`. If you rotate the secret in Grok, call `rotateWebhookDestinationSecret` with the new `secret`, or use **Rotate secret** on the same settings row, before the next event. +## Claude Code routines + +A Claude Code routine can receive events without a receiver of your own. Ask Gina calls the routine's API trigger, and Claude Code starts a new cloud session for each call. The [Claude page](/connect/claude#push-events-into-claude-code-routine) walks through creating the routine and registering it. This section describes how delivery behaves. + +Anthropic marks routines as a research preview and the fire endpoint as experimental, so the details below can change on its side. See [Trigger a routine through the API](https://platform.claude.com/docs/en/api/claude-code/routines-fire). + +### Register a routine + +Ask Gina treats a destination as a Claude routine when its `url` is exactly `https://api.anthropic.com/v1/claude_code/routines/trig_.../fire`, with the routine's own id in place of the dots. Any other `api.anthropic.com` address is refused. + +For a routine, the `secret` is required and must be the routine's API trigger token, which starts with `sk-ant-oat01-`. Ask Gina cannot generate one, so `createWebhookDestination` without a `secret` fails with `INVALID_ARGUMENTS`. Register it on [askgina.ai/profile/webhooks](https://askgina.ai/profile/webhooks) when you can. The token then never enters a chat. If an agent registers it with the tool, the token stays in that transcript, and the tool result never echoes it. Then create a subscription with the `destinationId` as for any other destination. + +### What Ask Gina sends + +- **Batching.** Ask Gina fires a destination at most once every 150 seconds. Each fire carries every event waiting at that moment, oldest first, so a burst of fills becomes one session. Events that do not fit wait for the next fire. +- **Text.** The fire body has one `text` field. It holds a short note, then a JSON array of [event envelopes](#what-you-get). The text stays under Anthropic's 65,536-character limit, and an envelope is never split. +- **Note.** The note says that events can repeat, that the reader should dedupe on `eventId` and that the message is not your approval for any trade. +- **Authentication.** Ask Gina sends the token as a bearer token. There are no Standard Webhooks headers, because the receiver is Anthropic and nothing on your side verifies a signature. + +Delivery is at least once. Anthropic has no idempotency key, so a retried request can start a second session with the same events. Each fire is a new session with no memory of earlier ones, so the routine can only dedupe inside one fire. If duplicates matter, keep the handled `eventId` values somewhere the routine can write. + +### Delivery outcomes + +| Anthropic answer | What Ask Gina does | +| --------------------------- | -------------------------------------------------------------------------------------------------------- | +| `200` | Counts the events as delivered and moves on. | +| `429` | Waits for the `Retry-After` time Anthropic sends, then tries again. A `429` does not count as a failure. | +| `500`, `503`, network error | Retries with the usual exponential backoff. A retry after a `500` can start a duplicate session. | +| `400`, `401`, `403`, `404` | Counts as a failed delivery. | + +A `400` can mean the routine is paused. A `401` means the token is wrong or you regenerated it. A `403` means the account or organization has no access to the endpoint, and a `404` means the routine no longer exists. A subscription that keeps failing is paused and emits a `paused` health event. Fix the routine or the token, then resume it with `updatePredictionEventSubscription` and `patch.enabled: true`. `listPredictionEventSubscriptions` shows why one is paused. Ask Gina keeps the status and a fixed reason for a failure, not the text of Anthropic's error. + +### Rotate the routine token + +Regenerating a token in Claude makes the old one stop at once. Ask Gina cannot keep signing with it for 24 hours as it does for a webhook secret. + +1. In claude.ai, open the routine's API trigger and click **Regenerate**. Copy the new token. +2. Right away, press **Rotate secret** on the destination's row or call `rotateWebhookDestinationSecret` with the `destinationId` and the new token as `secret`. + +Deliveries between the two steps fail with `401`. Do them back to back, and resume the subscription if it paused in between. To stop routine pushes for good, delete the API trigger's token in claude.ai and call `disableWebhookDestination`. + +### Limits and billing + +Anthropic lists 30 API fires an hour per routine, shared with **Run now**, and 100 API fires an hour per account across all of your routines. At one fire per 150 seconds, one destination stays under the routine limit, but a test event, **Run now** and other callers share that count, and two busy routines can reach the account limit. Past a limit Anthropic answers `429`. + +Each session draws on your Claude subscription like an interactive session. Ask Gina does not charge per delivery. Check [Anthropic's usage and limits](https://code.claude.com/docs/en/routines#usage-and-limits) for the current numbers and for what happens when your subscription limit runs out. + +### Safety + +An event that starts a session is a notification, not a request to trade. The note says so, and Anthropic wraps the text as untrusted data in the session. Treat the fired text that way yourself. A routine that holds the Predictions connector can place orders without you present, because Claude runs it in auto mode. For a routine that only needs to tell you what happened, remove the Predictions connector and report through another one. Orders you want placed still go through Gina in a session where you can confirm them. + ## ChatGPT MCP Events @@ -248,4 +299,4 @@ Run these in order. Steps 1 and 2 only read. Steps 3 and 5 create a destination 4. Ask **“Use Gina to send a test event to that destination.”** Expected: `sendWebhookTestEvent` returns an HTTP `status` and an `outcome`, and your receiver shows one signed test event. 5. Ask **“Create a prediction event subscription for this destination.”** Expected: a subscription with status `active` and a `cursor`. Then, if you choose to, place an order yourself. Confirm that your receiver gets an `eventId` for each transition and that a repeated `eventId` is the same event. -If you prefer the settings page, register the destination and press **Send test event** there instead of steps 3 and 4. If a tool is missing, remove the connection and add it again. If you see `PREDICTION_EVENTS_ACCOUNT_NOT_READY`, finish Predictions account setup in Ask Gina first. +For a Claude routine, the receiver in step 3 is the routine's fire URL and its token as `secret`, and step 4 starts a real session, so expect one new run in the routine's history instead of a signed request. If you prefer the settings page, register the destination and press **Send test event** there instead of steps 3 and 4. If a tool is missing, remove the connection and add it again. If you see `PREDICTION_EVENTS_ACCOUNT_NOT_READY`, finish Predictions account setup in Ask Gina first. diff --git a/docs/predictions-mcp/tools.mdx b/docs/predictions-mcp/tools.mdx index 15db40de..479bd5ca 100644 --- a/docs/predictions-mcp/tools.mdx +++ b/docs/predictions-mcp/tools.mdx @@ -100,28 +100,28 @@ Deletes a prediction event subscription so it stops delivering. It moves no fund ## Register a webhook destination -Registers a webhook destination for prediction events and can return a generated signing secret once. It changes only the destination Gina stores for your account and moves no funds. It is marked destructive so your client asks you first, and a secret it passes or returns appears in your client's transcript. +Registers a webhook destination, or a Claude routine's fire URL, for prediction events and can return a generated signing secret once. A routine needs its own token instead of a generated secret. It changes only the destination Gina stores for your account and moves no funds. It is marked destructive so your client asks you first, and a secret it passes or returns appears in your client's transcript. -| Tool | Use it for | -| -------------------------- | ----------------------------------------------------------------------------------------------------------------------- | -| `createWebhookDestination` | Register a webhook destination from a label, a URL and an optional `whsec_` secret; a generated secret is returned once | +| Tool | Use it for | +| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `createWebhookDestination` | Register a webhook destination from a label, a URL and an optional `whsec_` secret, or a Claude routine fire URL with its token; a generated secret is returned once | ## Change a webhook destination Replaces the signing secret of a webhook destination or disables it. It moves no funds and is marked destructive so your client asks you first. Disabling cannot be undone. -| Tool | Use it for | -| -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | -| `rotateWebhookDestinationSecret` | Replace the signing secret of an active destination; a generated secret is returned once and the previous one keeps signing for 24 hours | -| `disableWebhookDestination` | Disable a destination for good and pause the subscriptions that use it | +| Tool | Use it for | +| -------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `rotateWebhookDestinationSecret` | Replace the signing secret of an active destination; a generated secret is returned once and the previous one keeps signing for 24 hours, except a Claude routine, which needs its new token | +| `disableWebhookDestination` | Disable a destination for good and pause the subscriptions that use it | ## Test a webhook destination -Sends one signed test event to a webhook destination you registered and records the result. It starts a real automation on receivers such as Grok, so it is not a read. +Sends one test event to a webhook destination you registered and records the result. It starts a real automation on receivers such as Grok and a real Claude Code session for a routine, so it is not a read. -| Tool | Use it for | -| ---------------------- | ------------------------------------------------------------------------------------- | -| `sendWebhookTestEvent` | Send one signed test event to a destination and return the HTTP status and an outcome | +| Tool | Use it for | +| ---------------------- | ---------------------------------------------------------------------------------------------------------------------- | +| `sendWebhookTestEvent` | Send one test event to a destination and return the HTTP status and an outcome; a Claude routine starts a real session | ## Delete a schedule diff --git a/tools/docs/venue-tools.json b/tools/docs/venue-tools.json index 4bec5eab..27ca9519 100644 --- a/tools/docs/venue-tools.json +++ b/tools/docs/venue-tools.json @@ -68,7 +68,7 @@ "destructiveHint": true, "openWorldHint": true }, - "meaning": "Registers a webhook destination for prediction events and can return a generated signing secret once. It changes only the destination Gina stores for your account and moves no funds. It is marked destructive so your client asks you first, and a secret it passes or returns appears in your client's transcript." + "meaning": "Registers a webhook destination, or a Claude routine's fire URL, for prediction events and can return a generated signing secret once. A routine needs its own token instead of a generated secret. It changes only the destination Gina stores for your account and moves no funds. It is marked destructive so your client asks you first, and a secret it passes or returns appears in your client's transcript." }, "change-destination": { "title": "Change a webhook destination", @@ -86,7 +86,7 @@ "destructiveHint": false, "openWorldHint": true }, - "meaning": "Sends one signed test event to a webhook destination you registered and records the result. It starts a real automation on receivers such as Grok, so it is not a read." + "meaning": "Sends one test event to a webhook destination you registered and records the result. It starts a real automation on receivers such as Grok and a real Claude Code session for a routine, so it is not a read." }, "delete-schedule": { "title": "Delete a schedule", @@ -344,12 +344,12 @@ { "name": "createWebhookDestination", "class": "register-destination", - "purpose": "Register a webhook destination from a label, a URL and an optional `whsec_` secret; a generated secret is returned once" + "purpose": "Register a webhook destination from a label, a URL and an optional `whsec_` secret, or a Claude routine fire URL with its token; a generated secret is returned once" }, { "name": "rotateWebhookDestinationSecret", "class": "change-destination", - "purpose": "Replace the signing secret of an active destination; a generated secret is returned once and the previous one keeps signing for 24 hours" + "purpose": "Replace the signing secret of an active destination; a generated secret is returned once and the previous one keeps signing for 24 hours, except a Claude routine, which needs its new token" }, { "name": "disableWebhookDestination", @@ -359,7 +359,7 @@ { "name": "sendWebhookTestEvent", "class": "test-destination", - "purpose": "Send one signed test event to a destination and return the HTTP status and an outcome" + "purpose": "Send one test event to a destination and return the HTTP status and an outcome; a Claude routine starts a real session" }, { "name": "searchPredictionMarkets", From f7c8b7aff2c13a1778a3e582ee7cd31ab20da2b2 Mon Sep 17 00:00:00 2001 From: Eric Juta Date: Fri, 23 Oct 2026 18:20:34 +0000 Subject: [PATCH 2/3] docs(claude): drop bot-blocked claude.ai links from routine steps --- docs/connect/claude.mdx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/connect/claude.mdx b/docs/connect/claude.mdx index 3a30254f..8e65c23b 100644 --- a/docs/connect/claude.mdx +++ b/docs/connect/claude.mdx @@ -95,7 +95,7 @@ A Claude Code routine is a saved prompt that runs as a cloud session. Its API tr You need a Claude plan with Claude Code on the web (Pro, Max, Team or Enterprise), the [Predictions connector](#add-the-predictions-connector) in the Claude session where you create the subscription, and a finished Predictions account in Ask Gina. -1. **Create the routine.** Open [claude.ai/code/routines](https://claude.ai/code/routines), choose **New task** and write the prompt. Claude hands the fired text to the routine as untrusted data, so the prompt has to tell Claude to read it. For example: +1. **Create the routine.** Open `claude.ai/code/routines`, choose **New task** and write the prompt. Claude hands the fired text to the routine as untrusted data, so the prompt has to tell Claude to read it. For example: ```text Ask Gina sent prediction events in the routine-fire-payload block, as a JSON array. List each distinct eventId once with the event name and the order or trade it describes. Do not place, change or cancel any order. If the block holds no events, say so and stop. @@ -138,7 +138,7 @@ A routine can instead run on a schedule and read the event log with a pull subsc Every run starts with no memory, so the cursor has to live somewhere the routine can read and write, such as a file in a repository the routine clones or a note in another connector. Without a stored cursor, each run would read from the subscription's start. Reading the subscription counts as activity, so an hourly routine also keeps it from pausing after 7 days unread. -Anthropic says routines can call the connectors on your Claude account, and that servers added at [claude.ai/customize/connectors](https://claude.ai/customize/connectors) count. A server you added only with `claude mcp add` is stored on your machine and does not. Ask Gina has not run a routine against the Predictions connector, so open the first run and check that the `getPredictionEvents` call succeeded before you rely on it. +Anthropic says routines can call the connectors on your Claude account, and that servers added at `claude.ai/customize/connectors` count. A server you added only with `claude mcp add` is stored on your machine and does not. Ask Gina has not run a routine against the Predictions connector, so open the first run and check that the `getPredictionEvents` call succeeded before you rely on it. ## Verify your first result From 56382687f23801ba92636ab2cde9c28e41918dc3 Mon Sep 17 00:00:00 2001 From: Eric Juta Date: Fri, 23 Oct 2026 21:53:01 +0000 Subject: [PATCH 3/3] docs(predictions): align Claude routine delivery with shipped D46 --- docs/connect/claude.mdx | 6 +-- docs/predictions-mcp/events.mdx | 73 +++++++++++++++++---------------- docs/predictions-mcp/tools.mdx | 6 +-- tools/docs/venue-tools.json | 2 +- 4 files changed, 44 insertions(+), 43 deletions(-) diff --git a/docs/connect/claude.mdx b/docs/connect/claude.mdx index 8e65c23b..deeaa2a3 100644 --- a/docs/connect/claude.mdx +++ b/docs/connect/claude.mdx @@ -103,9 +103,9 @@ You need a Claude plan with Claude Code on the web (Pro, Max, Team or Enterprise 2. **Choose its connectors.** A new routine includes every connector on your Claude account. Remove the ones it does not need. Keep the Predictions connector out unless the routine must read your account, because that connector also carries the trading tools. See [Safety](#safety-for-routine-push). 3. **Add an API trigger.** Edit the routine, click **+** in the **Trigger** row and choose **API**. Copy the **Fire URL**. Click **Generate token** and copy the token straight away. Claude shows it once and cannot show it again. -4. **Register it with Ask Gina.** On the [settings page](https://askgina.ai/profile/webhooks), choose **Add destination**, enter a label, paste the Fire URL as the **Webhook URL** and paste the token as the **Signing secret**. The Fire URL looks like `https://api.anthropic.com/v1/claude_code/routines/trig_.../fire` and the token starts with `sk-ant-oat01-`. The settings page is the better path because the token goes from you to Ask Gina without passing through a chat. A Claude agent can instead call `createWebhookDestination` with the same URL as `url` and the token as `secret`. Then the token sits in that conversation's transcript, and anyone who can read it can start your routine until you regenerate the token. Ask Gina cannot generate this token for you, so a create call with no `secret` is refused. +4. **Register it with Ask Gina.** On the [settings page](https://askgina.ai/profile/webhooks), choose **Add destination** and enter a label. **Receiver type** offers **Detect from the address** by default, **Webhook**, or **Claude routine**. Leave detection on or choose **Claude routine**, paste the Fire URL into **Webhook or routine URL**, and paste the token into **Routine API trigger token**. The Fire URL looks like `https://api.anthropic.com/v1/claude_code/routines/trig_.../fire` and the token starts with `sk-ant-oat01-`. After saving, look for the **Claude routine** badge on the destination row to identify it for testing or token replacement. The settings page is the better path because the token goes from you to Ask Gina without passing through a chat. A Claude agent can instead call `createWebhookDestination` with the same URL as `url` and the token as `secret`. Its optional `kind` is `webhook` or `claude_routine`. If omitted, the URL decides: the exact routine fire URL pattern selects `claude_routine`, and any other `api.anthropic.com` URL is refused. A `kind` that contradicts the URL fails with `INVALID_ARGUMENTS` on `kind`. Passing the token through a Claude agent puts it in that conversation's transcript, and anyone who can read it can start your routine until you regenerate the token. Ask Gina cannot generate this token for you, so a create call with no `secret` is refused. 5. **Subscribe.** Ask Claude to call `createPredictionEventSubscription` with the `destinationId` from step 4. Add a filter if the routine should only hear about some markets or orders. -6. **Send a test.** Press **Send test event** on the settings page or ask Claude to call `sendWebhookTestEvent`. It starts a real session, so expect a new run in the routine's history. A test uses one of the routine's fires for the hour. +6. **Send a test.** Press **Send test event** on the settings page or ask Claude to call `sendWebhookTestEvent`. This sends a short test message, not a signed event. It starts a real session, uses the routine's fire quota, and takes the destination's shared 150-second fire slot. Expect a new run in the routine's history. If the routine was fired less than 150 seconds ago, nothing is sent: `sendWebhookTestEvent` refuses with `WEBHOOK_ROUTINE_NOT_READY` and `details.retryAfterSeconds`. The settings page tells you to wait N seconds before trying again. ### What the routine receives @@ -113,7 +113,7 @@ Ask Gina fires a routine at most once every 150 seconds per destination. Each fi Each fire is a new session with no memory of earlier ones. The routine can drop repeats inside one fire, but it cannot know that an earlier fire carried the same `eventId`. A repeated notification is usually harmless. If it is not for your use, keep the ids you have handled somewhere the routine can write. -The [Prediction events](/predictions-mcp/events#claude-code-routines) page lists what happens on each Anthropic error, how to rotate the token and the limits. In short, a regenerated token stops working at once, so rotate it in Ask Gina right after you regenerate it. A routine you paused or deleted pauses delivery. +The [Prediction events](/predictions-mcp/events#claude-code-routines) page lists what happens on each Anthropic error, how to rotate the token and the limits. Regenerating the token stops the old token from working at once. In Ask Gina settings, choose **Replace token** on the routine's row, paste the new token, and choose **Save token**. A rejected token or a routine you paused or deleted pauses the subscription immediately when Anthropic returns 400, 401, 403 or 404. A 413 response or an event too large to fit alone also pauses it immediately. After fixing the cause, resume with `updatePredictionEventSubscription` and `patch.enabled: true`. ### Safety for routine push diff --git a/docs/predictions-mcp/events.mdx b/docs/predictions-mcp/events.mdx index 626de963..7313af8f 100644 --- a/docs/predictions-mcp/events.mdx +++ b/docs/predictions-mcp/events.mdx @@ -20,7 +20,7 @@ You also need a finished Predictions account with delegated signing in Ask Gina. ## What you get -Subscriptions deliver three event names. Each name carries a version. +Subscriptions deliver the following event names. Each name carries a version. | Event name | What it reports | | ----------------------------------- | ----------------------------------------------------------------------------------------- | @@ -50,22 +50,22 @@ Every event arrives in the same envelope: `data` follows the versioned schema for the event name. Order and trade events echo the `clientRef` you passed when you placed the order, so an agent can match an event to its own intent. Pass `clientRef` and `idempotencyKey` on `tradePredictionMarket` and `managePredictionOrders`; see each tool's input schema. -## The ten event tools +## The event tools These tools are native tools on the Predictions connector. The [native tools reference](/predictions-mcp/tools) lists their annotation classes. Read each tool's input schema from `tools/list` for argument limits and rely on it instead of this page. -| Tool | Use it for | -| ----------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `listWebhookDestinations` | Read the destinations you registered: id, label, host, status and last test. It never returns a URL or a secret. | -| `createWebhookDestination` | Register a destination. Returns a generated secret once when you pass none. A Claude routine's fire URL needs the routine's token as `secret`. | -| `rotateWebhookDestinationSecret` | Replace the secret of an active destination. A Claude routine destination needs its new token. | -| `disableWebhookDestination` | End a destination for good. This cannot be undone. | -| `sendWebhookTestEvent` | Send one test event and return the HTTP `status` and an `outcome`. A signed event for a webhook, a real session for a Claude routine. | -| `createPredictionEventSubscription` | Subscribe to order and trade events, optionally filtered, with a `destinationId` for webhook delivery or without one to pull. | -| `listPredictionEventSubscriptions` | Read subscriptions, their filter, status and why one is paused. | -| `updatePredictionEventSubscription` | Change the name, filter, destination or pause state with one partial patch. `patch.enabled: true` resumes a paused subscription. It cannot change a subscription an MCP Events client created; delete that one instead. | -| `deletePredictionEventSubscription` | Stop a subscription. A subscription made with these tools sends one final `terminated` health event to its webhook destination. This cannot be undone. | -| `getPredictionEvents` | Read events oldest first with a cursor. Always pass `subscriptionId` to read that subscription's view. | +| Tool | Use it for | +| ----------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `listWebhookDestinations` | Read the destinations you registered: id, label, host, status and last test. It never returns a URL or a secret. | +| `createWebhookDestination` | Register a destination. Returns a generated secret once when you pass none. A Claude routine's fire URL needs the routine's token as `secret`. | +| `rotateWebhookDestinationSecret` | Replace the secret of an active destination. A Claude routine destination needs its new token. | +| `disableWebhookDestination` | End a destination for good. This cannot be undone. | +| `sendWebhookTestEvent` | Send one test event and return the HTTP `status` and an `outcome`. A signed event for a webhook, a short unsigned message that starts a real session for a Claude routine. A routine still waiting for its fire slot returns `WEBHOOK_ROUTINE_NOT_READY`. | +| `createPredictionEventSubscription` | Subscribe to order and trade events, optionally filtered, with a `destinationId` for webhook delivery or without one to pull. | +| `listPredictionEventSubscriptions` | Read subscriptions, their filter, status and why one is paused. | +| `updatePredictionEventSubscription` | Change the name, filter, destination or pause state with one partial patch. `patch.enabled: true` resumes a paused subscription. It cannot change a subscription an MCP Events client created; delete that one instead. | +| `deletePredictionEventSubscription` | Stop a subscription. A subscription made with these tools sends one final `terminated` health event to its webhook destination. This cannot be undone. | +| `getPredictionEvents` | Read events oldest first with a cursor. Always pass `subscriptionId` to read that subscription's view. | A filter can narrow by `conditionIds`, `assetIds`, `orderIds`, `clientRefs`, `orderEventTypes` and `tradeStatuses`. Fields combine with AND and the values inside one field combine with OR. Empty arrays are rejected, and an omitted filter means everything. Strategy filters such as side or price do not exist. @@ -90,7 +90,7 @@ Each call to an event tool is metered like a read tool. Deliveries to your webho ## Register a webhook destination -A destination is the HTTPS endpoint that receives your events, plus the secret Ask Gina signs them with. For a Claude routine, the endpoint is the routine's fire URL and the secret is its token, which Ask Gina sends as a bearer token in place of a signature. You can register one in two ways. Both make the same kind of destination, and both share one pool: the same cap, the same rate limits, and each destination shows up in `listWebhookDestinations` and on the settings page. +A destination is the HTTPS endpoint that receives your events, plus the secret Ask Gina signs them with. For a Claude routine, the endpoint is the routine's fire URL and the secret is its token, which Ask Gina sends as a bearer token in place of a signature. You can register one through MCP tools or the settings page. Both paths share the same caps and rate limits, and each destination shows up in `listWebhookDestinations` and on the settings page. Create the receiver first. For Grok, that is a webhook trigger on an automation. Copy its endpoint and signing secret. Grok shows the secret only when the trigger is created or rotated. @@ -98,7 +98,7 @@ Create the receiver first. For Grok, that is a webhook trigger on an automation. Your agent can set up a destination without a browser. -1. Call `createWebhookDestination` with a `label`, the receiver's `url` and, if the receiver gave you one, its `secret` (it starts with `whsec_`). +1. Call `createWebhookDestination` with a `label`, the receiver's `url` and, if the webhook receiver gave you one, its `secret`, which starts with `whsec_`. The optional `kind` is `webhook` or `claude_routine`; omit it to infer the kind from the URL. A kind that contradicts the URL fails with `INVALID_ARGUMENTS` on `kind`. A routine requires its API trigger token as `secret`; see [Register a routine](#register-a-routine). 2. Read the result. It holds the `destination` (id, label, host, status and last test), `secretGenerated` and a `next` list. When you passed no `secret`, Ask Gina generates a `whsec_` secret and returns it once in `secret`. Store it in your receiver straight away, because no tool or page shows it again. If you lose it, rotate the secret. 3. Call `sendWebhookTestEvent` with the `destinationId`. It returns the HTTP `status` your endpoint answered and an `outcome`. 4. Call `createPredictionEventSubscription` with the same `destinationId`. @@ -115,15 +115,15 @@ A receiver that makes its own secret, such as a Grok trigger, needs that secret, If your host retries `createWebhookDestination` and a second destination appears, call `listWebhookDestinations` and call `disableWebhookDestination` on the extra one. Disabling cannot be undone, so check the ids first. -To replace a secret later, call `rotateWebhookDestinationSecret` with the `destinationId` and an optional new `secret`. It works on active destinations only and, like creation, returns a generated secret once. To end a destination, call `disableWebhookDestination` with the `destinationId`. +To replace a webhook secret later, call `rotateWebhookDestinationSecret` with the `destinationId` and an optional new `secret`. It works on active destinations only and, like webhook creation, returns a generated secret once when you omit `secret`. For a routine, always pass the new API trigger token as `secret`; Ask Gina cannot generate one. To end a destination, call `disableWebhookDestination` with the `destinationId`. The secret passes through your client's transcript on this path either way: you pass it in as `secret`, or Ask Gina returns it once in the result. Treat that transcript as holding a credential for this destination. Create, rotate and disable are marked destructive, so hosts ask you to confirm each call before it runs. `sendWebhookTestEvent` is not destructive, but it reaches your receiver. ### On the settings page 1. Open [askgina.ai/profile/webhooks](https://askgina.ai/profile/webhooks) and choose **Add destination**. -2. Enter a **Label**, the **Webhook URL** and the **Signing secret** (it starts with `whsec_`). -3. Press **Send test event**. Ask Gina signs a `prediction.subscription.health.v1` event with `kind: "test"` and shows the HTTP status your endpoint returned. +2. Enter a **Label** and the **Webhook or routine URL**. Under **Receiver type**, choose **Detect from the address**, the default, **Webhook** or **Claude routine**. For a webhook, enter the **Signing secret**, which starts with `whsec_`. For a routine, the secret field is **Routine API trigger token**. Routine rows show a **Claude routine** badge. +3. Press **Send test event**. For a webhook, Ask Gina signs a `prediction.subscription.health.v1` event with `kind: "test"` and shows the HTTP status your endpoint returned. For a routine, it sends a short unsigned test message that starts a real session. If the destination's fire slot is not ready, the page tells you to wait N seconds and sends nothing. On the page, the secret goes from you to Ask Gina without passing through an agent. @@ -133,10 +133,10 @@ These rules apply the same way on both paths. - The URL must be `https`, use the default port, carry no credentials and name a public DNS host. IP addresses, `localhost` and internal names are refused, and so is a host that resolves to a private, loopback, link-local or metadata address. Redirects are never followed, and a `3xx` answer counts as a failed delivery. - The secret is stored encrypted and is never shown again. Tools and the page show the host, not the full URL, because a trigger URL can itself be a bearer credential. -- Limits: 5 active destinations per account, shared by the settings page and the tools. Past it, `createWebhookDestination` fails with `WEBHOOK_DESTINATION_LIMIT_REACHED` and `details.limit`. Adding destinations and sending test events are each limited to 10 per hour, shared the same way. A refused call names the `action` and the `limit`. -- To replace a secret, use **Rotate secret** on the row or `rotateWebhookDestinationSecret`. The previous secret keeps signing alongside the new one for 24 hours, so you can update the receiver without losing deliveries. A Claude routine destination has no such overlap. See [Rotate the routine token](#rotate-the-routine-token). +- The settings page and tools share the same active-destination cap and rate limits for adding destinations and sending test events. At the destination cap, `createWebhookDestination` fails with `WEBHOOK_DESTINATION_LIMIT_REACHED`; `details.limit` states the current cap. A rate-limited call names the `action` and the `limit`. +- To replace a webhook secret, use **Rotate secret** on the row or `rotateWebhookDestinationSecret`. The previous secret keeps signing alongside the new one for 24 hours, so you can update the receiver without losing deliveries. A Claude routine row uses **Replace token** and has no such overlap. See [Rotate the routine token](#rotate-the-routine-token). - Disabling ends the destination and cannot be reversed. Register a new destination instead. It pauses the subscriptions that use it, and it works from the page (**Disable**) or from `disableWebhookDestination`. -- A test event signs `prediction.subscription.health.v1` with `kind: "test"`. Ask Gina sends it once, retries nothing and does not store it in the event log. It starts a real automation on receivers such as Grok, so expect it to run. A Claude routine gets a short test message instead of a signed event, and that also starts a real session. +- A webhook test signs `prediction.subscription.health.v1` with `kind: "test"`. Ask Gina sends it once, retries nothing and does not store it in the event log. It starts a real automation on receivers such as Grok, so expect it to run. A Claude routine gets a short unsigned test message instead. It starts a real session, uses the routine's fire quota and takes the destination's 150-second fire slot. If the routine was fired less than 150 seconds ago, nothing is sent. `sendWebhookTestEvent` returns `WEBHOOK_ROUTINE_NOT_READY` with `details.retryAfterSeconds`, and the settings page tells you to wait N seconds. Then ask your agent to list the destinations and create a subscription with the `destinationId`. The agent sees labels and ids only. @@ -219,9 +219,9 @@ Anthropic marks routines as a research preview and the fire endpoint as experime ### Register a routine -Ask Gina treats a destination as a Claude routine when its `url` is exactly `https://api.anthropic.com/v1/claude_code/routines/trig_.../fire`, with the routine's own id in place of the dots. Any other `api.anthropic.com` address is refused. +`createWebhookDestination` accepts an optional `kind`, either `webhook` or `claude_routine`. When you omit it, Ask Gina infers the kind from the URL. A Claude routine's `url` must be exactly `https://api.anthropic.com/v1/claude_code/routines/trig_.../fire`, with the routine's own id in place of the dots. Any other `api.anthropic.com` address is refused. A `kind` that contradicts the URL fails with `INVALID_ARGUMENTS` on `kind`. -For a routine, the `secret` is required and must be the routine's API trigger token, which starts with `sk-ant-oat01-`. Ask Gina cannot generate one, so `createWebhookDestination` without a `secret` fails with `INVALID_ARGUMENTS`. Register it on [askgina.ai/profile/webhooks](https://askgina.ai/profile/webhooks) when you can. The token then never enters a chat. If an agent registers it with the tool, the token stays in that transcript, and the tool result never echoes it. Then create a subscription with the `destinationId` as for any other destination. +For a routine, the `secret` is required and must be the routine's API trigger token, which starts with `sk-ant-oat01-`. Ask Gina cannot generate one, so `createWebhookDestination` without a `secret` fails with `INVALID_ARGUMENTS`. Register it on [askgina.ai/profile/webhooks](https://askgina.ai/profile/webhooks) when you can. Leave **Receiver type** as **Detect from the address** or choose **Claude routine**. The token then never enters a chat. If an agent registers it with the tool, the token stays in that transcript, and the tool result never echoes it. Then create a subscription with the `destinationId` as for any other destination. ### What Ask Gina sends @@ -234,27 +234,28 @@ Delivery is at least once. Anthropic has no idempotency key, so a retried reques ### Delivery outcomes -| Anthropic answer | What Ask Gina does | -| --------------------------- | -------------------------------------------------------------------------------------------------------- | -| `200` | Counts the events as delivered and moves on. | -| `429` | Waits for the `Retry-After` time Anthropic sends, then tries again. A `429` does not count as a failure. | -| `500`, `503`, network error | Retries with the usual exponential backoff. A retry after a `500` can start a duplicate session. | -| `400`, `401`, `403`, `404` | Counts as a failed delivery. | +| Anthropic answer | What Ask Gina does | +| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `200` | Counts the events as delivered and moves on. | +| `429` | Does not count as a failure. Honors `Retry-After`, never retrying sooner than 150 seconds. The wait is persisted on the destination and holds back every subscription using it. | +| `400`, `401`, `403`, `404` | Pauses the subscription immediately with one `paused` health event whose reason is `routine_rejected`. | +| `413` | Pauses the subscription immediately with reason `routine_too_large`. Retrying the same text cannot succeed. | +| Any other status or network failure | Counts as a failed delivery and retries with the usual exponential backoff, including `500` and `503`. A retry after a `500` can start a duplicate session. | -A `400` can mean the routine is paused. A `401` means the token is wrong or you regenerated it. A `403` means the account or organization has no access to the endpoint, and a `404` means the routine no longer exists. A subscription that keeps failing is paused and emits a `paused` health event. Fix the routine or the token, then resume it with `updatePredictionEventSubscription` and `patch.enabled: true`. `listPredictionEventSubscriptions` shows why one is paused. Ask Gina keeps the status and a fixed reason for a failure, not the text of Anthropic's error. +A `400` can mean the routine is paused. A `401` means the token is wrong or you regenerated it. A `403` means the account or organization has no access to the endpoint, and a `404` means the routine no longer exists. These answers pause the subscription at once, rather than waiting for repeated failures. A single event envelope too large to fit by itself also pauses the subscription with reason `routine_too_large`; Ask Gina never splits it. Other failures use normal backoff and pause the subscription if it keeps failing. Fix the cause, then resume with `updatePredictionEventSubscription` and `patch.enabled: true`. `listPredictionEventSubscriptions` shows why one is paused. Ask Gina keeps the status and a fixed reason for a failure, not the text of Anthropic's error. ### Rotate the routine token Regenerating a token in Claude makes the old one stop at once. Ask Gina cannot keep signing with it for 24 hours as it does for a webhook secret. 1. In claude.ai, open the routine's API trigger and click **Regenerate**. Copy the new token. -2. Right away, press **Rotate secret** on the destination's row or call `rotateWebhookDestinationSecret` with the `destinationId` and the new token as `secret`. +2. Right away, press **Replace token** on the routine destination's row, enter the new **Routine API trigger token** and press **Save token**. Or call `rotateWebhookDestinationSecret` with the `destinationId` and the new token as `secret`. **Rotate secret** is for webhook rows, not routines. -Deliveries between the two steps fail with `401`. Do them back to back, and resume the subscription if it paused in between. To stop routine pushes for good, delete the API trigger's token in claude.ai and call `disableWebhookDestination`. +Deliveries between the two steps get `401` and immediately pause the subscription with reason `routine_rejected`. Do them back to back. If a delivery paused the subscription, resume it after saving the token with `updatePredictionEventSubscription` and `patch.enabled: true`. To stop routine pushes for good, delete the API trigger's token in claude.ai and call `disableWebhookDestination`. ### Limits and billing -Anthropic lists 30 API fires an hour per routine, shared with **Run now**, and 100 API fires an hour per account across all of your routines. At one fire per 150 seconds, one destination stays under the routine limit, but a test event, **Run now** and other callers share that count, and two busy routines can reach the account limit. Past a limit Anthropic answers `429`. +Anthropic applies [per-routine and per-account fire limits](https://platform.claude.com/docs/en/api/claude-code/routines-fire). **Run now**, test events and other callers share the quotas, so Ask Gina's 150-second destination interval does not guarantee quota remains available. Past a limit Anthropic answers `429`, and Ask Gina waits without counting a delivery failure. Each session draws on your Claude subscription like an interactive session. Ask Gina does not charge per delivery. Check [Anthropic's usage and limits](https://code.claude.com/docs/en/routines#usage-and-limits) for the current numbers and for what happens when your subscription limit runs out. @@ -274,7 +275,7 @@ ChatGPT subscribes through the MCP Events protocol on the same Predictions endpo | Method | Behavior | | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| `events/list` | Describes the three event names, their filter arguments, payload schemas and delivery modes. | +| `events/list` | Describes the event names, their filter arguments, payload schemas and delivery modes. | | `events/subscribe` | Creates or refreshes a webhook subscription from a callback URL and a ChatGPT-supplied secret. Only `delivery.mode` `webhook` is accepted. It returns `id`, `refreshBefore`, `cursor` and `truncated`. | | `events/unsubscribe` | Ends the subscription that matches the event name, arguments and callback URL. When nothing matches it still succeeds. | | `events/poll` | Reads events for one event name with a cursor, like `getPredictionEvents`. Without a cursor it starts from now. It returns `events`, `cursor`, `hasMore`, `truncated` and `nextPollMs`. | @@ -299,4 +300,4 @@ Run these in order. Steps 1 and 2 only read. Steps 3 and 5 create a destination 4. Ask **“Use Gina to send a test event to that destination.”** Expected: `sendWebhookTestEvent` returns an HTTP `status` and an `outcome`, and your receiver shows one signed test event. 5. Ask **“Create a prediction event subscription for this destination.”** Expected: a subscription with status `active` and a `cursor`. Then, if you choose to, place an order yourself. Confirm that your receiver gets an `eventId` for each transition and that a repeated `eventId` is the same event. -For a Claude routine, the receiver in step 3 is the routine's fire URL and its token as `secret`, and step 4 starts a real session, so expect one new run in the routine's history instead of a signed request. If you prefer the settings page, register the destination and press **Send test event** there instead of steps 3 and 4. If a tool is missing, remove the connection and add it again. If you see `PREDICTION_EVENTS_ACCOUNT_NOT_READY`, finish Predictions account setup in Ask Gina first. +For a Claude routine, the receiver in step 3 is the routine's fire URL and its token as `secret`. You can pass `kind: "claude_routine"` or omit `kind` to infer it from the URL. Step 4 sends a short unsigned test message, starts a real session, uses the routine's fire quota and takes the destination's 150-second fire slot. Expect one new run in the routine's history instead of a signed request. If the slot is not ready, nothing is sent: `sendWebhookTestEvent` returns `WEBHOOK_ROUTINE_NOT_READY` with `details.retryAfterSeconds`. Wait that long before trying again. If you prefer the settings page, register the destination and press **Send test event** there instead of steps 3 and 4; a refusal tells you to wait N seconds. If a tool is missing, remove the connection and add it again. If you see `PREDICTION_EVENTS_ACCOUNT_NOT_READY`, finish Predictions account setup in Ask Gina first. diff --git a/docs/predictions-mcp/tools.mdx b/docs/predictions-mcp/tools.mdx index 479bd5ca..63bf8fa1 100644 --- a/docs/predictions-mcp/tools.mdx +++ b/docs/predictions-mcp/tools.mdx @@ -102,9 +102,9 @@ Deletes a prediction event subscription so it stops delivering. It moves no fund Registers a webhook destination, or a Claude routine's fire URL, for prediction events and can return a generated signing secret once. A routine needs its own token instead of a generated secret. It changes only the destination Gina stores for your account and moves no funds. It is marked destructive so your client asks you first, and a secret it passes or returns appears in your client's transcript. -| Tool | Use it for | -| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| `createWebhookDestination` | Register a webhook destination from a label, a URL and an optional `whsec_` secret, or a Claude routine fire URL with its token; a generated secret is returned once | +| Tool | Use it for | +| -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `createWebhookDestination` | Register a label and URL, optional `whsec_` secret and optional `kind: webhook \| claude_routine`; routines need a fire URL and token. Generated secret returned once | ## Change a webhook destination diff --git a/tools/docs/venue-tools.json b/tools/docs/venue-tools.json index 27ca9519..8383101d 100644 --- a/tools/docs/venue-tools.json +++ b/tools/docs/venue-tools.json @@ -344,7 +344,7 @@ { "name": "createWebhookDestination", "class": "register-destination", - "purpose": "Register a webhook destination from a label, a URL and an optional `whsec_` secret, or a Claude routine fire URL with its token; a generated secret is returned once" + "purpose": "Register a label and URL, optional `whsec_` secret and optional `kind: webhook | claude_routine`; routines need a fire URL and token. Generated secret returned once" }, { "name": "rotateWebhookDestinationSecret",