Skip to content

Conversation

@evantahler
Copy link
Contributor

@evantahler evantahler commented Dec 12, 2025

Add context parameter support to Python prompt handlers for SDK parity and future-proofing, while ensuring backward compatibility.

This change uses inspect.signature to detect if a prompt handler accepts the context parameter, allowing both new and legacy handler signatures to coexist without breaking existing code.


Linear Issue: TOO-202

Open in Cursor Open in Web


Note

Introduce context parameter support for Python prompt handlers, automatically detected and propagated through Context and Server while preserving legacy handlers.

  • Prompts/PromptManager:
    • Add PromptHandlerType supporting both legacy handler(args) and new handler(context, args) signatures with introspection-based detection.
    • Extend PromptHandler.get_messages and PromptManager.get_prompt to accept/pass context; raise PromptError if required context is missing.
    • Improve type handling (use get_type_hints, Annotated/Union unwrap, safe string refs) and cast results.
  • Context:
    • Update Prompts.get to forward the active Context to the prompt manager.
  • Server:
    • _handle_get_prompt now retrieves the current model context and passes it to the prompt manager.
  • Tests:
    • Add comprehensive tests covering context-aware and legacy handlers, async/sync functions, mixed registration, logging with context, and error when context is required but absent.
  • Version:
    • Bump package version to 1.14.1.

Written by Cursor Bugbot for commit d9d1544. This will update automatically on new commits. Configure here.

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
Copy link

cursor bot commented Dec 12, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@codecov
Copy link

codecov bot commented Dec 12, 2025

Codecov Report

❌ Patch coverage is 62.85714% with 26 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...de-mcp-server/arcade_mcp_server/managers/prompt.py 64.70% 24 Missing ⚠️
...ibs/arcade-mcp-server/arcade_mcp_server/context.py 0.00% 1 Missing ⚠️
libs/arcade-mcp-server/arcade_mcp_server/server.py 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@cursor
Copy link

cursor bot commented Dec 12, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@evantahler evantahler marked this pull request as ready for review December 12, 2025 16:57
@cursor
Copy link

cursor bot commented Dec 12, 2025

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@evantahler
Copy link
Contributor Author

@cursoragent roll back the latest commit

@cursor
Copy link

cursor bot commented Dec 12, 2025

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)?

  • Recommended for PRs: git revert HEAD (keeps history intact)
  • Only if you’re OK rewriting history: git reset --hard HEAD~1 + force-push

Tell me which one you prefer and I’ll proceed.


Open in Cursor Open in Web

Learn more about Cursor Agents

@evantahler
Copy link
Contributor Author

@cursoragent roll back the latest commit

@cursor
Copy link

cursor bot commented Dec 12, 2025

I can roll back the latest commit.

  • If you want a history rewrite, I’ll drop it with git reset --hard HEAD~1 and then force-push the branch so the PR updates.
  • If you’d rather keep history intact, I can revert it instead (git revert HEAD).

Which approach do you want?


Open in Cursor Open in Web

Learn more about Cursor Agents

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants