Where does the bug appear (feature/product)?
Cursor SDK
Describe the Bug
Originally observed on 1.0.23 and reproduced on 1.0.28. The sessionStart hook executes and returns additional_context, but the marker is not available to the model on the first turn.
A project-level sessionStart hook returns additional_context that should be added to the model’s initial context.
This works in the Cursor IDE. When the same project is executed using Agent.create with the local runtime, the hook runs successfully, but its additional_context never reaches the model.
Hook logs, sidecar output, and the presence of session_id in the hook environment confirm that execution succeeds. The failure is specifically in propagating the returned context into the model request.
Steps to Reproduce
- Configure a project-level
sessionStarthook that returnsadditional_contextcontaining a unique marker. - Open the project in the Cursor IDE and start a new session.
- Ask the model on the first turn, without using tools, to repeat the marker. The model can identify it.
- Run the same project using
Agent.createwith the local runtime. - Confirm through the hook logs that
sessionStartexecuted and returned the context. - Ask the model the same question on the first turn, without using tools.
The model behaves as though the returned context was never added to the session.
Expected Behavior
The additional_context returned by sessionStart should be included in the model’s initial context before the first user message is processed, matching the behavior of the Cursor IDE.
Operating System
MacOS
Version Information
@cursor/sdk: 1.0.28
Runtime: local
API: Agent.create
Additional Information
The hooks adapter already maps the hook result to { additionalContext }, and the request-context implementation awaits hooksAdditionalContextPromise before assigning the result to RequestContext.hooksAdditionalContext.
However, wrapResources constructs the request-context wrapper with hooksAdditionalContextPromise set to undefined. This appears to leave the result of onSessionStart disconnected from the request context consumed by the model.
Proposed fix:
- Create a deferred promise in the resource-wrapper factory.
- Pass that promise to the request-context accessor.
- Resolve it with
additional_contextwhenonSessionStartcompletes. - Resolve it with
undefinedif the hook is skipped or throws, preventing the request from remaining blocked.
The context should be propagated through RequestContext.hooksAdditionalContext, not prepended to the user prompt.
A temporary workaround for @cursor/[email protected] is available at GitHub - jgabriellima/cursor-sdk-session-start-patch: @cursor/[email protected] workaround: sessionStart runs, additional_context never reaches the model · GitHub
Does this stop you from using Cursor
Sometimes - I can sometimes use Cursor