-
Notifications
You must be signed in to change notification settings - Fork 24
feat(client): Allow customizing memory tool descriptions with ToolSchema wrapper classes #100
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
Conversation
here we go again, attempt to fix issue redis#96
add some documentation
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 introduces ToolSchema and ToolSchemaCollection wrapper classes that provide a fluent API for customizing tool descriptions, names, and parameter descriptions before passing them to LLMs. This enables users to tailor tool schemas for specific use cases, LLM providers, or application domains without manually modifying dictionaries. The implementation maintains full backwards compatibility through dict-like access patterns.
Key Changes:
- New
ToolSchemaclass wraps individual tool schema dictionaries with methods for customization (set_description, set_name, set_parameter_description) and supports both OpenAI and Anthropic formats - New
ToolSchemaCollectionclass wraps lists of tool schemas with bulk customization operations (get_by_name, set_description, set_name) - All 20 tool schema methods in
MemoryAPIClientnow return wrapper types instead of plain dicts, with backwards compatibility maintained via__getitem__implementation
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
agent-memory-client/agent_memory_client/tool_schema.py |
New module defining ToolSchema and ToolSchemaCollection classes with fluent API for customization |
agent-memory-client/agent_memory_client/client.py |
Updated all 20 schema methods to return ToolSchema/ToolSchemaCollection wrappers; modified _convert_openai_to_anthropic_schema to handle both wrapper and dict inputs |
agent-memory-client/agent_memory_client/__init__.py |
Added exports for ToolSchema and ToolSchemaCollection classes |
agent-memory-client/tests/test_tool_schemas.py |
Added 16 new tests covering customization methods, backwards compatibility, and collection operations |
docs/python-sdk.md |
Added comprehensive documentation section with examples for basic customization, method chaining, bulk operations, and API reference tables |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
abrookins
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.
Looks good, my dude! 👍 LGTM
|
All tests passing locally with API keys. |
Summary
This PR introduces
ToolSchemaandToolSchemaCollectionwrapper classes that provide a fluent API for customizing tool descriptions, names, and parameter descriptions before passing them to LLMs. This allows users of theagent-memory-clientto tune tool descriptions for their specific use cases and LLM providers.Motivation
Different LLMs and use cases may benefit from customized tool descriptions. For example:
Previously, users had to manually modify the returned dictionaries, which was error-prone and didn't provide a clean API.
Attempt to fix #96
Changes
New Classes
ToolSchema- Wrapper for individual tool schema dictionaries:set_description(text)- Set custom tool descriptionset_name(name)- Set custom tool nameset_parameter_description(param, text)- Customize parameter descriptionsget_description()/get_name()/get_parameter_description(param)- Gettersto_dict()- Convert to dict for LLM consumption (returns deep copy)copy()- Create independent copy of the schemaformatpropertyschema["function"]["name"])ToolSchemaCollection- Wrapper for lists of tool schemas:get_by_name(name)- Get specific tool by nameset_description(name, text)- Set description for a tool by nameset_name(old_name, new_name)- Rename a toolnames()- Get list of all tool namesto_list()- Convert to list of dicts for LLM consumptioncopy()- Create independent copy of the collectionUpdated Methods
All 20 public schema methods now return
ToolSchemaorToolSchemaCollection:get_memory_search_tool_schema()ToolSchemaget_working_memory_tool_schema()ToolSchemaget_add_memory_tool_schema()ToolSchemaget_update_memory_data_tool_schema()ToolSchemaget_long_term_memory_tool_schema()ToolSchemaedit_long_term_memory_tool_schema()ToolSchemacreate_long_term_memory_tool_schema()ToolSchemadelete_long_term_memories_tool_schema()ToolSchemaget_current_datetime_tool_schema()ToolSchemaget_all_memory_tool_schemas()ToolSchemaCollection*_anthropic()variantsUsage Examples
Backwards Compatibility
ToolSchemaimplements__getitem__and__setitem__for dict-like accessToolSchemaCollectionis iterable and indexableschema["function"]["name"]continues to workto_dict()andto_list()return deep copies to prevent accidental mutationsFiles Changed
agent-memory-client/agent_memory_client/tool_schema.pyagent-memory-client/agent_memory_client/client.pyagent-memory-client/agent_memory_client/__init__.pyagent-memory-client/tests/test_tool_schemas.pydocs/python-sdk.mdTesting
agent-memory-client/tests/tests/test_client_tool_calls.pyruff checkChecklist
to_dict()/to_list()to prevent mutations