Skip to content

Conversation

@mrinalwadhwa
Copy link
Member

No description provided.

- Remove mem0ai package from dependencies in pyproject.toml
- Delete source/python/python/autonomy/knowledge/mem0.py
- Remove Mem0Knowledge from knowledge module exports
- Remove mem0.memory.main logger configuration
- Update uv.lock
- Replace threading.RLock with asyncio.Lock for async compatibility
- Add max_active_messages and max_active_tokens configuration
- Add optional Model parameter for token counting
- Convert active_messages to use Dict[Tuple[str, str], List[dict]]
- Add metrics tracking for monitoring memory usage
- Improve database initialization with retry logic and better error handling
- Add comprehensive docstrings
- Remove json import (was unused)
- Remove knowledge, memory_model, and memory_embeddings_model parameters
- Remove contextual_knowledge from AgentStateMachine
- Add max_active_messages and max_active_tokens parameters for memory config
- Remove unused copy import
- Remove KnowledgeProvider, Mem0Knowledge, NoopKnowledge imports
- Remove ConversationRole import (unused)
- Remove AgentMemoryKnowledge class (unused)
- Update NodeController to match new Agent API signature
- Simplify complete_chat to no longer accept contextual_knowledge
- Add new KnowledgeTool class that wraps KnowledgeProvider
- Allows knowledge to be accessed via the tool system
- Export KnowledgeTool from knowledge module and main module
- Provides search_knowledge functionality as a callable tool
- Remove memory_model, memory_embeddings_model, and knowledge parameters
- Replace knowledge parameter with KnowledgeTool in tools list
- Import KnowledgeTool in test_agents.py
- Update all Agent instantiations to match new signature
- Fix formatting in some test cases
… tests

- Add comprehensive module documentation explaining agent architecture
- Document key components: Agent, StateMachine, State, ConversationResponse
- Add references to practical guides in docs
- Update agent tests to reflect new implementation
- Improve code organization and structure (736 additions, 151 deletions)
- Add WAITING_FOR_INPUT state to agent state machine
- Create builtin_tools.py with AskUserForInputTool
- Add pause/resume mechanism for agent execution
- Update state machine diagram to include new state and transitions
- Add WAITING_FOR_INPUT phase to message protocol
- Support for agents to request user input and wait for response
- Add consistent log prefixes like [STATE_MACHINE], [STATE:THINKING], etc.
- Improve log formatting for better readability and debugging
- Add more detailed logging for state transitions and iterations
- Enhance error and warning messages with context
When streaming responses end with tool calls, the model sends an empty
finish chunk after accumulating tool call data. Previously, this empty
chunk would yield an empty message and break the loop before accumulated
tool calls could be yielded.

Changes:
- Skip yielding empty finish chunks when tool calls are accumulated
- Only break if no tool calls exist (pure text response)
- Fall through to tool call yielding logic when finish_reason='tool_calls'

This fixes the final bug in streaming tool call support.
Models may send tool arguments as strings (e.g., "5") when integers
are expected. This commit adds automatic type coercion to convert
arguments to their expected types based on function type hints.

Changes:
- Add _coerce_argument_types() method to Tool class
- Add _coerce_value() to handle individual type conversions
- Support coercion: str->int, str->float, str->bool, int->float, any->str
- Handle Optional types by extracting the non-None type
- Add debug logging when type coercion occurs
- Provide clear error messages when coercion fails

Tests:
- Add comprehensive test suite (15 tests) covering:
  - Valid coercions (str to int/float/bool, int to float/bool, etc.)
  - Invalid coercions (proper error handling)
  - Optional parameters with defaults
  - Multiple typed parameters
  - Edge cases (empty/null arguments)

This fixes TypeError issues when models pass numeric parameters as
strings, such as: TypeError: unsupported operand type(s) for -: 'str' and 'int'
The previous type coercion implementation didn't properly handle generic
types from the typing module (List, Dict, Set, Tuple). This caused
failures when comparing runtime types (list, dict) against type hints
(List[int], Dict[str, Any]).

Changes:
- Check get_origin() for generic types before isinstance()
- Handle List/Dict/Set/Tuple by comparing against origin type
- Wrap isinstance() in try/except to handle generic types gracefully
- Move isinstance() check after origin check to avoid TypeError

This fixes test failures:
- test_agent_tool_with_complex_parameters
- test_agent_tool_chaining
- test_agent_tool_parameter_validation

All tool tests (44) and agent tests (196) now pass.
- Add factory pattern for tool creation and registration
- Implement filesystem tools (read_file, write_file, list_directory, create_directory, delete_file, delete_directory)
- Update tool registration to use factory pattern in spawner
- Add comprehensive tests for filesystem tools
- Export factory and filesystem tools from autonomy.tools module
@mrinalwadhwa mrinalwadhwa requested a review from Copilot November 6, 2025 23:03
Copy link

Copilot AI left a 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 adds filesystem tools with configurable visibility levels and type coercion for tool arguments, along with comprehensive test coverage. The main changes include:

  • Adds FilesystemTools for file operations with four visibility levels (all, agent, scope, conversation)
  • Implements type coercion for tool arguments (string to int/float/bool conversions)
  • Removes mem0 knowledge provider dependency
  • Updates agent architecture for better memory management and pause/resume support

Reviewed Changes

Copilot reviewed 23 out of 24 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
source/python/tests/tools/test_tool_type_coercion.py Comprehensive tests for tool argument type coercion feature
source/python/tests/tools/test_filesystem_tools.py Complete test suite for FilesystemTools including security, operations, and edge cases
source/python/tests/models/test_models.py Removes obsolete memory_model and knowledge parameters from agent initialization
source/python/tests/models/test_bedrock_client.py.bak2 Deletes deprecated backup test file
source/python/tests/agents/test_agents.py Updates agent tests to use KnowledgeTool wrapper and removes deprecated parameters
source/python/src/nodes/spawner.rs Adds scope/conversation context extraction and passes to worker constructor
source/python/python/autonomy/tools/tool.py Implements type coercion for tool arguments with detailed error handling
source/python/python/autonomy/tools/filesystem.py New FilesystemTools implementation with four visibility levels and complete file operations
source/python/python/autonomy/tools/factory.py Adds ToolFactory protocol for scope-aware tool creation
source/python/python/autonomy/tools/init.py Exports FilesystemTools and ToolFactory
source/python/python/autonomy/nodes/remote.py Updates remote node handling to remove deprecated memory/knowledge parameters
source/python/python/autonomy/nodes/message.py Adds WAITING_FOR_INPUT phase for human-in-the-loop support
source/python/python/autonomy/memory/memory.py Major refactor: async operations, two-tier memory, token-aware trimming
source/python/python/autonomy/logs/logs.py Removes mem0 logger configuration
source/python/python/autonomy/knowledge/tool.py Adds KnowledgeTool wrapper for knowledge providers
source/python/python/autonomy/knowledge/mem0.py Removes mem0 knowledge provider implementation
source/python/python/autonomy/knowledge/init.py Removes Mem0Knowledge and exports KnowledgeTool
source/python/python/autonomy/agents/builtin_tools.py Adds ask_user_for_input built-in tool
source/python/python/autonomy/agents/agent.py Major refactor: state machine improvements, pause/resume, better memory scoping
source/python/python/autonomy/init.py Updates exports to include new tools and remove mem0
source/python/pyproject.toml Removes mem0ai dependency
source/python/Makefile Adds --no-cache flag to Docker builds
examples/001/autonomy.yaml Adds explicit inlet port configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mrinalwadhwa mrinalwadhwa merged commit 3cfb6a9 into main Nov 6, 2025
3 checks passed
@mrinalwadhwa mrinalwadhwa deleted the mrinal/example branch November 6, 2025 23:15
@mrinalwadhwa mrinalwadhwa restored the mrinal/example branch November 6, 2025 23:16
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.

2 participants