fix: add MCP result validation, improve agent error handling and state management

- Add `_extract_mcp_content_text()` helper in naliia_tools.py to safely
  extract text from MCP results, preventing IndexError on empty content
- Replace all direct `result.content[0].text` accesses with safe helper
- Improve customer identification with preservation of existing state
- Add proper JSON parsing with fallback and error handling
- Simplify webhook state management (use agent's checkpointer internally)
- Update system prompt to remove check_mcp_connection tool reference
- Fix tests to use async mocks and correct expected values
This commit is contained in:
2026-03-19 21:11:28 -05:00
parent 12822784b0
commit 30345538f7
7 changed files with 231 additions and 91 deletions

View File

@@ -32,7 +32,7 @@ class TestAgentConstruction:
agent = Agent(model=mock_model)
assert agent.config.max_iterations == 200
assert agent.config.max_iterations == 10
assert "helpful assistant" in agent.config.system_prompt
assert agent.tools == []