{"version":"2.1.309","anchor":"headless-onturnbeganbeforeinit-callback","canonical_anchor":"headless-onturnbeganbeforeinit-callback","heading":"Headless sessions can report a turn that starts before setup finishes","tier":"use","area":"SDK","scope":"individual","heads_up":false,"url":"https:\/\/changelogs.core-directive.com\/v\/2.1.309\/e\/headless-onturnbeganbeforeinit-callback","release_url":"https:\/\/changelogs.core-directive.com\/v\/2.1.309","markdown":"### Headless sessions can report a turn that starts before setup finishes\n\nIn headless mode, a turn that starts before the startup message was sent now triggers an optional onTurnBeganBeforeInit callback\n\n**What**\n\nIn headless mode, Claude Code runs without its interactive screen and is driven by another program. A turn is one exchange where Claude handles a message. Sometimes a turn begins before the startup message has been sent. When that happens, the session now calls an optional `onTurnBeganBeforeInit` callback, which is a function the controlling program can supply. If that function fails, the error is logged and the turn carries on.\n\n**Why**\n\nPrograms that run Claude Code can measure when turns begin before startup has finished. A fault in their own callback will not stop the turn.\n\n- Area: SDK\n- Names: `onTurnBeganBeforeInit`\n- Tier: Use it now\n- Useful: 4\/5\n- Signal: 2\/5\n- Scope: individual\n- Heads-up: no"}