-
Notifications
You must be signed in to change notification settings - Fork 83
Python prompt context parameter #725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Python prompt context parameter #725
Conversation
This change allows prompt handlers to access the current context, enabling more dynamic prompt generation and improved logging. It also introduces backward compatibility for existing handlers. Co-authored-by: evan <[email protected]>
|
Cursor Agent can help with this pull request. Just |
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Co-authored-by: evan <[email protected]>
|
Cursor Agent can help with this pull request. Just |
Co-authored-by: evan <[email protected]>
Co-authored-by: evan <[email protected]>
Co-authored-by: evan <[email protected]>
Co-authored-by: evan <[email protected]>
|
Cursor Agent can help with this pull request. Just |
|
@cursoragent roll back the latest commit |
|
I can do that, but quick check: do you want a safe revert (adds a new commit that undoes the latest one), or a history rewrite (reset/force-push)?
Tell me which one you prefer and I’ll proceed. Learn more about Cursor Agents |
|
@cursoragent roll back the latest commit |
|
I can roll back the latest commit.
Which approach do you want? Learn more about Cursor Agents |
Add
contextparameter support to Python prompt handlers for SDK parity and future-proofing, while ensuring backward compatibility.This change uses
inspect.signatureto detect if a prompt handler accepts thecontextparameter, allowing both new and legacy handler signatures to coexist without breaking existing code.Linear Issue: TOO-202
Note
Introduce context parameter support for Python prompt handlers, automatically detected and propagated through Context and Server while preserving legacy handlers.
PromptHandlerTypesupporting both legacyhandler(args)and newhandler(context, args)signatures with introspection-based detection.PromptHandler.get_messagesandPromptManager.get_promptto accept/passcontext; raisePromptErrorif required context is missing.get_type_hints,Annotated/Unionunwrap, safe string refs) and cast results.Prompts.getto forward the activeContextto the prompt manager._handle_get_promptnow retrieves the current model context and passes it to the prompt manager.1.14.1.Written by Cursor Bugbot for commit d9d1544. This will update automatically on new commits. Configure here.