-
Notifications
You must be signed in to change notification settings - Fork 569
Fix: Add middleware support for resource context injection(#431) #432
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
Fix: Add middleware support for resource context injection(#431) #432
Conversation
WalkthroughThe PR refactors the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Possibly related issues
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (4)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes issue #431 by extending middleware support to inject unity_instance into resource contexts, ensuring resources can access the active Unity instance after set_active_instance is called.
Key Changes:
- Extracted common injection logic into a reusable
_inject_unity_instancemethod - Added
on_read_resourcemiddleware hook to support resource operations - Refactored
on_call_toolto use the extracted injection method
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| async def on_read_resource(self, context: MiddlewareContext, call_next): | ||
| """Inject active Unity instance into resource context if available.""" | ||
| await self._inject_unity_instance(context) | ||
| return await call_next(context) |
Copilot
AI
Dec 5, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new on_read_resource method lacks test coverage. Since the repository has comprehensive tests for on_call_tool (see test_instance_routing_comprehensive.py), similar tests should be added for on_read_resource to verify that:
- The middleware correctly injects
unity_instanceinto resource contexts - Resources can successfully retrieve the active instance via
get_unity_instance_from_context - The behavior matches that of tool calls
|
This looks good @MyNameisPI , thanks for the catch and fix! |
unity_instancefrom context #431Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.