Pass explicit ToolContext to tools instead of hidden ContextVars
Add ToolContext dataclass (session_id, event_sink, stop_event, model,
user_id, user_role, user_info) and thread it through the execution chain:
Agent._execute_tools_with_sink → ToolExecutor → tool.execute().

All ~25 tools updated to accept ctx parameter. Tools that previously
read ContextVar now prefer ctx when provided, falling back to
ContextVar for backward compatibility.

Tests updated to pass ToolContext explicitly — no more test fixtures
that set current_session_id / current_user_id ContextVars.

ContextVar setters remain as fallback for non-tool consumers
(ai_helper, context_builder, planning) and will be removed in a
follow-up refactor.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 14f2753 commit 3d182f641bfcf8dce5d029cfafb25d1e6293e581
@Eugene Sukhodolskiy Eugene Sukhodolskiy authored on 23 May
Showing 36 changed files
View
docs/architecture_weak_spots.md
View
navi/core/agent.py
View
navi/core/subagent_runner.py
View
navi/core/tool_executor.py
View
navi/mcp/tools.py
View
navi/tools/_internal/base.py
View
navi/tools/code_exec.py
View
navi/tools/content_publish.py
View
navi/tools/create_mcp_server.py
View
navi/tools/filesystem.py
View
navi/tools/image_view.py
View
navi/tools/list_profiles.py
View
navi/tools/list_tools.py
View
navi/tools/manage_recall.py
View
navi/tools/mcp_status.py
View
navi/tools/memory.py
View
navi/tools/reflect.py
View
navi/tools/reload_tools.py
View
navi/tools/schedule_recall.py
View
navi/tools/scratchpad.py
View
navi/tools/share_file.py
View
navi/tools/spawn_agent.py
View
navi/tools/ssh_exec.py
View
navi/tools/switch_profile.py
View
navi/tools/terminal.py
View
navi/tools/test_mcp_tool.py
View
navi/tools/todo.py
View
navi/tools/tool_manual.py
View
tests/conftest_factory.py
View
tests/unit/tools/test_content_publish.py
View
tests/unit/tools/test_memory.py
View
tests/unit/tools/test_recall_tools.py
View
tests/unit/tools/test_scratchpad.py
View
tests/unit/tools/test_share_file.py
View
tests/unit/tools/test_spawn_agent.py
View
tests/unit/tools/test_todo.py