SDK, paste-to-AI, or manual
The SDK is the preferred path. ACP also generates a deterministic long-form client plus an instruction prompt you can paste into a coding agent, or you can wire the pieces yourself.
Wrap the call you already have
wrapAgentRun refuses to run while the agent is paused or stopped, times the call, extracts token counts from OpenAI- or Anthropic-shaped responses, and reports the run. Errors are reported and rethrown.
Runs buffer and flush every 5 seconds, or immediately at 50 buffered. The buffer is capped at 200; excess drops oldest first.
A failed flush retries four times with jittered backoff, then drops the batch and logs the count. Reporting never throws into your code.
The client flushes on beforeExit and on acp.stop(), so the last runs of a process still arrive.
Paste to your coding agent
The onboarding prompt tells the agent exactly which files to create, which env vars to read, and which calls to wrap. It does not ask the agent to invent an API.
Manual: prompt fetch and run guard
Two pieces matter. The prompt fetch resolves the current version with a cache fallback. The run wrapper checks paused and stopped state before the model is called.
Fallback order for prompts: live fetch, then the local cache, then the prompt already hardcoded in your app. A failed fetch never blocks a run.