-
Notifications
You must be signed in to change notification settings - Fork 7
fix: GlobalRuntime direct access for auxiliary memory #187
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: develop
Are you sure you want to change the base?
Conversation
…ary cache Signed-off-by: Amitha Dissanayake <[email protected]>
Signed-off-by: Amitha Dissanayake <[email protected]>
Signed-off-by: Amitha Dissanayake <[email protected]>
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 refactors the auxiliary memory access pattern by introducing the AuxiliaryCache class as a cleaner public API for accessing volatile and non-volatile caches. The change removes direct exposure of GlobalRuntime to external users while maintaining internal access through ModuleLoader.runtime().
Key changes:
- Introduced
AuxiliaryCachewith static methodsget_volatile_cache()andget_non_volatile_cache()as the new public API - Replaced
GlobalRuntime.instance()access withModuleLoader.runtime()in internal API handlers and services - Updated all examples and documentation to use the new
AuxiliaryCacheAPI
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
ak-py/src/agentkernel/core/runtime.py |
Added AuxiliaryCache class with static methods for cache access; moved cache retrieval methods from Runtime to AuxiliaryCache |
ak-py/src/agentkernel/core/__init__.py |
Updated exports to expose AuxiliaryCache instead of GlobalRuntime |
ak-py/src/agentkernel/core/service.py |
Changed from GlobalRuntime.instance() to ModuleLoader.runtime() for internal runtime access |
ak-py/src/agentkernel/api/handler.py |
Updated agent listing to use ModuleLoader.runtime() instead of GlobalRuntime.instance() |
ak-py/src/agentkernel/api/mcp/akmcp.py |
Updated MCP integration to use ModuleLoader.runtime() for agent access |
ak-py/src/agentkernel/api/a2a/a2a.py |
Updated A2A integration to use ModuleLoader.runtime() for agent access |
examples/memory/key-value-cache/app.py |
Updated example to use AuxiliaryCache.get_volatile_cache() instead of GlobalRuntime.instance().get_volatile_cache() |
examples/memory/key-value-cache/README.md |
Updated documentation to reference new AuxiliaryCache API |
examples/api/hooks/demonstration.py |
Updated import to use agentkernel.core.runtime.GlobalRuntime for internal demonstration purposes |
examples/api/hooks/README.md |
Updated example code snippets to show module-based hook registration instead of runtime-based |
docs/docs/architecture/memory-management.md |
Updated documentation to reference AuxiliaryCache API for cache access |
docs/blog/2025-12-18-hooks-and-smart-memory.md |
Updated blog examples to use AuxiliaryCache.get_volatile_cache() |
ak-py/src/agentkernel/core/session/base.py |
Minor docstring formatting improvement for consistency |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
tharindud
left a comment
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.
This looks fine. However I would suggest the following changes.
- The
ModuleLoader.runtime()was put in place for the module loader to access the current active runtime. This is externally set when aRuntimeis activated viawith. - It would be better to refactor this code for general use. For example we could improve this by moving this to the
Runtimeclass. For example,Runtime.current()could return the currently active runtime (either aRuntimeinstance capturedwithor defaulting to theGlobalRuntimeinstance). - We can then get rid of
ModuleLoader.runtime()and replace it withRuntime.current().
Description
There was no way of accessing the auxiliary cache without accessing the
Runtimeobject for users. This PR solves that by introducingAuxiliaryCacheclass.Direct exposure of
GlobalRuntimeclass has also been removed.Type of Change
Related Issues
Changes Made
AuxiliaryCacheGlobalRuntimeaccess withModuleLoaderwherever neededTesting
Checklist
Screenshots (if applicable)
Additional Notes