async def test_continuation_id_works_across_different_tools(self, mock_redis):
        """Test that a continuation_id from one tool can be used with another tool"""
        mock_client = Mock()
        mock_redis.return_value = mock_client

        # Step 1: Analysis tool creates a conversation with follow-up
        with patch.object(self.analysis_tool, "create_model") as mock_create_model:
            mock_model = Mock()
            mock_response = Mock()
            mock_response.candidates = [
                Mock(
                    content=Mock(
                        parts=[
                            Mock(
                                text="""Found potential security issues in authentication logic.

```json
{
  "follow_up_question": "Would you like me to review these security findings in detail?",
  "suggested_params": {"findings": "Authentication bypass vulnerability detected"},
  "ui_hint": "Security review recommended"
}
```"""
                            )
                        ]
                    ),
                    finish_reason="STOP",
                )
            ]
            mock_model.generate_content.return_value = mock_response
            mock_create_model.return_value = mock_model

            # Execute analysis tool
            arguments = {"code": "function authenticate(user) { return true; }"}
            response = await self.analysis_tool.execute(arguments)
            response_data = json.loads(response[0].text)

            assert response_data["status"] == "requires_continuation"
            continuation_id = response_data["follow_up_request"]["continuation_id"]

        # Step 2: Mock the existing thread context for the review tool
        # The thread was created by analysis_tool but will be continued by review_tool
        existing_context = ThreadContext(
            thread_id=continuation_id,
            created_at="2023-01-01T00:00:00Z",
            last_updated_at="2023-01-01T00:01:00Z",
            tool_name="test_analysis",  # Original tool
            turns=[
                ConversationTurn(
                    role="assistant",
                    content="Found potential security issues in authentication logic.",
                    timestamp="2023-01-01T00:00:30Z",
                    tool_name="test_analysis",  # Original tool
                    follow_up_question="Would you like me to review these security findings in detail?",
                )
            ],
            initial_context={"code": "function authenticate(user) { return true; }"},
        )

        # Mock the get call to return existing context for add_turn to work
        def mock_get_side_effect(key):
            if key.startswith("thread:"):
                return existing_context.model_dump_json()
            return None

        mock_client.get.side_effect = mock_get_side_effect

        # Step 3: Review tool uses the same continuation_id
        with patch.object(self.review_tool, "create_model") as mock_create_model:
            mock_model = Mock()
            mock_response = Mock()
            mock_response.candidates = [
                Mock(
                    content=Mock(
                        parts=[
                            Mock(
                                text="Critical security vulnerability confirmed. The authentication function always returns true, bypassing all security checks."
                            )
                        ]
                    ),
                    finish_reason="STOP",
                )
            ]
            mock_model.generate_content.return_value = mock_response
            mock_create_model.return_value = mock_model

            # Execute review tool with the continuation_id from analysis tool
            arguments = {
                "findings": "Authentication bypass vulnerability detected",
                "continuation_id": continuation_id,
            }
            response = await self.review_tool.execute(arguments)
            response_data = json.loads(response[0].text)

            # Should offer continuation since there are remaining turns available
            assert response_data["status"] == "continuation_available"
            assert "Critical security vulnerability confirmed" in response_data["content"]

        # Step 4: Verify the cross-tool continuation worked
        # Should have at least 2 setex calls: 1 from analysis tool follow-up, 1 from review tool add_turn
        setex_calls = mock_client.setex.call_args_list
        assert len(setex_calls) >= 2  # Analysis tool creates thread + review tool adds turn

        # Get the final thread state from the last setex call
        final_thread_data = setex_calls[-1][0][2]  # Last setex call's data
        final_context = json.loads(final_thread_data)

        assert final_context["thread_id"] == continuation_id
        assert final_context["tool_name"] == "test_analysis"  # Original tool name preserved
        assert len(final_context["turns"]) == 2  # Original + new turn

        # Verify the new turn has the review tool's name
        second_turn = final_context["turns"][1]
        assert second_turn["role"] == "assistant"
        assert second_turn["tool_name"] == "test_review"  # New tool name
        assert "Critical security vulnerability confirmed" in second_turn["content"]
Test that a continuation_id from one tool can be used with another tool
tests/test_cross_tool_continuation.py