Grouping requests into conversations using an API gateway

Cursor does not currently send conversation or agent identity headers (or equivalent metadata) on requests to a custom OpenAI-compatible base URL. Outbound calls to that override path effectively only carry the provider auth you’d expect, so a gateway sees anonymous completions and has to reassemble sessions after the fact - exactly the pain you’re describing.

Hooks can expose conversation_id (and related lifecycle events) for out-of-band correlation, which matches what you already tried. That path is still incomplete for nested / background Task runs; the gaps you hit line up with what’s discussed in subagentStop never fires for background subagents…. Docs for the hook surface: Hooks. For how BYOK / custom keys are routed today: Bring your own API key.